ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r584964 - in /ode/trunk: ./ extensions/jms-eventpublisher/ extensions/jms-eventpublisher/src/ extensions/jms-eventpublisher/src/main/ extensions/jms-eventpublisher/src/main/java/ extensions/jms-eventpublisher/src/main/java/org/ extensions/j...
Date Mon, 15 Oct 2007 23:07:56 GMT
Author: vanto
Date: Mon Oct 15 16:07:54 2007
New Revision: 584964

URL: http://svn.apache.org/viewvc?rev=584964&view=rev
Log:
Example BPEL event listener added.
Added extensions into the build loop, extensions are now included into distro packages.

Added:
    ode/trunk/extensions/jms-eventpublisher/
    ode/trunk/extensions/jms-eventpublisher/src/
    ode/trunk/extensions/jms-eventpublisher/src/main/
    ode/trunk/extensions/jms-eventpublisher/src/main/java/
    ode/trunk/extensions/jms-eventpublisher/src/main/java/org/
    ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/
    ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/
    ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/
    ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/
    ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java
    ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java
Modified:
    ode/trunk/Rakefile

Modified: ode/trunk/Rakefile
URL: http://svn.apache.org/viewvc/ode/trunk/Rakefile?rev=584964&r1=584963&r2=584964&view=diff
==============================================================================
--- ode/trunk/Rakefile (original)
+++ ode/trunk/Rakefile Mon Oct 15 16:07:54 2007
@@ -128,7 +128,7 @@
 
   desc "ODE Axis Integration Layer"
   define "axis2" do
-    compile.with projects("bpel-api", "bpel-connector", "bpel-dao", "il-common", "bpel-runtime",
+    compile.with projects("bpel-api", "bpel-compiler", "bpel-connector", "bpel-dao", "il-common",
"bpel-runtime",
       "scheduler-simple", "bpel-schemas", "bpel-store", "utils"),
       AXIOM, AXIS2_ALL, COMMONS.logging, COMMONS.collections, DERBY, GERONIMO.kernel, GERONIMO.transaction,
       JAVAX.activation, JAVAX.servlet, JAVAX.stream, JAVAX.transaction, JENCKS, WSDL4J, WS_COMMONS.xml_schema,
@@ -283,10 +283,10 @@
   desc "ODE BPEL Tests"
   define "bpel-test" do
     compile.with projects("bpel-api", "bpel-compiler", "bpel-dao", "bpel-runtime",
-      "bpel-store", "utils", "il-common", "dao-jpa"),
+      "bpel-store", "utils", "il-common", "dao-jpa", "bpel-obj"),
       DERBY, Java::JUnit::JUNIT_REQUIRES, JAVAX.persistence, OPENJPA, WSDL4J, JAVAX.transaction,
COMMONS.lang
 
