mirror of https://github.com/apache/openjpa.git
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:
parent
86e17fc210
commit
777818d283
|
@ -64,7 +64,8 @@ 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
|
||||||
* <code>topic/OpenJPACommitProviderTopic</code>.
|
* <code>topic/OpenJPACommitProviderTopic</code>.
|
||||||
|
@ -151,6 +152,7 @@ public class JMSRemoteCommitProvider
|
||||||
*/
|
*/
|
||||||
public void endConfiguration() {
|
public void endConfiguration() {
|
||||||
super.endConfiguration();
|
super.endConfiguration();
|
||||||
|
_appClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,29 +206,36 @@ public class JMSRemoteCommitProvider
|
||||||
_topicName, m.getClass().getName()));
|
_topicName, m.getClass().getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectMessage om = (ObjectMessage) m;
|
ClassLoader saveCls = Thread.currentThread()
|
||||||
Object o;
|
.getContextClassLoader();
|
||||||
try {
|
try {
|
||||||
o = om.getObject();
|
if (saveCls != _appClassLoader)
|
||||||
|
Thread.currentThread().setContextClassLoader(
|
||||||
|
_appClassLoader);
|
||||||
|
ObjectMessage om = (ObjectMessage) m;
|
||||||
|
Object o = om.getObject();
|
||||||
|
|
||||||
|
if (o instanceof RemoteCommitEvent) {
|
||||||
|
if (log.isTraceEnabled())
|
||||||
|
log.trace(s_loc.get("jms-received-update",
|
||||||
|
_topicName));
|
||||||
|
|
||||||
|
RemoteCommitEvent rce = (RemoteCommitEvent) o;
|
||||||
|
fireEvent(rce);
|
||||||
|
} else {
|
||||||
|
if (log.isWarnEnabled())
|
||||||
|
log.warn(s_loc.get("jms-receive-error-2",
|
||||||
|
o.getClass().getName(), _topicName));
|
||||||
|
}
|
||||||
} catch (JMSException jmse) {
|
} catch (JMSException jmse) {
|
||||||
if (log.isWarnEnabled())
|
if (log.isWarnEnabled())
|
||||||
log.warn(s_loc.get("jms-receive-error-1"), jmse);
|
log.warn(s_loc.get("jms-receive-error-1"), jmse);
|
||||||
return;
|
} finally {
|
||||||
|
if (saveCls != _appClassLoader)
|
||||||
|
Thread.currentThread().setContextClassLoader(saveCls);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o instanceof RemoteCommitEvent) {
|
|
||||||
if (log.isTraceEnabled())
|
|
||||||
log.trace(s_loc.get("jms-received-update",
|
|
||||||
_topicName));
|
|
||||||
|
|
||||||
RemoteCommitEvent rce = (RemoteCommitEvent) o;
|
|
||||||
fireEvent(rce);
|
|
||||||
} else {
|
|
||||||
if (log.isWarnEnabled())
|
|
||||||
log.warn(s_loc.get("jms-receive-error-2",
|
|
||||||
o.getClass().getName(), _topicName));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue