OPENJPA-520. Committing on behalf of Qin Feng.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@633723 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2008-03-05 00:24:45 +00:00
parent 86e17fc210
commit 777818d283
1 changed files with 27 additions and 18 deletions

View File

@ -64,6 +64,7 @@ public class JMSRemoteCommitProvider
private TopicConnection _connection;
private TopicSession _session;
private TopicPublisher _publisher;
private ClassLoader _appClassLoader;
/**
* Sets the JMS Topic name. Defaults to
@ -151,6 +152,7 @@ public class JMSRemoteCommitProvider
*/
public void endConfiguration() {
super.endConfiguration();
_appClassLoader = Thread.currentThread().getContextClassLoader();
connect();
}
@ -205,15 +207,14 @@ public class JMSRemoteCommitProvider
return;
}
ObjectMessage om = (ObjectMessage) m;
Object o;
ClassLoader saveCls = Thread.currentThread()
.getContextClassLoader();
try {
o = om.getObject();
} catch (JMSException jmse) {
if (log.isWarnEnabled())
log.warn(s_loc.get("jms-receive-error-1"), jmse);
return;
}
if (saveCls != _appClassLoader)
Thread.currentThread().setContextClassLoader(
_appClassLoader);
ObjectMessage om = (ObjectMessage) m;
Object o = om.getObject();
if (o instanceof RemoteCommitEvent) {
if (log.isTraceEnabled())
@ -227,6 +228,14 @@ public class JMSRemoteCommitProvider
log.warn(s_loc.get("jms-receive-error-2",
o.getClass().getName(), _topicName));
}
} catch (JMSException jmse) {
if (log.isWarnEnabled())
log.warn(s_loc.get("jms-receive-error-1"), jmse);
} finally {
if (saveCls != _appClassLoader)
Thread.currentThread().setContextClassLoader(saveCls);
}
}
};
}