-    test.with projects("bpel-obj", "jacob", "bpel-schemas",
+    test.with projects("jacob", "bpel-schemas",
       "bpel-scripts", "scheduler-simple"),
       COMMONS.collections, COMMONS.lang, COMMONS.logging, DERBY, JAVAX.connector,
       JAVAX.stream, JAVAX.transaction, JAXEN, HSQLDB, LOG4J, SAXON, XERCES, XMLBEANS, XALAN
@@ -395,7 +395,7 @@
 
   desc "ODE JBI Integration Layer"
   define "jbi" do
-    compile.with projects("bpel-api", "bpel-connector", "bpel-dao", "il-common", "bpel-obj",
+    compile.with projects("bpel-api", "bpel-compiler", "bpel-connector", "bpel-dao", "il-common",
"bpel-obj",
       "bpel-runtime", "scheduler-simple", "bpel-schemas", "bpel-store", "utils"),
       COMMONS.logging, COMMONS.pool, JAVAX.transaction, JBI, LOG4J, WSDL4J, XERCES
 
@@ -456,20 +456,29 @@
 
 end
 
-  define "ode-extensions" do
-    define "extensions" do
-	  desc "E4X Assign Extension"
-	  define "e4x" do
-	    compile.with "rhino:js:jar:1.6R7", projects("ode:bpel-api", "ode:bpel-obj", "ode:utils")
-		test.with "rhino:js:jar:1.6R7", projects("ode:bpel-api", "ode:bpel-obj", "ode:jacob", "ode:bpel-schemas",
-		      "ode:bpel-scripts", "ode:scheduler-simple", "ode:bpel-test", "ode:utils", "ode:bpel-compiler",
-			  "ode:bpel-dao", "ode:bpel-runtime", "ode:bpel-store", "ode:il-common", "ode:dao-jpa"),
-		      COMMONS.collections, COMMONS.lang, COMMONS.logging, DERBY, JAVAX.connector,
-		      JAVAX.stream, JAVAX.transaction, JAXEN, HSQLDB, LOG4J, SAXON, XERCES, XMLBEANS, XALAN,
-			  DERBY, Java::JUnit::JUNIT_REQUIRES, JAVAX.persistence, OPENJPA, WSDL4J, JAVAX.transaction
-      end
-	end
+define "ode-extensions", :base_dir => "extensions" do
+  [:version, :manifest, :meta_inf].each { |prop| send "#{prop}=", project("ode").send(prop)
}
+  project.group = "org.apache.ode.extensions"
+
+  desc "E4X Extension"
+  define "e4x", :version=>"1.0-beta" do
+    compile.with "rhino:js:jar:1.6R7", projects("ode:bpel-api", "ode:bpel-obj", "ode:bpel-runtime",
"ode:bpel-compiler", "ode:utils")
+    test.with "rhino:js:jar:1.6R7", projects("ode:bpel-api", "ode:bpel-obj", "ode:jacob",
"ode:bpel-schemas",
+              "ode:bpel-scripts", "ode:scheduler-simple", "ode:bpel-test", "ode:utils", "ode:bpel-compiler",
+              "ode:bpel-dao", "ode:bpel-runtime", "ode:bpel-store", "ode:il-common", "ode:dao-jpa"),
+              COMMONS.collections, COMMONS.lang, COMMONS.logging, DERBY, JAVAX.connector,
+              JAVAX.stream, JAVAX.transaction, JAXEN, HSQLDB, LOG4J, SAXON, XERCES, XMLBEANS,
XALAN,
+              DERBY, Java::JUnit::JUNIT_REQUIRES, JAVAX.persistence, OPENJPA, WSDL4J, JAVAX.transaction
+    package :jar
+  end
+
+  desc "JMS BPEL event publisher"
+  define "jms-eventpublisher", :version=>"1.0-beta" do
+    compile.with "org.apache.activemq:apache-activemq:jar:4.2-incubator-SNAPSHOT", projects("ode:bpel-schemas",
"ode:bpel-api"),
+		XMLBEANS
+	package :jar
   end
+end
 
 define "apache-ode" do
   [:version, :group, :manifest, :meta_inf].each { |prop| send "#{prop}=", project("ode").send(prop)
}
@@ -488,6 +497,22 @@
         zip.include(pkg.to_s, :as=>"#{pkg.id}.#{pkg.type}", :path=>"lib")
       end
 
+      #Include extensions
+	  #(create a extensions folder, put extension folders in there, add README per extension
if available, 
+	  # add README.extensions to extensions folder)
+      project("ode-extensions").projects.each do |p|
+        p.packages.flatten.select{|pkg| pkg.type == :jar && !pkg.classifier}.each
do |art|
+          zip.include(art, :path=>"extensions/#{art.id}")
+		  if File.exist?(p.path_to("README"))
+		    zip.path("extensions/#{art.id}").include p.path_to("README")
+		  end
+          p.compile.classpath.select{|pkg| pkg.group != project("ode").group}.each do |lib|
+            zip.include(lib, :path=>"extensions/#{art.id}/lib")
+          end
+        end
+      end
+	  zip.path("extensions").include project("ode-extensions").path_to("README.extensions")
+
       # Including third party licenses
       Dir["#{project.path_to("license")}/*LICENSE"].each { |l| zip.include(l, :path=>"lib")
}
       zip.include(project.path_to("target/LICENSE"))
@@ -548,6 +573,6 @@
     end
   end
 
-  package(:zip, :id=>"#{id}-docs").include(javadoc(project("ode").projects).target)
+  package(:zip, :id=>"#{id}-docs").include(javadoc(project("ode").projects).target) unless
ENV["JAVADOC"] =~ /^(no|off|false|skip)$/i
 end
 

Added: ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java?rev=584964&view=auto
==============================================================================
--- ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java
(added)
+++ ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java
Mon Oct 15 16:07:54 2007
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.extension.jmseventlistener;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.evt.ActivityEvent;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.CorrelationEvent;
+import org.apache.ode.bpel.evt.CorrelationMatchEvent;
+import org.apache.ode.bpel.evt.CorrelationSetEvent;
+import org.apache.ode.bpel.evt.CorrelationSetWriteEvent;
+import org.apache.ode.bpel.evt.ExpressionEvaluationEvent;
+import org.apache.ode.bpel.evt.ExpressionEvaluationFailedEvent;
+import org.apache.ode.bpel.evt.NewProcessInstanceEvent;
+import org.apache.ode.bpel.evt.PartnerLinkEvent;
+import org.apache.ode.bpel.evt.ProcessCompletionEvent;
+import org.apache.ode.bpel.evt.ProcessEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceStartedEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceStateChangeEvent;
+import org.apache.ode.bpel.evt.ProcessMessageExchangeEvent;
+import org.apache.ode.bpel.evt.ScopeCompletionEvent;
+import org.apache.ode.bpel.evt.ScopeEvent;
+import org.apache.ode.bpel.evt.ScopeFaultEvent;
+import org.apache.ode.bpel.evt.VariableEvent;
+import org.apache.ode.bpel.iapi.BpelEventListener;
+import org.apache.ode.bpel.pmapi.TEventInfo;
+
+/**
+ * Example for a BPEL Event Listener:
+ * Publishes BPEL events to an ActiveMQ JMS topic
+ * 
+ * This listener can be configured by adding the following keys to
+ * ODE's config file:
+ * <ul>
+ *   <li><code>jel.topicname</code> - identifies the name of the target
topic.</li>
+ *   <li><code>jel.mqurl</code> - the URL to the ActiveMQ broker.</li>
+ * </ul>
+ * @author Tammo van Lessen (University of Stuttgart)
+ */
+public class JmsBpelEventListener implements BpelEventListener {
+	protected static final Log logger = LogFactory.getLog(JmsBpelEventListener.class);
+	
+	public static final String TOPIC_NAME_KEY = "jel.topicname";
+	public static final String MQ_URL_KEY = "jel.mqurl";
+	private String topicName;
+	private String url;
+
+	private ConnectionFactory factory;
+	private Connection connection;
+	private Session session;
+	private Topic topic;
+	private MessageProducer publisher;
+
+	boolean initialized = false;
+	protected Calendar _calendar = Calendar.getInstance(); 
+	
+	public void onEvent(BpelEvent bpelEvent) {
+		if (!initialized)
+			return;
+		try {
+			String msg = serializeEvent(bpelEvent);
+			if (msg != null) {
+				TextMessage om = session.createTextMessage(serializeEvent(bpelEvent));
+				publisher.send(om);
+			}
+		} catch (JMSException e) {
+			logger.warn("Event " + bpelEvent + "could not be sent", e);
+		}
+	}
+
+	public void shutdown() {
+		if (connection == null) {
+			return;
+		}
+		try {
+			connection.stop();
+			connection.close();
+			connection = null;
+			initialized = false;
+		} catch (JMSException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		factory = null;
+		logger.info("JMS BPEL event has been shutdown.");
+	}
+
+	public void startup(Properties configProperties) {
+		if (configProperties == null) {
+			logger.info("No configuration properties given. Initialization aborted.");
+			return;
+		}
+		topicName = configProperties.getProperty(TOPIC_NAME_KEY, "org.apache.ode.events");
+		url = configProperties.getProperty(MQ_URL_KEY, "tcp://localhost:61616");
+		
+		try {
+			factory = new ActiveMQConnectionFactory(url);
+			connection = factory.createConnection();
+	        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+			topic = session.createTopic(topicName);
+	        publisher = session.createProducer(topic);
+	        publisher.setDeliveryMode(DeliveryMode.PERSISTENT);
+	        initialized = true;
+		} catch (JMSException e) {
+			logger.error("Initialization failed.", e);
+		}
+		logger.info("JMS BPEL event has been started.");
+	}
+	
+	protected String serializeEvent(BpelEvent evt) {
+		TEventInfo ei = TEventInfo.Factory.newInstance();
+		fillEventInfo(ei, evt);
+		String xml = ei.toString();
+		logger.debug(xml);
+		return xml;
+	}
+
+	//TODO: This code should be reused
+    private void fillEventInfo(TEventInfo info, BpelEvent event) {
+        info.setName(BpelEvent.eventName(event));
+        info.setType(event.getType().toString());
+        info.setLineNumber(event.getLineNo());
+        info.setTimestamp(toCalendar(event.getTimestamp()));
+        if (event instanceof ActivityEvent) {
+            info.setActivityName(((ActivityEvent) event).getActivityName());
+            info.setActivityId(((ActivityEvent) event).getActivityId());
+            info.setActivityType(((ActivityEvent) event).getActivityType());
+            info.setActivityDefinitionId(((ActivityEvent) event).getActivityDeclarationId());
+        }
+        if (event instanceof CorrelationEvent) {
+            info.setPortType(((CorrelationEvent) event).getPortType());
+            info.setOperation(((CorrelationEvent) event).getOperation());
+            info.setMexId(((CorrelationEvent) event).getMessageExchangeId());
+        }
+        if (event instanceof CorrelationMatchEvent) {
+            info.setPortType(((CorrelationMatchEvent) event).getPortType());
+        }
+        if (event instanceof CorrelationSetEvent) {
+            info.setCorrelationSet(((CorrelationSetEvent) event).getCorrelationSetName());
+        }
+        if (event instanceof CorrelationSetWriteEvent) {
+            info.setCorrelationKey(((CorrelationSetWriteEvent) event).getCorrelationSetName());
+        }
+        if (event instanceof ExpressionEvaluationEvent) {
+            info.setExpression(((ExpressionEvaluationEvent) event).getExpression());
+        }
+        if (event instanceof ExpressionEvaluationFailedEvent) {
+            info.setFault(((ExpressionEvaluationFailedEvent) event).getFault());
+        }
+        if (event instanceof NewProcessInstanceEvent) {
+            if ((((NewProcessInstanceEvent) event).getRootScopeId()) != null)
+                info.setRootScopeId(((NewProcessInstanceEvent) event).getRootScopeId());
+            info.setScopeDefinitionId(((NewProcessInstanceEvent) event).getScopeDeclarationId());
+        }
+        if (event instanceof PartnerLinkEvent) {
+            info.setPartnerLinkName(((PartnerLinkEvent) event).getpLinkName());
+        }
+        if (event instanceof ProcessCompletionEvent) {
+            info.setFault(((ProcessCompletionEvent) event).getFault());
+        }
+        if (event instanceof ProcessEvent) {
+            info.setProcessId(((ProcessEvent) event).getProcessId());
+            info.setProcessType(((ProcessEvent) event).getProcessName());
+        }
+        if (event instanceof ProcessInstanceEvent) {
+            info.setInstanceId(((ProcessInstanceEvent) event).getProcessInstanceId());
+        }
+        if (event instanceof ProcessInstanceStartedEvent) {
+            info.setRootScopeId(((ProcessInstanceStartedEvent) event).getRootScopeId());
+            info.setRootScopeDeclarationId(((ProcessInstanceStartedEvent) event).getScopeDeclarationId());
+        }
+        if (event instanceof ProcessInstanceStateChangeEvent) {
+            info.setOldState(((ProcessInstanceStateChangeEvent) event).getOldState());
+            info.setNewState(((ProcessInstanceStateChangeEvent) event).getNewState());
+        }
+        if (event instanceof ProcessMessageExchangeEvent) {
+            info.setPortType(((ProcessMessageExchangeEvent) event).getPortType());
+            info.setOperation(((ProcessMessageExchangeEvent) event).getOperation());
+            info.setMexId(((ProcessMessageExchangeEvent) event).getMessageExchangeId());
+        }
+        if (event instanceof ScopeCompletionEvent) {
+            info.setSuccess(((ScopeCompletionEvent) event).isSuccess());
+            info.setFault(((ScopeCompletionEvent) event).getFault());
+        }
+        if (event instanceof ScopeEvent) {
+            info.setScopeId(((ScopeEvent) event).getScopeId());
+            if (((ScopeEvent) event).getParentScopeId() != null)
+                info.setParentScopeId(((ScopeEvent) event).getParentScopeId());
+            if (((ScopeEvent) event).getScopeName() != null)
+                info.setScopeName(((ScopeEvent) event).getScopeName());
+            info.setScopeDefinitionId(((ScopeEvent) event).getScopeDeclarationId());
+        }
+        if (event instanceof ScopeFaultEvent) {
+            info.setFault(((ScopeFaultEvent) event).getFaultType());
+            info.setFaultLineNumber(((ScopeFaultEvent) event).getFaultLineNo());
+            info.setExplanation(((ScopeFaultEvent) event).getExplanation());
+        }
+        if (event instanceof VariableEvent) {
+            info.setVariableName(((VariableEvent) event).getVarName());
+        }
+    }
+
+    /**
+     * Convert a {@link Date} to a {@link Calendar}.
+     * 
+     * @param dtime
+     *            a {@link Date}
+     * @return a {@link Calendar}
+     */
+    private Calendar toCalendar(Date dtime) {
+        if (dtime == null)
+            return null;
+
+        Calendar c = (Calendar) _calendar.clone();
+        c.setTime(dtime);
+        return c;
+    }
+}

Added: ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java?rev=584964&view=auto
==============================================================================
--- ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java
(added)
+++ ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java
Mon Oct 15 16:07:54 2007
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.extension.jmseventlistener;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+/**
+ * Basic Consumer that dumps Ode's BPEL events to the console.
+ *
+ * @author Tammo van Lessen (University of Stuttgart)
+ */
+public class TestConsumer implements MessageListener {
+	private Connection connection;
+	private Session session;	
+	private Topic topic;
+
+	public static void main(String[] argv) throws Exception {
+		TestConsumer c = new TestConsumer();
+    	c.run();
+	}
+
+	public void run() throws JMSException {
+		ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
+		connection = factory.createConnection();    	
+		session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+		topic = session.createTopic("org.apache.ode.events");
+
+		MessageConsumer consumer = session.createConsumer(topic);
+		consumer.setMessageListener(this);
+
+		connection.start();
+
+		System.out.println("Waiting for messages...");		
+	}
+
+	public void onMessage(Message msg) {
+		TextMessage t = (TextMessage)msg;
+		try {
+			System.err.println("--");
+			System.out.println(t.getText());
+		} catch (JMSException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+}



Mime
View raw message