Author: jeff.yuchang
Date: 2008-10-08 02:34:33 -0400 (Wed, 08 Oct 2008)
New Revision: 367
Added:
cdl/trunk/docs/docbook/samplesguide/
cdl/trunk/docs/docbook/samplesguide/pom.xml
cdl/trunk/docs/docbook/samplesguide/src/
cdl/trunk/docs/docbook/samplesguide/src/main/
cdl/trunk/docs/docbook/samplesguide/src/main/images/
cdl/trunk/docs/docbook/samplesguide/src/main/master.xml
cdl/trunk/docs/docbook/samplesguide/src/main/module/
cdl/trunk/docs/docbook/samplesguide/src/main/module/author_group.xml
cdl/trunk/docs/docbook/samplesguide/src/main/module/overview.xml
cdl/trunk/docs/docbook/samplesguide/src/main/module/template.xml
Modified:
cdl/trunk/docs/docbook/pom.xml
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionManager.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ActionProperties.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageRouterAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ParallelAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ReceiveMessageAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/RetrieveSessionAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ScheduleStateAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SendMessageAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetMessageAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SwitchAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java
cdl/trunk/samples/jbossesb/brokerage/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Request4QuoteMain.java
cdl/trunk/samples/jbossesb/brokerage/broker/src/main/resources/META-INF/jboss-esb.xml
Log:
* Refactor the 'parentReference' work, it works now.
* Add samples guide docbook module.
* Refactor the Action code, move the Action specific constants into Action class itself.
Modified: cdl/trunk/docs/docbook/pom.xml
===================================================================
--- cdl/trunk/docs/docbook/pom.xml 2008-10-07 13:22:59 UTC (rev 366)
+++ cdl/trunk/docs/docbook/pom.xml 2008-10-08 06:34:33 UTC (rev 367)
@@ -12,6 +12,7 @@
<modules>
<module>userguide</module>
+ <module>samplesguide</module>
</modules>
<repositories>
Added: cdl/trunk/docs/docbook/samplesguide/pom.xml
===================================================================
--- cdl/trunk/docs/docbook/samplesguide/pom.xml (rev 0)
+++ cdl/trunk/docs/docbook/samplesguide/pom.xml 2008-10-08 06:34:33 UTC (rev 367)
@@ -0,0 +1,87 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.soa.overlord.cdl.docs</groupId>
+ <artifactId>samplesguide</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jdocbook</packaging>
+ <name>Overlord::CDL::Docs::samplesguide</name>
+
+ <parent>
+ <groupId>org.jboss.soa.overlord.cdl</groupId>
+ <artifactId>docs</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.1.2</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-docbook</id>
+ <phase>package</phase>
+ <goals>
+ <goal>resources</goal>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+ <sourceDirectory>${basedir}/src/main</sourceDirectory>
+ <imageResource>
+ <directory>${basedir}/src/main</directory>
+ <includes>
+ <include>images/**/*</include>
+ </includes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+
<stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
+ <finalName>SamplesGuide.pdf</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+
<stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <docbookVersion>1.72.0</docbookVersion>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
Added: cdl/trunk/docs/docbook/samplesguide/src/main/master.xml
===================================================================
--- cdl/trunk/docs/docbook/samplesguide/src/main/master.xml (rev
0)
+++ cdl/trunk/docs/docbook/samplesguide/src/main/master.xml 2008-10-08 06:34:33 UTC (rev
367)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
+]>
+
+<book lang="en">
+ <bookinfo>
+ <title>JBoss Overlord CDL 1.0</title>
+ <subtitle>Samples Guide</subtitle>
+ <xi:include
xmlns:xi="http://www.w3.org/2001/XInclude"
href="module/author_group.xml"/>
+ </bookinfo>
+
+ <toc/>
+ <xi:include
xmlns:xi="http://www.w3.org/2001/XInclude"
href="module/overview.xml"/>
+
+</book>
Added: cdl/trunk/docs/docbook/samplesguide/src/main/module/author_group.xml
===================================================================
--- cdl/trunk/docs/docbook/samplesguide/src/main/module/author_group.xml
(rev 0)
+++ cdl/trunk/docs/docbook/samplesguide/src/main/module/author_group.xml 2008-10-08
06:34:33 UTC (rev 367)
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<authorgroup>
+ <corpauthor>Gary Brown</corpauthor>
+ <corpauthor>Jeff Yu</corpauthor>
+</authorgroup>
Added: cdl/trunk/docs/docbook/samplesguide/src/main/module/overview.xml
===================================================================
--- cdl/trunk/docs/docbook/samplesguide/src/main/module/overview.xml
(rev 0)
+++ cdl/trunk/docs/docbook/samplesguide/src/main/module/overview.xml 2008-10-08 06:34:33
UTC (rev 367)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="overview">
+ <title>Overview</title>
+ <para>The Overlord CDL distribution contains two main types of
functionality:</para>
+ <orderedlist>
+ <listitem>
+ the ability to validate executing services against a choreography description (an
example of runtime governance).
+ </listitem>
+ <listitem>
+ the ability to build an ESB using 'conversation aware' actions which can be
checked for conformance against a choreography description (an example of design time
governance).
+ </listitem>
+ </orderedlist>
+
+ <para>
+ This document will describe the samples available to demonstrate each aspect of the
functionality.
+ </para>
+ <para>
+ Further information about configuring the runtime validation of services against a
choreography can be found in the <emphasis
role="bold">UserGuide</emphasis>.
+ Information regarding the conversation aware ESB actions, and how to use them in
conjunction with conformance checking against a choreography description, can also be
found in the <emphasis role="bold">UserGuide</emphasis>.
+ </para>
+
+ <note>
+ <para>
+ Before attempting to install and run these examples, you must follow the instructions
in the <emphasis role="bold">"Getting Started"
Chapter</emphasis> of <emphasis role="bold">User
Guide</emphasis> regarding installing Overlord CDL into a JBossAS environment.
+ </para>
+ </note>
+
+</chapter>
Added: cdl/trunk/docs/docbook/samplesguide/src/main/module/template.xml
===================================================================
--- cdl/trunk/docs/docbook/samplesguide/src/main/module/template.xml
(rev 0)
+++ cdl/trunk/docs/docbook/samplesguide/src/main/module/template.xml 2008-10-08 06:34:33
UTC (rev 367)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="chapter-id">
+ <title>Chapter title</title>
+ <para>To be written...</para>
+</chapter>
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionManager.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionManager.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionManager.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -116,6 +116,7 @@
if (sessionKey != null) {
org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
Session session = (Session) hibernateSession.load(Session.class,
Long.valueOf(sessionKey));
+ injectParentReference(session);
return session;
}
@@ -189,10 +190,18 @@
}
Session session = theID.getSession();
+ injectParentReference(session);
+
logger.debug("Get Session of " + session + " by using identity of "
+ id);
return session;
}
-
+ private static void injectParentReference(Session session) {
+ String parentProperty = session.getProperties().get(Session.PARENT_REFERENCE_KEY);
+ if (parentProperty!= null && session.getParent() != null) {
+ Object parentBizObj = session.getParent().getBusinessObject();
+ MVEL.setProperty(session.getBusinessObject(), parentProperty, parentBizObj);
+ }
+ }
}
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ActionProperties.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ActionProperties.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ActionProperties.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -43,28 +43,9 @@
public static final String CLIENT_EPR = "clientEPR";
- public static final String CATEGORY = "category"; // request, response,
notification
-
public static final String SERVICE_NAME_PROPERTY = "serviceName";
public static final String SERVICE_CATEGORY_PROPERTY = "serviceCategory";
public static final String SERVICE_DESCRIPTION_NAME =
"serviceDescriptionName";
- public static final String PARENT_PROPERTY = "parentProperty";
-
- public static final String PARENT_REFERENCE_PROPERTY = "parentReference";
-
- public static final String RESPONSE_SERVICE_NAME = "responseServiceName";
- public static final String RESPONSE_SERVICE_CATEGORY =
"responseServiceCategory";
-
- public static final String RETURN_SERVICE_NAME = "returnServiceName";
- public static final String RETURN_SERVICE_CATEGORY = "returnServiceCategory";
-
- public static final String SERVICE_NAME_EXPRESSION = "serviceNameExpression";
- public static final String SERVICE_CATEGORY_EXPRESSION =
"serviceCategoryExpression";
-
- public static final String IMMEDIATE = "immediate";
-
public static final String IDENTITIES = "identities";
-
- public static final String INITIATE = "initiate" ;
}
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -41,9 +41,10 @@
import org.jboss.soa.overlord.jbossesb.util.HibernateUtil;
import org.jboss.soa.overlord.jbossesb.util.MessageUtil;
import org.jboss.soa.overlord.jbossesb.util.XMLUtils;
+import org.mvel.MVEL;
/**
- * Base activity, all the ESB aware actions extends from this one.
+ * Base activity, all the ESB aware actions extend from this one.
*
* @author <a href="mailto:gary.brown@hattricksoftware.com">Gary
Brown</a>
* @author <a href="mailto:cyu@redhat.com>Jeff Yu</a>
@@ -58,6 +59,8 @@
protected boolean unscheduledServiceItem = false;
+ protected Session session;
+
public ConversationAction(ConfigTree config) {
this.config = config;
}
@@ -118,7 +121,7 @@
Identity id = new Identity();
id.setType(IdentityType.toIdentityType(type));
id.setProperties(properties);
- id.setSession(getSession(message));
+ id.setSession(session);
if (serviceDescriptionName != null) {
id.setServiceName(serviceDescriptionName);
}
@@ -145,8 +148,7 @@
protected String getMessageType(Message message) throws Exception {
String mesgType=(String)message.getProperties().getProperty(
MessageProperties.MESSAGE_TYPE);
- // NOTE: Only deals with XML at present
-
+ // NOTE: Only deals with XML at present
if (mesgType == null) {
Object value=message.getBody().get();
@@ -160,7 +162,7 @@
return(mesgType);
}
- protected Session getSession(Message message) throws Exception {
+ private Session getSession(Message message) throws Exception {
return getSession(message, null);
}
@@ -170,7 +172,6 @@
if (ret == null) {
ret = SessionManager.retrieveSession(sessionKey, ids);
if (ret != null) {
- //message.getProperties().setProperty(MessageProperties.SESSION, ret);
message.getProperties().setProperty(MessageProperties.SESSION_KEY,
String.valueOf(ret.getId()));
} else {
logger.debug("Can not get session by using neither session key of [" +
sessionKey +"] nor" +
@@ -187,13 +188,11 @@
* @throws Exception
*/
public Message process(Message message) throws Exception {
- String
sessionKey=(String)message.getProperties().getProperty(MessageProperties.SESSION_KEY);
- logger.debug("Session Key is [" + sessionKey + "] Body is: [" +
message.getBody().get() + "]");
org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
Transaction transaction = hibernateSession.beginTransaction();
try {
- Session session = getSession(message);
+ session = getSession(message);
if (session != null && isFirstOrLastConversationAction(message, true)) {
logger.debug("This is first conversation action to unschedule the item.");
unschedule(message);
@@ -202,13 +201,15 @@
handle(message);
- session = getSession(message);
+ SessionManager.updateObject(session);
+ updateParentSessionBizObject();
+
if (session != null && isFirstOrLastConversationAction(message, false)) {
logger.debug("This is the last conversation action.");
if (session.getScheduleItems().size() <= 0) {
session.setStatus(SessionStatus.Completed);
SessionManager.updateObject(session);
- logger.info("Completed the session of " + session);
+ logger.debug("Completed the session of " + session);
if (session.getParent() != null) {
invokeSubsessionExitService(message, session);
}
@@ -227,6 +228,16 @@
return message;
}
+
+ private void updateParentSessionBizObject() {
+ String parentProperty = session.getProperties().get(Session.PARENT_REFERENCE_KEY);
+ if (parentProperty != null && session.getParent() != null) {
+ Object parentBizObj = MVEL.eval(parentProperty, session.getBusinessObject());
+ Session parentSession = session.getParent();
+ parentSession.setBusinessObject(parentBizObj);
+ SessionManager.updateObject(parentSession);
+ }
+ }
private void invokeSubsessionExitService(Message message, Session session)
@@ -293,7 +304,6 @@
protected void unschedule(Message message) throws Exception {
String
serviceCategory=getConfig().getParent().getAttribute(ActionProperties.SERVICE_CATEGORY);
String
serviceName=getConfig().getParent().getAttribute(ActionProperties.SERVICE_NAME);
- Session session = getSession(message);
session.unschedule(serviceCategory, serviceName);
}
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -22,7 +22,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
@@ -34,6 +33,9 @@
*/
public class IfAction extends ConversationAction {
+ public static final String IF_STATEMENT = "if";
+ public static final String ELSE_STATEMENT = "else";
+
private static Logger logger = Logger.getLogger(IfAction.class);
public IfAction(ConfigTree config) {
@@ -41,7 +43,6 @@
}
public Message handle(Message message) throws Exception{
- Session session=getSession(message);
ConfigTree ifConfig = null;
ConfigTree elseConfig = null;
@@ -49,9 +50,9 @@
ConfigTree[] children=getConfig().getAllChildren();
for (ConfigTree ct : children) {
- if ("if".equals(ct.getName())) {
+ if (IF_STATEMENT.equals(ct.getName())) {
ifConfig = ct;
- } else if ("else".equals(ct.getName())){
+ } else if (ELSE_STATEMENT.equals(ct.getName())){
elseConfig = ct;
} else {
throw new Exception("Unrecognized configuration Node in IfAction.");
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageRouterAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageRouterAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageRouterAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -28,7 +28,6 @@
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.overlord.jbossesb.Identity;
import org.jboss.soa.overlord.jbossesb.ScheduleItem;
-import org.jboss.soa.overlord.jbossesb.Session;
/**
* Route message to different services according to the 'MessageType'.
@@ -37,6 +36,8 @@
*/
public class MessageRouterAction extends ConversationAction {
+ public static final String INITIATE = "initiate" ;
+
private static Logger logger = Logger.getLogger(MessageRouterAction.class);
public MessageRouterAction(ConfigTree config) {
@@ -64,10 +65,10 @@
if (routerFlag == false && (selectedMsgConfig != null)) {
List<Identity> ids = getIdentities(message, svcDesc, selectedMsgConfig);
- Session session = getSession(message, ids);
+ session = getSession(message, ids);
String serviceCategory = ct.getAttribute(ActionProperties.SERVICE_CATEGORY);
String serviceName = ct.getAttribute(ActionProperties.SERVICE_NAME);
- String initiate = ct.getAttribute(ActionProperties.INITIATE);
+ String initiate = ct.getAttribute(INITIATE);
if ("true".equals(initiate) && session == null) {
logger.info("This is an initiate process of " + serviceCategory +
"/" + serviceName);
routerFlag = true;
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ParallelAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ParallelAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ParallelAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -22,7 +22,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.jbossesb.Session;
/**
* This action represents a parallel construct.
@@ -32,6 +31,9 @@
*/
public class ParallelAction extends ConversationAction {
+ public static final String PATH_BRANCH = "path";
+ public static final String JOIN_BRANCH = "join";
+
private static Logger logger = Logger.getLogger(ParallelAction.class);
public ParallelAction(ConfigTree config) {
@@ -39,7 +41,7 @@
}
public Message handle(Message message) throws Exception{
- Session session=getSession(message);
+
int pathCount=0;
String joinCategory=null;
String joinName=null;
@@ -47,9 +49,9 @@
ConfigTree[] children=getConfig().getAllChildren();
for (int i=0; i < children.length; i++) {
- if (children[i].getName().equals("path")) {
+ if (PATH_BRANCH.equals(children[i].getName())) {
pathCount++;
- } else if (children[i].getName().equals("join")) {
+ } else if (JOIN_BRANCH.equals(children[i].getName())) {
// Check if join already defined
if (joinName != null) {
@@ -74,8 +76,7 @@
// Schedule the paths
for (int i=0; i < children.length; i++) {
-
- if (children[i].getName().equals("path")) {
+ if (PATH_BRANCH.equals(children[i].getName())) {
String category=children[i].getAttribute("service-category");
String name=children[i].getAttribute("service-name");
String immediate=children[i].getAttribute("immediate","false");
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -35,6 +35,12 @@
*/
public class PerformAction extends ConversationAction {
+ public static final String RETURN_SERVICE_CATEGORY = "returnServiceCategory";
+ public static final String RETURN_SERVICE_NAME = "returnServiceName";
+ public static final String PARENT_REFERENCE_PROPERTY = "parentReference";
+ public static final String FROM_EXPRESSION = "from-expression";
+ public static final String TO_VARIABLE = "to-variable";
+
private Logger logger = Logger.getLogger(PerformAction.class);
public PerformAction(ConfigTree config) {
@@ -46,7 +52,6 @@
public Message handle(Message message) throws Exception {
String serviceCategory =
getConfig().getAttribute(ActionProperties.SERVICE_CATEGORY_PROPERTY);
String serviceName = getConfig().getAttribute(ActionProperties.SERVICE_NAME_PROPERTY);
- Session session = getSession(message);
ConfigTree[] configs = getConfig().getAllChildren();
@@ -54,8 +59,8 @@
for(ConfigTree ct : configs) {
if ("bind".equals(ct.getName())) {
- String fromExpression = ct.getAttribute("from-expression");
- String toVariable = ct.getAttribute("to-variable");
+ String fromExpression = ct.getAttribute(FROM_EXPRESSION);
+ String toVariable = ct.getAttribute(TO_VARIABLE);
Object o = MVEL.eval(fromExpression, session.getBusinessObject());
bindingVal.put(toVariable, o);
@@ -64,7 +69,7 @@
}
message.getProperties().setProperty(MessageProperties.BOUND_VARIABLE_KEY, bindingVal);
- String parentProperty =
getConfig().getAttribute(ActionProperties.PARENT_REFERENCE_PROPERTY);
+ String parentProperty = getConfig().getAttribute(PARENT_REFERENCE_PROPERTY);
if (parentProperty != null) {
Map<String, String> properties = new HashMap<String, String>();
properties.put(Session.PARENT_REFERENCE_KEY, parentProperty);
@@ -74,8 +79,8 @@
session.schedule(serviceCategory, serviceName, message);
addScheduleItemToDeliver(serviceCategory, serviceName);
- String returnServiceCategory =
getConfig().getAttribute(ActionProperties.RETURN_SERVICE_CATEGORY);
- String returnServiceName =
getConfig().getAttribute(ActionProperties.RETURN_SERVICE_NAME);
+ String returnServiceCategory = getConfig().getAttribute(RETURN_SERVICE_CATEGORY);
+ String returnServiceName = getConfig().getAttribute(RETURN_SERVICE_NAME);
if (returnServiceCategory != null && returnServiceName != null) {
session.schedule(returnServiceCategory, returnServiceName, message);
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ReceiveMessageAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ReceiveMessageAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ReceiveMessageAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -24,7 +24,6 @@
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.overlord.jbossesb.Identity;
-import org.jboss.soa.overlord.jbossesb.Session;
/**
* Receive activity.
@@ -55,7 +54,7 @@
if (requiredMType.equals(mesgMType)) {
java.util.List<Identity> ids=getIdentities(message, serviceName);
- Session session=getSession(message, ids);
+ session=getSession(message, ids);
session.assimulateIdentities(ids);
logger.info("MESSAGE TYPE ["+mesgMType+"] RECEIVED.");
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/RetrieveSessionAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/RetrieveSessionAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/RetrieveSessionAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -25,7 +25,6 @@
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.overlord.jbossesb.Identity;
-import org.jboss.soa.overlord.jbossesb.Session;
/**
* This action gets an existed session.
@@ -45,7 +44,7 @@
String serviceDescriptionName =
getConfig().getAttribute(ActionProperties.SERVICE_DESCRIPTION_NAME);
List<Identity> ids = getIdentities(message, serviceDescriptionName);
- Session session= getSession(message, ids);
+ session= getSession(message, ids);
String
serviceName=getConfig().getParent().getAttribute(ActionProperties.SERVICE_NAME);
String
serviceCategory=getConfig().getParent().getAttribute(ActionProperties.SERVICE_CATEGORY);
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ScheduleStateAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ScheduleStateAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ScheduleStateAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -22,7 +22,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.jbossesb.Session;
/**
* Schedule state activity.
@@ -32,6 +31,8 @@
*/
public class ScheduleStateAction extends ConversationAction {
+ public static final String IMMEDIATE = "immediate";
+
private static Logger logger = Logger.getLogger(ScheduleStateAction.class);
public ScheduleStateAction(ConfigTree config) {
@@ -41,9 +42,8 @@
public Message handle(Message message) throws Exception {
String serviceName=getConfig().getAttribute(ActionProperties.SERVICE_NAME_PROPERTY);
String
serviceCategory=getConfig().getAttribute(ActionProperties.SERVICE_CATEGORY_PROPERTY);
- String immediate=getConfig().getAttribute(ActionProperties.IMMEDIATE);
-
- Session session=getSession(message);
+ String immediate=getConfig().getAttribute(IMMEDIATE);
+
session.schedule(serviceCategory, serviceName, message);
if ("true".equalsIgnoreCase(immediate)) {
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SendMessageAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SendMessageAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SendMessageAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -33,7 +33,6 @@
import org.jboss.soa.esb.message.format.MessageType;
import org.jboss.soa.overlord.jbossesb.Identity;
import org.jboss.soa.overlord.jbossesb.LogicalCourier;
-import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
@@ -45,8 +44,14 @@
*/
public class SendMessageAction extends ConversationAction {
+ public static final String RESPONSE_SERVICE_CATEGORY =
"responseServiceCategory";
+ public static final String RESPONSE_SERVICE_NAME = "responseServiceName";
+ public static final String SERVICE_NAME_EXPRESSION = "serviceNameExpression";
+ public static final String SERVICE_CATEGORY_EXPRESSION =
"serviceCategoryExpression";
+
private Logger logger = Logger.getLogger(SendMessageAction.class);
+
public SendMessageAction(ConfigTree config) {
super(config);
}
@@ -64,13 +69,11 @@
if (requiredMType.equals(mesgMType)) {
String serviceName=getConfig().getAttribute(ActionProperties.SERVICE_NAME_PROPERTY);
String
serviceCategory=getConfig().getAttribute(ActionProperties.SERVICE_CATEGORY_PROPERTY);
- String
respServiceName=getConfig().getAttribute(ActionProperties.RESPONSE_SERVICE_NAME);
- String
respServiceCategory=getConfig().getAttribute(ActionProperties.RESPONSE_SERVICE_CATEGORY);
+ String respServiceName=getConfig().getAttribute(RESPONSE_SERVICE_NAME);
+ String respServiceCategory=getConfig().getAttribute(RESPONSE_SERVICE_CATEGORY);
String clientEPR=getConfig().getAttribute(ActionProperties.CLIENT_EPR);
- String nameExpression =
getConfig().getAttribute(ActionProperties.SERVICE_NAME_EXPRESSION);
- String categoryExpression =
getConfig().getAttribute(ActionProperties.SERVICE_CATEGORY_EXPRESSION);
-
- Session session=getSession(message);
+ String nameExpression = getConfig().getAttribute(SERVICE_NAME_EXPRESSION);
+ String categoryExpression =
getConfig().getAttribute(SendMessageAction.SERVICE_CATEGORY_EXPRESSION);
List<Identity> ids=getIdentities(message, null);
session.assimulateIdentities(ids);
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetMessageAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetMessageAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetMessageAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -22,7 +22,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
@@ -33,6 +32,10 @@
*/
public class SetMessageAction extends ConversationAction {
+ public static final String STATE_EXPRESSION = "stateExpression";
+
+ public static final String HEADER_PROPERTY = "headerProperty";
+
private Logger logger = Logger.getLogger(SetMessageAction.class);
public SetMessageAction(ConfigTree config) {
@@ -42,13 +45,13 @@
@Override
public Message handle(Message message) throws Exception {
- String expression = getConfig().getAttribute("stateExpression");
- String headerProperty = getConfig().getAttribute("headerProperty");
- Session session = getSession(message);
+ String expression = getConfig().getAttribute(STATE_EXPRESSION);
+ String headerProperty = getConfig().getAttribute(HEADER_PROPERTY);
+
Object obj = MVEL.eval(expression, session.getBusinessObject());
if (headerProperty != null) {
message.getProperties().setProperty(headerProperty, obj);
- logger.info("Set object of " + obj + " to header property of " +
headerProperty);
+ logger.info("Set object of " + obj + " to header property: " +
headerProperty);
}
return message;
}
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -22,8 +22,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.jbossesb.Session;
-import org.jboss.soa.overlord.jbossesb.SessionManager;
import org.jboss.soa.overlord.jbossesb.util.XMLUtils;
import org.mvel.MVEL;
import org.w3c.dom.Element;
@@ -34,6 +32,9 @@
*/
public class SetStateAction extends ConversationAction {
+ public static final String STATE_EXPRESSION = "stateExpression";
+ public static final String MESSAGE_EXPRESSION = "messageExpression";
+
private Logger logger = Logger.getLogger(SetStateAction.class);
public SetStateAction(ConfigTree config) {
@@ -44,30 +45,14 @@
@Override
public Message handle(Message message) throws Exception {
String variable = getConfig().getAttribute("variable");
- String stateExpression = getConfig().getAttribute("stateExpression");
- String messageExpression = getConfig().getAttribute("messageExpression");
+ String stateExpression = getConfig().getAttribute(STATE_EXPRESSION);
+ String messageExpression = getConfig().getAttribute(MESSAGE_EXPRESSION);
if (variable == null) {
throw new NullPointerException("variable can not be null");
}
- boolean need2UpdateParentState = false;
-
- Session session = getSession(message);
- Object bstate = session.getBusinessObject();
-
- if (session.getParent() != null) {
- Session parentSession = session.getParent();
- String parentReference = session.getProperties().get(Session.PARENT_REFERENCE_KEY);
- logger.debug("parentReference is : " + parentReference);
- if (parentReference != null) {
- Object parentState = parentSession.getBusinessObject();
- MVEL.setProperty(bstate, parentReference, parentState);
- need2UpdateParentState = true;
- }
- }
-
-
+ Object bstate = session.getBusinessObject();
if (stateExpression != null) {
Object result = MVEL.eval(stateExpression, bstate);
MVEL.setProperty(bstate, variable, result);
@@ -79,21 +64,10 @@
MVEL.setProperty(bstate, variable, result);
logger.info("populated from messageExpression of: " + messageExpression);
} else {
- MVEL.eval(variable, bstate);
+ throw new Exception ("Neither stateExpression nor messageExpression has been
specified.");
}
- if (need2UpdateParentState) {
- Session parentSession = session.getParent();
- String parentReference = session.getProperties().get(Session.PARENT_REFERENCE_KEY);
- Object updatedObject = MVEL.eval(parentReference, bstate);
- parentSession.setBusinessObject(updatedObject);
- SessionManager.updateObject(parentSession);
- logger.info("populated to parentProperty of: " + parentReference);
- }
- session.setBusinessObject(bstate);
- SessionManager.updateObject(session);
-
return message;
}
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SwitchAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SwitchAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SwitchAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -22,7 +22,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.jbossesb.Session;
/**
* This action represents a choice between a set of specified paths
@@ -33,6 +32,8 @@
*/
public class SwitchAction extends ConversationAction {
+ public static final String CASE_STATEMENT = "case";
+
private static Logger logger = Logger.getLogger(SwitchAction.class);
public SwitchAction(ConfigTree config) {
@@ -40,7 +41,6 @@
}
public Message handle(Message message) throws Exception{
- Session session=getSession(message);
// Get the message type
String mesgMType=getMessageType(message);
@@ -52,7 +52,7 @@
for (int i=0; i < children.length; i++) {
- if (children[i].getName().equals("case")) {
+ if (children[i].getName().equals(CASE_STATEMENT)) {
String category=children[i].getAttribute("service-category");
String name=children[i].getAttribute("service-name");
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -22,7 +22,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
@@ -32,6 +31,9 @@
*/
public class WhenAction extends ConversationAction {
+ public static final String EXPRESSION = "expression";
+ public static final String WHEN_STATEMENT = "when";
+
private static Logger logger = Logger.getLogger(WhenAction.class);
public WhenAction(ConfigTree config) {
@@ -42,12 +44,10 @@
@Override
public Message handle(Message message) throws Exception {
- Session session = getSession(message);
-
for(ConfigTree ct : getConfig().getAllChildren()) {
- if ("when".equals(ct.getName())) {
+ if (WHEN_STATEMENT.equals(ct.getName())) {
//TODO: make the expression as an method name temporarily
- String decision = ct.getAttribute("expression");
+ String decision = ct.getAttribute(EXPRESSION);
String category = ct.getAttribute(ActionProperties.SERVICE_CATEGORY);
String name = ct.getAttribute(ActionProperties.SERVICE_NAME);
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -22,16 +22,18 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
*
- *
* @author <a href="mailto:cyu@redhat.com>Jeff Yu</a>
*/
public class WhileAction extends ConversationAction {
+ public static final String WHILE_BRANCH = "while";
+ public static final String EXIT_BRANCH = "exit";
+ public static final String DECISION_METHOD = "decision-method";
+
private Logger logger = Logger.getLogger(WhileAction.class);
public WhileAction(ConfigTree config) {
@@ -40,15 +42,15 @@
@Override
public Message handle(Message message) throws Exception {
- Session session = getSession(message);
+
ConfigTree whileConfig = null;
ConfigTree exitConfig = null;
ConfigTree[] configTrees = getConfig().getAllChildren();
for (ConfigTree ct : configTrees) {
- if ("while".equals(ct.getName())) {
+ if (WHILE_BRANCH.equals(ct.getName())) {
whileConfig = ct;
- } else if ("exit".equals(ct.getName())){
+ } else if (EXIT_BRANCH.equals(ct.getName())){
exitConfig = ct;
} else {
throw new Exception("Unrecognized configuration Node in WhileAction");
@@ -56,7 +58,7 @@
}
//TODO: Need to think about the expression.
- String decisionMethod = whileConfig.getAttribute("decision-method");
+ String decisionMethod = whileConfig.getAttribute(DECISION_METHOD);
logger.debug("decision method is : " + decisionMethod);
if (decisionMethod != null) {
Object response = MVEL.eval(getMvelMethodName(decisionMethod),
session.getBusinessObject());
Modified:
cdl/trunk/samples/jbossesb/brokerage/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Request4QuoteMain.java
===================================================================
---
cdl/trunk/samples/jbossesb/brokerage/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Request4QuoteMain.java 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/samples/jbossesb/brokerage/broker/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/Request4QuoteMain.java 2008-10-08
06:34:33 UTC (rev 367)
@@ -49,11 +49,9 @@
public void setQuote(Quote quote) {
this.quote = quote;
+ quoteManager.getQuotes().add(this.quote);
}
- public void addToQuoteManager() {
- quoteManager.getQuotes().add(quote);
- }
public QuoteManager getQuoteManager() {
return quoteManager;
Modified:
cdl/trunk/samples/jbossesb/brokerage/broker/src/main/resources/META-INF/jboss-esb.xml
===================================================================
---
cdl/trunk/samples/jbossesb/brokerage/broker/src/main/resources/META-INF/jboss-esb.xml 2008-10-07
13:22:59 UTC (rev 366)
+++
cdl/trunk/samples/jbossesb/brokerage/broker/src/main/resources/META-INF/jboss-esb.xml 2008-10-08
06:34:33 UTC (rev 367)
@@ -435,11 +435,7 @@
process="process" name="s9-3">
<property name="variable" value="quote.value" />
<property name="messageExpression" value="/quote" />
- </action>
- <action class="org.jboss.soa.overlord.jbossesb.actions.SetStateAction"
- process="process" name="s9-4">
- <property name="variable" value="addToQuoteManager()" />
- </action>
+ </action>
</actions>
</service>