openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r633723 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java
Date Wed, 05 Mar 2008 00:24:47 GMT
Author: pcl
Date: Tue Mar  4 16:24:45 2008
New Revision: 633723

URL: http://svn.apache.org/viewvc?rev=633723&view=rev
Log:
OPENJPA-520. Committing on behalf of Qin Feng.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java?rev=633723&r1=633722&r2=633723&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java
Tue Mar  4 16:24:45 2008
@@ -64,7 +64,8 @@
     private TopicConnection _connection;
     private TopicSession _session;
     private TopicPublisher _publisher;
-
+    private ClassLoader _appClassLoader;
+    
     /**
      * Sets the JMS Topic name. Defaults to
      * <code>topic/OpenJPACommitProviderTopic</code>.
@@ -151,6 +152,7 @@
      */
     public void endConfiguration() {
         super.endConfiguration();
+        _appClassLoader = Thread.currentThread().getContextClassLoader();
         connect();
     }
 
@@ -204,29 +206,36 @@
                             _topicName, m.getClass().getName()));
                     return;
                 }
-
-                ObjectMessage om = (ObjectMessage) m;
-                Object o;
+                
+                ClassLoader saveCls = Thread.currentThread()
+                    .getContextClassLoader();
                 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) {
                     if (log.isWarnEnabled())
                         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));
-                }
             }
         };
     }



Mime
View raw message