ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r549636 - in /incubator/ode/trunk: axis2/src/main/java/org/apache/ode/axis2/ bpel-api/src/main/java/org/apache/ode/bpel/iapi/ bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ bpel-test/src/main/java/org/apache/ode/test/ jbi/src/main/j...
Date Thu, 21 Jun 2007 22:28:23 GMT
Author: mriou
Date: Thu Jun 21 15:28:21 2007
New Revision: 549636

URL: http://svn.apache.org/viewvc?view=rev&rev=549636
Log:
Applying BPEL event listeners patch from Tammo (see ODE-139).

Modified:
    incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
    incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEventListener.java
    incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
    incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
    incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java

Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?view=diff&rev=549636&r1=549635&r2=549636
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java Thu Jun 21
15:28:21 2007
@@ -460,6 +460,7 @@
             // dehy.setProcessMaxAge(10000);
             _server.setDehydrationPolicy(dehy);
         }
+        _server.setConfigProperties(_odeConfig.getProperties());
         _server.init();
     }
 

Modified: incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEventListener.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEventListener.java?view=diff&rev=549636&r1=549635&r2=549636
==============================================================================
--- incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEventListener.java
(original)
+++ incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEventListener.java
Thu Jun 21 15:28:21 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.ode.bpel.iapi;
 
+import java.util.Properties;
+
 import org.apache.ode.bpel.evt.BpelEvent;
 
 /**
@@ -34,4 +36,26 @@
      * @param bpelEvent BPEL event
      */
     void onEvent(BpelEvent bpelEvent);
+	
+    /**
+     * Allows the initialisation of listeners. Called directly
+     * after removing the listener from the listeners list. 
+     * 
+     * <code>configProperties</code> provide access to 
+     * configuration option defined in Ode's configuration file 
+     * (depends on the used IL implementation). This parameter might 
+     * be null if no configuration options are available (i.e. in test 
+     * cases).
+     * 
+     * @param configProperties configuration properties
+     * 
+     */
+    void startup(Properties configProperties);
+    
+    /**
+     * Allows the clean up in listener implementations. Called 
+     * directly before adding the listener to the listeners list.
+     */
+    void shutdown();
+
 }

Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?view=diff&rev=549636&r1=549635&r2=549636
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
(original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
Thu Jun 21 15:28:21 2007
@@ -21,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -85,6 +86,8 @@
     private State _state = State.SHUTDOWN;
     private Contexts _contexts = new Contexts();
     private DehydrationPolicy _dehydrationPolicy;
+    private Properties _configProperties;
+    
     BpelEngineImpl _engine;
     BpelDatabase _db;
 
@@ -145,7 +148,8 @@
      */
     public void registerBpelEventListener(BpelEventListener listener) {
         // Do not synchronize, eventListeners is copy-on-write array.
-        _contexts.eventListeners.add(listener);
+    	listener.startup(_configProperties);
+    	_contexts.eventListeners.add(listener);
     }
 
     /**
@@ -155,7 +159,19 @@
      */
     public void unregisterBpelEventListener(BpelEventListener listener) {
         // Do not synchronize, eventListeners is copy-on-write array.
-        _contexts.eventListeners.remove(listener);
+    	try {
+    		listener.shutdown();
+    	} catch (Exception e) {
+    		__log.warn("Stopping BPEL event listener " + listener.getClass().getName() + " failed,
nevertheless it has been unregistered.", e);
+    	} finally {
+    		_contexts.eventListeners.remove(listener);
+    	}
+    }
+    
+    private void unregisterBpelEventListeners() {
+    	for (BpelEventListener l : _contexts.eventListeners) {
+    		unregisterBpelEventListener(l);
+    	}
     }
 
     public void stop() {
@@ -199,6 +215,7 @@
         _mngmtLock.writeLock().lock();
         try {
             stop();
+            unregisterBpelEventListeners();
 
             _db = null;
             _engine = null;
@@ -388,6 +405,10 @@
         _dehydrationPolicy = dehydrationPolicy;
     }
 
+    public void setConfigProperties(Properties configProperties) {
+    	_configProperties = configProperties;
+    }
+    
     public void setMessageExchangeContext(MessageExchangeContext mexContext) throws BpelEngineException
{
         _contexts.mexContext = mexContext;
     }

Modified: incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java?view=diff&rev=549636&r1=549635&r2=549636
==============================================================================
--- incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
(original)
+++ incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
Thu Jun 21 15:28:21 2007
@@ -32,6 +32,7 @@
 import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl;
 import org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl;
 import org.apache.ode.il.MockScheduler;
+import org.apache.ode.il.config.OdeConfigProperties;
 import org.apache.ode.store.ProcessConfImpl;
 import org.apache.ode.store.ProcessStoreImpl;
 import org.apache.ode.utils.DOMUtils;
@@ -141,6 +142,7 @@
                 }
             }
         });
+        _server.setConfigProperties(getConfigProperties());
         _server.init();
         _server.start();
     }
@@ -383,6 +385,18 @@
         return new File(deployxmlurl.getPath()).getParentFile();
     }
 
+    /**
+     * Override this to provide configuration properties for Ode extensions 
+     * like BpelEventListeners.
+     * 
+     * @return
+     */
+    protected Properties getConfigProperties() {
+    	// could also return null, returning an empty properties 
+    	// object is more fail-safe.
+    	return new Properties();
+    }
+    
     protected static class Failure {
         Object where;
 

Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java?view=diff&rev=549636&r1=549635&r2=549636
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java Thu Jun 21
15:28:21 2007
@@ -214,6 +214,7 @@
         _ode._server.setMessageExchangeContext(_ode._mexContext);
         _ode._server.setBindingContext(new BindingContextImpl(_ode));
         _ode._server.setScheduler(_ode._scheduler);
+	_ode._server.setConfigProperties(_ode._config.getProperties());
 
         _ode._server.init();
 



Mime
View raw message