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