Overlord SVN: r225 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-07 13:15:54 -0400 (Thu, 07 Aug 2008)
New Revision: 225
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java
Log:
Support for async perform.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-08-07 15:10:02 UTC (rev 224)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-08-07 17:15:54 UTC (rev 225)
@@ -158,7 +158,15 @@
public void convert(java.util.List<Activity> activities,
ConversionContext context) {
- Run elem=new Run();
+ Compose elem=null;
+
+ // Check if perform is asynchronous
+ if (getAction().hasAttribute(RETURN_SERVICE_NAME)) {
+ elem = new Run();
+ } else {
+ elem = new Spawn();
+ }
+
activities.add(elem);
elem.derivedFrom(this);
15 years, 9 months
Overlord SVN: r224 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: java/org/jboss/tools/overlord/jbossesb/model and 3 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-07 11:10:02 -0400 (Thu, 07 Aug 2008)
New Revision: 224
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/DefaultESBServiceTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBService.java
Log:
Fixed various issues related to the conversation type and service description name. Now does conformance checking between model and generated ESB configuration.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java 2008-08-07 11:31:06 UTC (rev 223)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java 2008-08-07 15:10:02 UTC (rev 224)
@@ -405,23 +405,6 @@
final IJavaProject jproj=createJavaProject(projectName);
if (jproj != null && esbConfig != null) {
- // Store ESB configuration
- IPath esbConfigPath=jproj.getPath().append(
- new Path(getSelectedBuildSystem().getESBConfigFilePath()));
-
- IFile esbConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(esbConfigPath);
- createParentFolder(esbConfigFile);
- esbConfigFile.create(null, true,
- new org.eclipse.core.runtime.NullProgressMonitor());
-
- String config=getText(esbConfig);
-
- if (config != null) {
- esbConfigFile.setContents(new java.io.ByteArrayInputStream(
- config.getBytes()), true, false,
- new org.eclipse.core.runtime.NullProgressMonitor());
- }
-
// Generate business object types for
// local conversation model
localcm.visit(new Visitor() {
@@ -442,6 +425,23 @@
}
});
+ // Store ESB configuration
+ IPath esbConfigPath=jproj.getPath().append(
+ new Path(getSelectedBuildSystem().getESBConfigFilePath()));
+
+ IFile esbConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(esbConfigPath);
+ createParentFolder(esbConfigFile);
+ esbConfigFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ String config=getText(esbConfig);
+
+ if (config != null) {
+ esbConfigFile.setContents(new java.io.ByteArrayInputStream(
+ config.getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
generateBuildConfigurationFile(jproj);
generateDeploymentFile(jproj, model);
@@ -729,8 +729,7 @@
method=ast.newMethodDeclaration();
method.setName(ast.newSimpleName(methodName));
- method.setReturnType2(ast.newSimpleType(
- ast.newName("void")));
+ method.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
SingleVariableDeclaration svd=ast.newSingleVariableDeclaration();
svd.setName(ast.newSimpleName("value"));
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java 2008-08-07 11:31:06 UTC (rev 223)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java 2008-08-07 15:10:02 UTC (rev 224)
@@ -45,7 +45,7 @@
public static final String ROOT_PROPERTY = "root";
public static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
public static final String CONVERSATION_TYPE_PROPERTY = "conversationType";
- public static final String SERVICE_NAME_PROPERTY = "serviceName";
+ public static final String SERVICE_DESCRIPTION_NAME_PROPERTY = "serviceDescriptionName";
public static final String SERVICE_ANNOTATION = "org.jboss.soa.overlord.jbossesb.actions.Service";
public static final String SERVICE_ELEMENT = "service";
public static final String RETRIEVE_SESSION_ACTION_CLASS = "org.jboss.soa.overlord.jbossesb.actions.RetrieveSessionAction";
@@ -476,14 +476,14 @@
*
* @return The service description name
*/
- public String getServiceName() {
+ public String getServiceDescriptionName() {
String ret=null;
ESBAction action=getFirstSessionBasedAction();
if (action != null) {
if (action.isCreateSession() || (action.getActionClass() != null &&
action.getActionClass().equals(RETRIEVE_SESSION_ACTION_CLASS))) {
- ret = action.getPropertyValue(SERVICE_NAME_PROPERTY);
+ ret = action.getPropertyValue(SERVICE_DESCRIPTION_NAME_PROPERTY);
if (ret == null) {
String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
@@ -632,7 +632,7 @@
ret.derivedFrom(this);
ModelName modelName=new ModelName();
- modelName.setName(getServiceName());
+ modelName.setName(getServiceDescriptionName());
ret.setModelName(modelName);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java 2008-08-07 11:31:06 UTC (rev 223)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java 2008-08-07 15:10:02 UTC (rev 224)
@@ -139,7 +139,7 @@
*
* @return The service description name
*/
- public String getServiceName();
+ public String getServiceDescriptionName();
/**
* This method returns the conversation type associated with the
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java 2008-08-07 11:31:06 UTC (rev 223)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java 2008-08-07 15:10:02 UTC (rev 224)
@@ -30,17 +30,13 @@
public abstract class AbstractESBAction extends ModelObject
implements ESBAction {
- public static final String SERVICE_DESCRIPTION_NAME = "serviceDescriptionName";
public static final String IDENTITIES = "identities";
- public static final String SESSION = "session";
public static final String ACTION_ELEMENT = "action";
public static final String VALUE_ATTR = "value";
public static final String NAME_ATTR = "name";
public static final String PROPERTY_ELEMENT = "property";
public static final String CLASS_PROPERTY = "class";
- protected static final String BUSINESS_OBJECT_TYPE_PROPERTY = SESSION;
-
/**
* The constructor for initializing the action based on
* an existing DOM element.
@@ -189,7 +185,7 @@
}
}
- String session=getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+ String session=getPropertyValue(DefaultESBService.BUSINESS_OBJECT_TYPE_PROPERTY);
if (session != null) {
// Validate that the business object type exists
@@ -309,9 +305,9 @@
*/
protected java.util.List<String> getOptionalProperties() {
java.util.List<String> ret=new java.util.Vector<String>();
- ret.add(SESSION);
+ ret.add(DefaultESBService.BUSINESS_OBJECT_TYPE_PROPERTY);
ret.add(IDENTITIES);
- ret.add(SERVICE_DESCRIPTION_NAME);
+ ret.add(DefaultESBService.SERVICE_DESCRIPTION_NAME_PROPERTY);
return(ret);
}
@@ -456,7 +452,8 @@
*/
public void setServiceDescriptionName(String name) {
- org.w3c.dom.Element prop=getPropertyElement(SERVICE_DESCRIPTION_NAME);
+ org.w3c.dom.Element prop=getPropertyElement(
+ DefaultESBService.SERVICE_DESCRIPTION_NAME_PROPERTY);
if (prop != null) {
prop.setAttribute(VALUE_ATTR, name);
@@ -470,7 +467,8 @@
*/
public void setBusinessObjectType(String type) {
- org.w3c.dom.Element prop=getPropertyElement(BUSINESS_OBJECT_TYPE_PROPERTY);
+ org.w3c.dom.Element prop=getPropertyElement(
+ DefaultESBService.BUSINESS_OBJECT_TYPE_PROPERTY);
if (prop != null) {
prop.setAttribute(VALUE_ATTR, type);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java 2008-08-07 11:31:06 UTC (rev 223)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java 2008-08-07 15:10:02 UTC (rev 224)
@@ -125,11 +125,28 @@
if (conv.getParent() instanceof Model) {
csa.setRoot(true);
- // Set conversation type
- String ctype=namespace+"."+
- conv.getModelName().getName()+"@"+
- conv.getModelName().getLocatedRole().getName();
- csa.setConversationType(ctype);
+ String ctype=null;
+
+ // Check if conversation has a 'conforms to' reference
+ if (conv.getConformsTo().size() > 0) {
+ // Set conversation type based on first 'conforms to'
+ // reference
+ ConformanceReference cref=conv.getConformsTo().get(0);
+
+ ctype = cref.getNamespace()+"."+
+ cref.getLocalpart()+"@"+
+ cref.getLocatedRole();
+ } else {
+ // Set conversation type based on conversation
+ // namespace and name
+ ctype = namespace+"."+
+ conv.getModelName().getName()+"@"+
+ conv.getModelName().getLocatedRole().getName();
+ }
+
+ if (ctype != null) {
+ csa.setConversationType(ctype);
+ }
}
csa.setServiceDescriptionName(sdname);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/DefaultESBServiceTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/DefaultESBServiceTest.java 2008-08-07 11:31:06 UTC (rev 223)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/DefaultESBServiceTest.java 2008-08-07 15:10:02 UTC (rev 224)
@@ -171,13 +171,13 @@
TestESBAction act1=new TestESBAction();
act1.setSessionBased(true);
act1.setCreateSession(true);
- act1.setPropertyValue(DefaultESBService.SERVICE_NAME_PROPERTY,
+ act1.setPropertyValue(DefaultESBService.SERVICE_DESCRIPTION_NAME_PROPERTY,
name);
service.getActions().add(act1);
- if (service.getServiceName().equals(name) == false) {
- fail("Service name '"+service.getServiceName()+
+ if (service.getServiceDescriptionName().equals(name) == false) {
+ fail("Service name '"+service.getServiceDescriptionName()+
"' invalid, expecting: "+name);
}
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBService.java 2008-08-07 11:31:06 UTC (rev 223)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBService.java 2008-08-07 15:10:02 UTC (rev 224)
@@ -95,7 +95,7 @@
return null;
}
- public String getServiceName() {
+ public String getServiceDescriptionName() {
// TODO Auto-generated method stub
return null;
}
15 years, 9 months
Overlord SVN: r223 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: java/org/jboss/tools/overlord/jbossesb/model and 1 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-07 07:31:06 -0400 (Thu, 07 Aug 2008)
New Revision: 223
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBLanguageModel.java
Log:
Support for Ant and Maven build systems, and now generating the deployment.xml and jbmq-queue-service.xml.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java 2008-08-07 11:31:06 UTC (rev 223)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.dialogs;
+
+/**
+ * This class represents the Ant build system.
+ */
+public class AntBuildSystem implements BuildSystem {
+
+ private static final String BUILD_FILE = "build.xml";
+ private static final String ANT = "Ant";
+ private static final String ESB_CONFIG_PATH = "src/conf/jboss-esb.xml";
+ private static final String DEPLOYMENT_PATH = "src/conf/deployment.xml";
+ private static final String JBMQ_CONFIG_PATH = "src/conf/jbmq-queue-service.xml";
+ private static final String JAVA_SOURCE_PATH = "src/java";
+
+ /**
+ * This method represents the name of the build
+ * system.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(ANT);
+ }
+
+ /**
+ * This method returns the build configuration file
+ * path.
+ *
+ * @return The build configuration file path
+ */
+ public String getBuildFilePath() {
+ return(BUILD_FILE);
+ }
+
+ /**
+ * This method returns the contents for the build
+ * configuration file.
+ *
+ * @param projectName The project name
+ * @return The build file contents
+ */
+ public String getBuildFileContents(String projectName) {
+ StringBuffer ret=new StringBuffer();
+
+ ret.append("<project name=\""+projectName+
+ "\" default=\"startdb\" basedir=\".\">\r\n");
+
+ ret.append("</project>\r\n");
+
+ return(ret.toString());
+ }
+
+ /**
+ * This method returns the ESB configuration file
+ * path.
+ *
+ * @return The ESB configuration file path
+ */
+ public String getESBConfigFilePath() {
+ return(ESB_CONFIG_PATH);
+ }
+
+ /**
+ * This method returns the deployment file
+ * path.
+ *
+ * @return The deployment file path
+ */
+ public String getDeploymentFilePath() {
+ return(DEPLOYMENT_PATH);
+ }
+
+ /**
+ * This method returns the JBMQ configuration file
+ * path.
+ *
+ * @return The JBMQ configuration file path
+ */
+ public String getJBMQConfigFilePath() {
+ return(JBMQ_CONFIG_PATH);
+ }
+
+ /**
+ * This method returns the Java source path.
+ *
+ * @return The Java source path
+ */
+ public String getJavaSourcePath() {
+ return(JAVA_SOURCE_PATH);
+ }
+
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java 2008-08-07 11:31:06 UTC (rev 223)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.dialogs;
+
+/**
+ * This interface represents a build system used when
+ * generating the ESB projects.
+ */
+public interface BuildSystem {
+
+ /**
+ * This method represents the name of the build
+ * system.
+ *
+ * @return The name
+ */
+ public String getName();
+
+ /**
+ * This method returns the build configuration file
+ * path.
+ *
+ * @return The build configuration file path
+ */
+ public String getBuildFilePath();
+
+ /**
+ * This method returns the contents for the build
+ * configuration file.
+ *
+ * @param projectName The project name
+ * @return The build file contents
+ */
+ public String getBuildFileContents(String projectName);
+
+ /**
+ * This method returns the ESB configuration file
+ * path.
+ *
+ * @return The ESB configuration file path
+ */
+ public String getESBConfigFilePath();
+
+ /**
+ * This method returns the deployment file
+ * path.
+ *
+ * @return The deployment file path
+ */
+ public String getDeploymentFilePath();
+
+ /**
+ * This method returns the JBMQ configuration file
+ * path.
+ *
+ * @return The JBMQ configuration file path
+ */
+ public String getJBMQConfigFilePath();
+
+ /**
+ * This method returns the Java source path.
+ *
+ * @return The Java source path
+ */
+ public String getJavaSourcePath();
+
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java 2008-08-07 03:33:23 UTC (rev 222)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java 2008-08-07 11:31:06 UTC (rev 223)
@@ -32,8 +32,7 @@
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
-import org.jboss.tools.overlord.jbossesb.model.DefaultESBLanguageModel;
-import org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.jboss.tools.overlord.jbossesb.model.util.ConversationUtil;
import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
import org.scribble.conversation.model.ConversationModel;
@@ -54,8 +53,6 @@
*/
public class GenerateDialog extends org.eclipse.jface.dialogs.Dialog {
- private static final String ESB_CONFIG_PATH = "src/conf/jboss-esb.xml";
- private static final String JAVA_SOURCE_LOCATION = "src/java";
private static final String CLASSPATH_FILENAME = ".classpath";
private static final String OUTPUT_LOCATION = "classes";
@@ -69,6 +66,9 @@
m_file = file;
+ m_buildSystems.add(new AntBuildSystem());
+ m_buildSystems.add(new MavenBuildSystem());
+
initialize(m_file);
}
@@ -131,7 +131,7 @@
group.setLayoutData(gd);
layout = new GridLayout();
- layout.numColumns = 2;
+ layout.numColumns = 4;
group.setLayout(layout);
// Labels
@@ -139,7 +139,7 @@
label.setText("Service Role");
gd = new GridData();
- gd.horizontalSpan = 1;
+ gd.horizontalSpan = 2;
gd.widthHint = 150;
label.setLayoutData(gd);
@@ -147,7 +147,7 @@
label.setText("Project Name");
gd = new GridData();
- gd.horizontalSpan = 1;
+ gd.horizontalSpan = 2;
gd.widthHint = 150;
label.setLayoutData(gd);
@@ -160,7 +160,7 @@
button.setSelection(true);
gd = new GridData();
- gd.horizontalSpan = 1;
+ gd.horizontalSpan = 2;
gd.widthHint = 150;
button.setLayoutData(gd);
@@ -180,7 +180,7 @@
projectName.setText(m_roles.get(i).getName());
gd = new GridData();
- gd.horizontalSpan = 1;
+ gd.horizontalSpan = 2;
gd.widthHint = 300;
projectName.setLayoutData(gd);
@@ -200,7 +200,7 @@
gd = new GridData();
gd.horizontalSpan = 1;
- gd.widthHint = 150;
+ gd.widthHint = 100;
button.setLayoutData(gd);
button.addSelectionListener(new SelectionListener() {
@@ -222,7 +222,7 @@
gd = new GridData();
gd.horizontalSpan = 1;
- gd.widthHint = 150;
+ gd.widthHint = 100;
button.setLayoutData(gd);
button.addSelectionListener(new SelectionListener() {
@@ -239,6 +239,27 @@
}
});
+ label = new Label(group, SWT.RIGHT);
+ label.setText("Build: ");
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 100;
+ label.setLayoutData(gd);
+
+ m_build=new Combo(group, SWT.DROP_DOWN);
+
+ for (int i=0; i < m_buildSystems.size(); i++) {
+ m_build.add(m_buildSystems.get(i).getName());
+ }
+
+ m_build.select(0);
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 100;
+ m_build.setLayoutData(gd);
+
return(composite);
}
@@ -326,6 +347,10 @@
error("Failed to generate ESB artefacts", e);
}
}
+
+ protected BuildSystem getSelectedBuildSystem() {
+ return(m_buildSystems.get(m_build.getSelectionIndex()));
+ }
protected void generateRole(Role role, String projectName)
throws Exception {
@@ -365,7 +390,7 @@
generateRoleProject(projectName,
target.getESBConfiguration(),
- lcm);
+ lcm, target);
} else {
logger.severe("Unable to find model generator");
}
@@ -374,14 +399,15 @@
}
protected void generateRoleProject(String projectName,
- org.w3c.dom.Element esbConfig, ConversationModel localcm)
- throws Exception {
+ org.w3c.dom.Element esbConfig, ConversationModel localcm,
+ ESBLanguageModel model) throws Exception {
final IJavaProject jproj=createJavaProject(projectName);
if (jproj != null && esbConfig != null) {
// Store ESB configuration
- IPath esbConfigPath=jproj.getPath().append(new Path(ESB_CONFIG_PATH));
+ IPath esbConfigPath=jproj.getPath().append(
+ new Path(getSelectedBuildSystem().getESBConfigFilePath()));
IFile esbConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(esbConfigPath);
createParentFolder(esbConfigFile);
@@ -415,13 +441,119 @@
return true;
}
});
+
+ generateBuildConfigurationFile(jproj);
+
+ generateDeploymentFile(jproj, model);
+ generateJBMQConfigurationFile(jproj, model);
}
}
+ protected void generateBuildConfigurationFile(IJavaProject jproj)
+ throws Exception {
+
+ IPath buildConfigPath=jproj.getPath().append(
+ new Path(getSelectedBuildSystem().getBuildFilePath()));
+
+ IFile buildConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(buildConfigPath);
+ createParentFolder(buildConfigFile);
+ buildConfigFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ String config=getSelectedBuildSystem().getBuildFileContents(jproj.getProject().getName());
+
+ if (config != null) {
+ buildConfigFile.setContents(new java.io.ByteArrayInputStream(
+ config.getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+ }
+
+
+ protected void generateJBMQConfigurationFile(IJavaProject jproj,
+ ESBLanguageModel model) throws Exception {
+
+ IPath buildConfigPath=jproj.getPath().append(
+ new Path(getSelectedBuildSystem().getJBMQConfigFilePath()));
+
+ IFile buildConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(buildConfigPath);
+ createParentFolder(buildConfigFile);
+ buildConfigFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ StringBuffer buf=new StringBuffer();
+ buf.append("<server>\r\n");
+
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (iter.hasNext()) {
+ ESBService service=iter.next();
+
+ String dest=model.getJMSDefinition(service.getJMSBusIdRef());
+
+ if (dest != null) {
+ buf.append("\t<mbean code=\"org.jboss.mq.server.jmx.Queue\"\r\n");
+ buf.append("\t\t\tname=\""+service.getCategory()+".destination:service=Queue,name="+dest+"\">\r\n");
+ buf.append("\t\t<depends optional-attribute-name=\"DestinationManager\">\r\n");
+ buf.append("\t\t\tjboss.mq:service=DestinationManager\r\n");
+ buf.append("\t\t</depends>\r\n");
+ buf.append("\t</mbean>\r\n");
+ } else {
+ logger.severe("Failed to find destination for JMS bus id '"+
+ service.getJMSBusIdRef()+"'");
+ }
+ }
+
+ buf.append("</server>\r\n");
+
+ buildConfigFile.setContents(new java.io.ByteArrayInputStream(
+ buf.toString().getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
+ protected void generateDeploymentFile(IJavaProject jproj,
+ ESBLanguageModel model) throws Exception {
+
+ IPath deploymentPath=jproj.getPath().append(
+ new Path(getSelectedBuildSystem().getDeploymentFilePath()));
+
+ IFile deploymentFile=jproj.getProject().getWorkspace().getRoot().getFile(deploymentPath);
+ createParentFolder(deploymentFile);
+ deploymentFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ StringBuffer buf=new StringBuffer();
+ buf.append("<jbossesb-deployment>\r\n");
+
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (iter.hasNext()) {
+ ESBService service=iter.next();
+
+ String dest=model.getJMSDefinition(service.getJMSBusIdRef());
+
+ if (dest != null) {
+ buf.append("\t<depends>"+service.getCategory()+
+ ".destination:service=Queue,name="+dest+
+ "</depends>\r\n");
+ } else {
+ logger.severe("Failed to find destination for JMS bus id '"+
+ service.getJMSBusIdRef()+"'");
+ }
+ }
+
+ buf.append("</jbossesb-deployment>\r\n");
+
+ deploymentFile.setContents(new java.io.ByteArrayInputStream(
+ buf.toString().getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
protected void generateBusinessObjectType(IJavaProject jproj,
Conversation conversation) throws Exception {
- IPath sourceLocation=jproj.getPath().append(new Path(JAVA_SOURCE_LOCATION));
+ IPath sourceLocation=jproj.getPath().append(
+ new Path(getSelectedBuildSystem().getJavaSourcePath()));
String javaClass=ConversationUtil.getBusinessObjectType(conversation);
@@ -650,7 +782,8 @@
IPath outputLocation=jproj.getPath().append(new Path(OUTPUT_LOCATION));
IPath classpathLocation=jproj.getPath().append(new Path(CLASSPATH_FILENAME));
- IPath sourceLocation=jproj.getPath().append(new Path(JAVA_SOURCE_LOCATION));
+ IPath sourceLocation=jproj.getPath().append(
+ new Path(getSelectedBuildSystem().getJavaSourcePath()));
// create and set the output and source paths first
IFolder outputFolder= jproj.getProject().getWorkspace().getRoot().getFolder(outputLocation);
@@ -860,10 +993,12 @@
}
private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.dialogs");
-
+
private IFile m_file=null;
private ConversationModel m_conversationModel=null;
private java.util.List<Role> m_roles=null;
private java.util.List<Button> m_roleButtons=new java.util.Vector<Button>();
private java.util.List<Text> m_projectNames=new java.util.Vector<Text>();
+ private Combo m_build=null;
+ private java.util.List<BuildSystem> m_buildSystems=new java.util.Vector<BuildSystem>();
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java 2008-08-07 11:31:06 UTC (rev 223)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.dialogs;
+
+/**
+ * This class represents the Ant build system.
+ */
+public class MavenBuildSystem implements BuildSystem {
+
+ private static final String BUILD_FILE = "pom.xml";
+ private static final String MAVEN = "Maven";
+ private static final String ESB_CONFIG_PATH = "src/main/resources/META-INF/jboss-esb.xml";
+ private static final String DEPLOYMENT_PATH = "src/main/resources/META-INF/deployment.xml";
+ private static final String JBMQ_CONFIG_PATH = "src/main/resources/jbmq-queue-service.xml";
+ private static final String JAVA_SOURCE_PATH = "src/main/java";
+
+ /**
+ * This method represents the name of the build
+ * system.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(MAVEN);
+ }
+
+ /**
+ * This method returns the build configuration file
+ * path.
+ *
+ * @return The build configuration file path
+ */
+ public String getBuildFilePath() {
+ return(BUILD_FILE);
+ }
+
+ /**
+ * This method returns the contents for the build
+ * configuration file.
+ *
+ * @param projectName The project name
+ * @return The build file contents
+ */
+ public String getBuildFileContents(String projectName) {
+ StringBuffer ret=new StringBuffer();
+
+ ret.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n");
+ ret.append("\t\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n");
+ ret.append("\t\txsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\r\n");
+
+ ret.append("</project>\r\n");
+
+ return(ret.toString());
+ }
+
+ /**
+ * This method returns the ESB configuration file
+ * path.
+ *
+ * @return The ESB configuration file path
+ */
+ public String getESBConfigFilePath() {
+ return(ESB_CONFIG_PATH);
+ }
+
+ /**
+ * This method returns the deployment file
+ * path.
+ *
+ * @return The deployment file path
+ */
+ public String getDeploymentFilePath() {
+ return(DEPLOYMENT_PATH);
+ }
+
+ /**
+ * This method returns the JBMQ configuration file
+ * path.
+ *
+ * @return The JBMQ configuration file path
+ */
+ public String getJBMQConfigFilePath() {
+ return(JBMQ_CONFIG_PATH);
+ }
+
+ /**
+ * This method returns the Java source path.
+ *
+ * @return The Java source path
+ */
+ public String getJavaSourcePath() {
+ return(JAVA_SOURCE_PATH);
+ }
+
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java 2008-08-07 03:33:23 UTC (rev 222)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java 2008-08-07 11:31:06 UTC (rev 223)
@@ -432,6 +432,41 @@
return(ret);
}
+ /**
+ * This method returns the JMS destination associated with
+ * the supplied JMS Bus Id.
+ *
+ * @param jmsBusId The JMS bus id
+ * @return The JMS definition, or null if not found
+ */
+ public String getJMSDefinition(String jmsBusId) {
+ String ret=null;
+
+ org.w3c.dom.Element elem=findJMSBus(jmsBusId);
+
+ if (elem != null) {
+ org.w3c.dom.NodeList nl=
+ elem.getElementsByTagName(JMS_MESSAGE_FILTER_ELEMENT);
+
+ if (nl.getLength() != 0 &&
+ nl.item(0) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element filter=(org.w3c.dom.Element)
+ nl.item(0);
+
+ if (filter.hasAttribute(DEST_NAME_ATTR)) {
+ ret = filter.getAttribute(DEST_NAME_ATTR);
+
+ // If prefixed, then strip prefix away
+ if (ret.startsWith(DEST_NAME_PREFIX)) {
+ ret = ret.substring(DEST_NAME_PREFIX.length());
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
protected void addJMSBus(String jmsBusId, String dest) {
org.w3c.dom.Element jmsBus=
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java 2008-08-07 03:33:23 UTC (rev 222)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java 2008-08-07 11:31:06 UTC (rev 223)
@@ -118,4 +118,13 @@
*/
public org.w3c.dom.Element getESBConfiguration();
+ /**
+ * This method returns the JMS destination associated with
+ * the supplied JMS Bus Id.
+ *
+ * @param jmsBusId The JMS bus id
+ * @return The JMS definition, or null if not found
+ */
+ public String getJMSDefinition(String jmsBusId);
+
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBLanguageModel.java 2008-08-07 03:33:23 UTC (rev 222)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBLanguageModel.java 2008-08-07 11:31:06 UTC (rev 223)
@@ -105,6 +105,11 @@
return null;
}
+ public String getJMSDefinition(String jmsBusId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
private java.util.Map<String,ESBService> m_services=new java.util.Hashtable<String,ESBService>();
private ESBService m_gatewayService=null;
private org.w3c.dom.Element m_esbConfig=null;
15 years, 9 months
Overlord SVN: r222 - in cdl/trunk: samples and 7 other directories.
by overlord-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2008-08-06 23:33:23 -0400 (Wed, 06 Aug 2008)
New Revision: 222
Modified:
cdl/trunk/distribution/assembly/jbossesb/src/main/resources/cdl-ds.xml
cdl/trunk/samples/jbossesb/README.txt
cdl/trunk/samples/jbossesb/creditAgency/pom.xml
cdl/trunk/samples/jbossesb/creditAgency/src/main/java/com/acme/services/creditAgency/SetCreditCheckInvalidMessageAction.java
cdl/trunk/samples/jbossesb/creditAgency/src/main/java/com/acme/services/creditAgency/SetCreditCheckResponseMessageAction.java
cdl/trunk/samples/jbossesb/creditAgency/src/main/resources/META-INF/jboss-esb.xml
cdl/trunk/samples/jbossesb/purchasing/pom.xml
cdl/trunk/samples/jbossesb/purchasing/src/main/java/com/acme/services/broker/SetCreditCheckRequestMessageAction.java
cdl/trunk/samples/jbossesb/purchasing/src/main/resources/META-INF/jboss-esb.xml
cdl/trunk/samples/pom.xml
Log:
* Update the Credit Agency Message Type.
Modified: cdl/trunk/distribution/assembly/jbossesb/src/main/resources/cdl-ds.xml
===================================================================
--- cdl/trunk/distribution/assembly/jbossesb/src/main/resources/cdl-ds.xml 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/distribution/assembly/jbossesb/src/main/resources/cdl-ds.xml 2008-08-07 03:33:23 UTC (rev 222)
@@ -3,18 +3,18 @@
<datasources>
<!--
<xa-datasource>
- <jndi-name>JbpmDS</jndi-name>
+ <jndi-name>cdlDS</jndi-name>
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
<track-connection-by-tx/>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
- <xa-datasource-property name="URL">jdbc:h2:${jboss.server.data.dir}${/}h2${/}jbpmDB;MVCC=TRUE</xa-datasource-property>
+ <xa-datasource-property name="URL">jdbc:h2:${jboss.server.data.dir}${/}h2${/}cdlDB;MVCC=TRUE</xa-datasource-property>
<xa-datasource-property name="User">sa</xa-datasource-property>
<xa-datasource-property name="Password"></xa-datasource-property>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
- <depends>jboss:service=h2,database=jbpmDB</depends>
+ <depends>jboss:service=h2,database=cdlDB</depends>
</xa-datasource>
-->
<local-tx-datasource>
Modified: cdl/trunk/samples/jbossesb/README.txt
===================================================================
--- cdl/trunk/samples/jbossesb/README.txt 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/jbossesb/README.txt 2008-08-07 03:33:23 UTC (rev 222)
@@ -13,6 +13,7 @@
- client
- broker
- purchasing
+- creditAgency
Settings required to edit before running:
========================================
Modified: cdl/trunk/samples/jbossesb/creditAgency/pom.xml
===================================================================
--- cdl/trunk/samples/jbossesb/creditAgency/pom.xml 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/jbossesb/creditAgency/pom.xml 2008-08-07 03:33:23 UTC (rev 222)
@@ -33,6 +33,27 @@
<build>
<finalName>creditAgency</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!--Deploy esb artifact to JBoss AS/ESB -->
+ <execution>
+ <id>deploy</id>
+ <phase>install</phase>
+ <configuration>
+ <tasks>
+ <copy file="target/creditAgency.esb" todir="${deploy.dir}" overwrite="true" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
</project>
Modified: cdl/trunk/samples/jbossesb/creditAgency/src/main/java/com/acme/services/creditAgency/SetCreditCheckInvalidMessageAction.java
===================================================================
--- cdl/trunk/samples/jbossesb/creditAgency/src/main/java/com/acme/services/creditAgency/SetCreditCheckInvalidMessageAction.java 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/jbossesb/creditAgency/src/main/java/com/acme/services/creditAgency/SetCreditCheckInvalidMessageAction.java 2008-08-07 03:33:23 UTC (rev 222)
@@ -40,7 +40,7 @@
Node node = XMLUtils.getNode((String)message.getBody().get());
String idValue = node.getAttributes().getNamedItem("id").getNodeValue();
- message.getBody().add("<CreditCheckInvalid id=\"" + idValue +"\"></CreditCheckInvalid>");
+ message.getBody().add("<CreditInvalid id=\"" + idValue +"\"></CreditInvalid>");
logger.info("Updated credit message: "+message);
Modified: cdl/trunk/samples/jbossesb/creditAgency/src/main/java/com/acme/services/creditAgency/SetCreditCheckResponseMessageAction.java
===================================================================
--- cdl/trunk/samples/jbossesb/creditAgency/src/main/java/com/acme/services/creditAgency/SetCreditCheckResponseMessageAction.java 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/jbossesb/creditAgency/src/main/java/com/acme/services/creditAgency/SetCreditCheckResponseMessageAction.java 2008-08-07 03:33:23 UTC (rev 222)
@@ -40,7 +40,7 @@
Node node = XMLUtils.getNode((String)message.getBody().get());
String idValue = node.getAttributes().getNamedItem("id").getNodeValue();
- message.getBody().add("<CreditCheckResponse id=\"" + idValue +"\"></CreditCheckResponse>");
+ message.getBody().add("<CreditValid id=\"" + idValue +"\"></CreditValid>");
logger.info("Updated credit message: "+message.getBody().get() +"' by thread of " + Thread.currentThread().getName());
Modified: cdl/trunk/samples/jbossesb/creditAgency/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- cdl/trunk/samples/jbossesb/creditAgency/src/main/resources/META-INF/jboss-esb.xml 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/jbossesb/creditAgency/src/main/resources/META-INF/jboss-esb.xml 2008-08-07 03:33:23 UTC (rev 222)
@@ -52,7 +52,7 @@
<action class="org.jboss.soa.overlord.jbossesb.actions.ReceiveMessageAction"
process="process" name="c2">
<property name="operation" value="checkCredit" />
- <property name="messageType" value="CreditCheckRequest" />
+ <property name="messageType" value="CreditInformation" />
<property name="clientEPR" value="broker" />
<property name="identities" >
<identity type="primary" >
@@ -89,7 +89,7 @@
process="process" name="d3">
<property name="session" value="com.acme.services.creditAgency.CreditAgencyPurchase" />
<property name="operation" value="checkCredit" />
- <property name="messageType" value="CreditCheckResponse" />
+ <property name="messageType" value="CreditValid" />
<property name="clientEPR" value="broker" />
<property name="identities" >
<identity type="primary" >
@@ -114,7 +114,7 @@
process="process" name="e3">
<property name="session" value="com.acme.services.creditAgency.CreditAgencyPurchase" />
<property name="operation" value="checkCredit" />
- <property name="messageType" value="CreditCheckInvalid" />
+ <property name="messageType" value="CreditInvalid" />
<property name="clientEPR" value="broker" />
<property name="identities" >
<identity type="primary" >
Modified: cdl/trunk/samples/jbossesb/purchasing/pom.xml
===================================================================
--- cdl/trunk/samples/jbossesb/purchasing/pom.xml 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/jbossesb/purchasing/pom.xml 2008-08-07 03:33:23 UTC (rev 222)
@@ -32,6 +32,26 @@
<build>
<finalName>purchasing</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>deploy</id>
+ <phase>install</phase>
+ <configuration>
+ <tasks>
+ <copy file="target/purchasing.esb" todir="${deploy.dir}" overwrite="true" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
</project>
Modified: cdl/trunk/samples/jbossesb/purchasing/src/main/java/com/acme/services/broker/SetCreditCheckRequestMessageAction.java
===================================================================
--- cdl/trunk/samples/jbossesb/purchasing/src/main/java/com/acme/services/broker/SetCreditCheckRequestMessageAction.java 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/jbossesb/purchasing/src/main/java/com/acme/services/broker/SetCreditCheckRequestMessageAction.java 2008-08-07 03:33:23 UTC (rev 222)
@@ -40,7 +40,7 @@
Node node = XMLUtils.getNode((String)message.getBody().get());
String idValue = node.getAttributes().getNamedItem("id").getNodeValue();
- message.getBody().add("<CreditCheckRequest id=\"" + idValue +"\"></CreditCheckRequest>");
+ message.getBody().add("<CreditInformation id=\"" + idValue +"\"></CreditInformation>");
logger.info("Updated credit check request message: "+message);
Modified: cdl/trunk/samples/jbossesb/purchasing/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- cdl/trunk/samples/jbossesb/purchasing/src/main/resources/META-INF/jboss-esb.xml 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/jbossesb/purchasing/src/main/resources/META-INF/jboss-esb.xml 2008-08-07 03:33:23 UTC (rev 222)
@@ -82,7 +82,7 @@
<action class="org.jboss.soa.overlord.jbossesb.actions.SendMessageAction"
process="process" name="a4">
<property name="operation" value="checkCredit" />
- <property name="messageType" value="CreditCheckRequest" />
+ <property name="messageType" value="CreditInformation" />
<property name="serviceName" value="CreditAgency.main" />
<property name="serviceCategory" value="PurchaseGoods.CreditAgency" />
<property name="responseServiceName" value="CreditResponse" />
@@ -118,11 +118,11 @@
<property name="paths">
<case service-category="PurchaseGoods.Broker"
service-name="CreditResponse1" >
- <message type="CreditCheckResponse" />
+ <message type="CreditValid" />
</case>
<case service-category="PurchaseGoods.Broker"
service-name="CreditResponse2" >
- <message type="CreditCheckInvalid" />
+ <message type="CreditInvalid" />
</case>
</property>
</action>
@@ -140,7 +140,7 @@
process="process" name="b4">
<property name="session" value="com.acme.services.broker.PurchaseGoods" />
<property name="operation" value="checkCredit" />
- <property name="messageType" value="CreditCheckResponse" />
+ <property name="messageType" value="CreditValid" />
<property name="serviceDescriptionName" value="{http://www.jboss.org/overlord/purchase}Broker" />
<property name="identities" >
<identity type="primary" >
@@ -234,7 +234,7 @@
process="process" name="b14">
<property name="session" value="com.acme.services.broker.PurchaseGoods" />
<property name="operation" value="checkCredit" />
- <property name="messageType" value="CreditCheckInvalid" />
+ <property name="messageType" value="CreditInvalid" />
<property name="serviceDescriptionName" value="{http://www.jboss.org/overlord/purchase}Broker" />
<property name="identities" >
<identity type="primary" >
Modified: cdl/trunk/samples/pom.xml
===================================================================
--- cdl/trunk/samples/pom.xml 2008-08-06 15:57:08 UTC (rev 221)
+++ cdl/trunk/samples/pom.xml 2008-08-07 03:33:23 UTC (rev 222)
@@ -17,9 +17,6 @@
<properties>
<deploy.dir>/var/local/jboss/server/default/deploy</deploy.dir>
- <hibernate-commons-annotations>3.0.0.ga</hibernate-commons-annotations>
- <hibernate-tools-version>3.2.0.ga</hibernate-tools-version>
- <hsqldb-version>1.8.0.7</hsqldb-version>
</properties>
15 years, 9 months
Overlord SVN: r221 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-06 11:57:08 -0400 (Wed, 06 Aug 2008)
New Revision: 221
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
Log:
Generate business object types for conversation hierarchy, and also variables aswell as roles.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java 2008-08-06 15:56:29 UTC (rev 220)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java 2008-08-06 15:57:08 UTC (rev 221)
@@ -377,7 +377,7 @@
org.w3c.dom.Element esbConfig, ConversationModel localcm)
throws Exception {
- IJavaProject jproj=createJavaProject(projectName);
+ final IJavaProject jproj=createJavaProject(projectName);
if (jproj != null && esbConfig != null) {
// Store ESB configuration
@@ -398,7 +398,23 @@
// Generate business object types for
// local conversation model
- generateBusinessObjectType(jproj, localcm.getConversation());
+ localcm.visit(new Visitor() {
+
+ public boolean visit(ModelObject obj) {
+
+ if (obj instanceof Conversation) {
+ try {
+ generateBusinessObjectType(jproj,
+ (Conversation)obj);
+ } catch(Exception e) {
+ error("Failed to generate business object type",
+ e);
+ }
+ }
+
+ return true;
+ }
+ });
}
}
@@ -471,6 +487,7 @@
protected void generateBusinessObjectTypeMethods(TypeDeclaration type,
final Conversation conversation) throws Exception {
final java.util.List<Role> roles=new java.util.Vector<Role>();
+ final java.util.List<Variable> variables=new java.util.Vector<Variable>();
conversation.visit(new Visitor() {
public boolean visit(ModelObject obj) {
@@ -491,6 +508,10 @@
roles.contains(interaction.getToRole()) == false) {
roles.add(interaction.getToRole());
}
+ } else if (obj instanceof VariableList) {
+ VariableList vars=(VariableList)obj;
+
+ variables.addAll(vars.getVariables());
}
return(ret);
@@ -511,9 +532,7 @@
method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
org.eclipse.jdt.core.dom.Block block=ast.newBlock();
-
- LineComment comment=ast.newLineComment();
-
+
ReturnStatement retStatement=ast.newReturnStatement();
retStatement.setExpression(ast.newNullLiteral());
@@ -546,6 +565,56 @@
type.bodyDeclarations().add(method);
}
+
+ for (int i=0; i < variables.size(); i++) {
+ AST ast=type.getAST();
+
+ String methodName=
+ ConversationUtil.getVariableAccessorMethod(variables.get(i).getName());
+
+ MethodDeclaration method=ast.newMethodDeclaration();
+ method.setName(ast.newSimpleName(methodName));
+ method.setReturnType2(ast.newSimpleType(
+ ast.newName("Object")));
+
+ method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
+
+ org.eclipse.jdt.core.dom.Block block=ast.newBlock();
+
+ ReturnStatement retStatement=ast.newReturnStatement();
+
+ retStatement.setExpression(ast.newNullLiteral());
+
+ block.statements().add(retStatement);
+
+ method.setBody(block);
+
+ type.bodyDeclarations().add(method);
+
+ // Generate setter method
+ methodName=
+ ConversationUtil.getVariableModifierMethod(variables.get(i).getName());
+
+ method=ast.newMethodDeclaration();
+ method.setName(ast.newSimpleName(methodName));
+ method.setReturnType2(ast.newSimpleType(
+ ast.newName("void")));
+
+ SingleVariableDeclaration svd=ast.newSingleVariableDeclaration();
+ svd.setName(ast.newSimpleName("value"));
+ svd.setType(ast.newSimpleType(
+ ast.newName("Object")));
+
+ method.parameters().add(svd);
+
+ method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
+
+ block=ast.newBlock();
+
+ method.setBody(block);
+
+ type.bodyDeclarations().add(method);
+ }
}
protected IJavaProject createJavaProject(String projectName)
15 years, 9 months
Overlord SVN: r220 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: java/org/jboss/tools/overlord/jbossesb/model/change and 2 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-06 11:56:29 -0400 (Wed, 06 Aug 2008)
New Revision: 220
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/RunModelChangeRuleTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
Log:
Add test for run/perform.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-08-06 13:32:47 UTC (rev 219)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-08-06 15:56:29 UTC (rev 220)
@@ -47,6 +47,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public PerformAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ PerformAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@@ -167,6 +179,48 @@
}
}
+ /**
+ * This method sets the destination service descriptor properties.
+ *
+ * @param category The category
+ * @param name The name
+ */
+ public void setDestination(String category, String name) {
+
+ org.w3c.dom.Element prop=getPropertyElement(SERVICE_CATEGORY);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, category);
+ }
+
+ prop = getPropertyElement(SERVICE_NAME);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, name);
+ }
+ }
+
+ /**
+ * This method sets the return destination service descriptor properties.
+ *
+ * @param category The category
+ * @param name The name
+ */
+ public void setReturnDestination(String category, String name) {
+
+ org.w3c.dom.Element prop=getPropertyElement(RETURN_SERVICE_CATEGORY);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, category);
+ }
+
+ prop = getPropertyElement(RETURN_SERVICE_NAME);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, name);
+ }
+ }
+
private String m_category=null;
private String m_name=null;
private ESBService m_service=null;
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java 2008-08-06 13:32:47 UTC (rev 219)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java 2008-08-06 15:56:29 UTC (rev 220)
@@ -79,24 +79,10 @@
String namespace=((Model)conv.getModel()).
getNamespace().getName();
- String qualifier="";
- Definition defn=conv;
+ String category=ConversationUtil.getServiceCategory(conv);
- // Create a hierarchical name related to the conversation
- while (defn != null) {
- qualifier = "."+defn.getModelName().getName();
-
- if (defn.getParent() instanceof Definition) {
- defn = (Definition)defn.getParent();
- } else {
- defn = null;
- }
- }
-
- String category = namespace + qualifier;
-
- String name=conv.getModelName().getLocatedRole().getName();
+ String name=ConversationUtil.getServiceName(conv);
String sdname="";
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/RunModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/RunModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/RunModelChangeRule.java 2008-08-06 15:56:29 UTC (rev 220)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the Run composition construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class RunModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ protected boolean isChangeSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof Run &&
+ context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param position The position, where relevant
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, int position) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=(ESBService)context.getParent();
+ Run run=(Run)mobj;
+
+ PerformAction action=new PerformAction(service);
+
+ service.addAction(action, position);
+
+ String category=ConversationUtil.getServiceCategory(run.getDefinition());
+ String name=ConversationUtil.getServiceName(run.getDefinition());
+
+ action.setDestination(category, name);
+
+ // Create return service
+ ESBService returnService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(returnService);
+
+ context.setParent(returnService);
+
+ action.setReturnDestination(returnService.getCategory(),
+ returnService.getName());
+
+ return(true);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model.change");
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java 2008-08-06 13:32:47 UTC (rev 219)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java 2008-08-06 15:56:29 UTC (rev 220)
@@ -18,6 +18,8 @@
package org.jboss.tools.overlord.jbossesb.model.util;
import org.scribble.conversation.model.*;
+import org.scribble.model.Definition;
+import org.scribble.model.Model;
/**
* This class contains utility functions related to the
@@ -78,4 +80,58 @@
return(ret);
}
+
+ /**
+ * This method returns the business object type accessor method
+ * for the variable's name.
+ *
+ * @param name The variable name
+ * @return The accessor method
+ */
+ public static String getVariableAccessorMethod(String name) {
+ String ret="get"+Character.toUpperCase(name.charAt(0))+name.substring(1);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the business object type modifier method
+ * for the variable's name.
+ *
+ * @param name The variable name
+ * @return The modifier method
+ */
+ public static String getVariableModifierMethod(String name) {
+ String ret="set"+Character.toUpperCase(name.charAt(0))+name.substring(1);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the service category associated with
+ * the supplied conversation.
+ *
+ * @param conv The conversation
+ * @return The service category
+ */
+ public static String getServiceCategory(Conversation conv) {
+ String ret=((Model)conv.getModel()).
+ getNamespace().getName();
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the service name associated with
+ * the supplied conversation.
+ *
+ * @param conv The conversation
+ * @return The service name
+ */
+ public static String getServiceName(Conversation conv) {
+ String ret=conv.getModelName().getName()+"_"+
+ conv.getModelName().getLocatedRole().getName();
+
+ return(ret);
+ }
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java 2008-08-06 13:32:47 UTC (rev 219)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java 2008-08-06 15:56:29 UTC (rev 220)
@@ -109,7 +109,7 @@
* for the role's service category.
*
* @param roleName The role
- * @return The service category property
+ * @return The service category accessor method
*/
public static String getRoleServiceCategoryAccessorMethod(String roleName) {
String ret=roleName+SERVICE_CATEGORY_ACCESSOR_SUFFIX;
@@ -124,7 +124,7 @@
* for the role's service name.
*
* @param roleName The role
- * @return The service name property
+ * @return The service name accessor method
*/
public static String getRoleServiceNameAccessorMethod(String roleName) {
String ret=roleName+SERVICE_NAME_ACCESSOR_SUFFIX;
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2008-08-06 13:32:47 UTC (rev 219)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2008-08-06 15:56:29 UTC (rev 220)
@@ -339,7 +339,6 @@
model.addService(service);
-
TestModelChangeContext context=new TestModelChangeContext();
context.setParent(service);
@@ -472,7 +471,7 @@
action.getPropertyValue(
SendMessageAction.RESPONSE_SERVICE_CATEGORY)+
"' invalid, expecting: "+
- service.getCategory());
+ newService.getCategory());
}
if (newService.getName().equals(action.getPropertyValue(
@@ -481,7 +480,7 @@
action.getPropertyValue(
SendMessageAction.RESPONSE_SERVICE_NAME)+
"' invalid, expecting: "+
- service.getName());
+ newService.getName());
}
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/RunModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/RunModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/RunModelChangeRuleTest.java 2008-08-06 15:56:29 UTC (rev 220)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class RunModelChangeRuleTest extends TestCase {
+
+ public void testInsertPerformAction() {
+ String runName="subconv";
+
+ RunModelChangeRule rule=new RunModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Run mobj=new Run();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(0);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ if (newService.getCategory().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
+ fail("Perform return service category '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)) == false) {
+ fail("Perform return service name '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+ }
+}
15 years, 9 months
Overlord SVN: r219 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: java/org/jboss/tools/overlord/jbossesb/model/change and 2 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-06 09:32:47 -0400 (Wed, 06 Aug 2008)
New Revision: 219
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBService.java
Log:
Primarily added tests for interaction insertion, but also made some other minor adjustments.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-08-05 16:44:24 UTC (rev 218)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-08-06 13:32:47 UTC (rev 219)
@@ -201,6 +201,22 @@
paths.appendChild(path);
}
+
+ /**
+ * This method returns the number of routes associated with
+ * the message router.
+ *
+ * @return The number of routes
+ */
+ public int getNumberOfRoutes() {
+ int ret=0;
+
+ org.w3c.dom.NodeList nl=getAction().getElementsByTagName(ROUTE);
+
+ ret = nl.getLength();
+
+ return(ret);
+ }
/**
* This method returns the mandatory property names.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java 2008-08-05 16:44:24 UTC (rev 218)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java 2008-08-06 13:32:47 UTC (rev 219)
@@ -28,10 +28,10 @@
*/
public class ReceiveMessageAction extends AbstractESBAction {
- private static final String IDENTITIES = "identities";
- private static final String MESSAGE_TYPE = "messageType";
- private static final String OPERATION = "operation";
- private static final String CLIENT_EPR = "clientEPR";
+ public static final String IDENTITIES = "identities";
+ public static final String MESSAGE_TYPE = "messageType";
+ public static final String OPERATION = "operation";
+ public static final String CLIENT_EPR = "clientEPR";
/**
* The constructor for the action.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java 2008-08-05 16:44:24 UTC (rev 218)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java 2008-08-06 13:32:47 UTC (rev 219)
@@ -28,9 +28,9 @@
*/
public class ScheduleStateAction extends AbstractESBAction {
- private static final String IMMEDIATE = "immediate";
- private static final String SERVICE_NAME = "serviceName";
- private static final String SERVICE_CATEGORY = "serviceCategory";
+ public static final String IMMEDIATE = "immediate";
+ public static final String SERVICE_NAME = "serviceName";
+ public static final String SERVICE_CATEGORY = "serviceCategory";
/**
* The constructor for the action.
@@ -148,5 +148,36 @@
}
}
+ /**
+ * This method sets the destination service descriptor properties.
+ *
+ * @param category The category
+ * @param name The name
+ * @param immediate Whether the invoke immediately
+ */
+ public void setDestination(String category, String name,
+ boolean immediate) {
+
+ org.w3c.dom.Element prop=getPropertyElement(SERVICE_CATEGORY);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, category);
+ }
+
+ prop = getPropertyElement(SERVICE_NAME);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, name);
+ }
+
+ if (immediate) {
+ prop = getPropertyElement(IMMEDIATE);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, Boolean.toString(immediate));
+ }
+ }
+ }
+
private ESBService m_service=null;
}
\ No newline at end of file
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java 2008-08-05 16:44:24 UTC (rev 218)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java 2008-08-06 13:32:47 UTC (rev 219)
@@ -28,15 +28,15 @@
*/
public class SendMessageAction extends AbstractESBAction {
- private static final String CLIENT_EPR = "clientEPR";
- private static final String RESPONSE_SERVICE_NAME = "responseServiceName";
- private static final String RESPONSE_SERVICE_CATEGORY = "responseServiceCategory";
- private static final String SERVICE_NAME = "serviceName";
- private static final String SERVICE_CATEGORY = "serviceCategory";
- private static final String SERVICE_NAME_EXPRESSION = "serviceNameExpression";
- private static final String SERVICE_CATEGORY_EXPRESSION = "serviceCategoryExpression";
- private static final String MESSAGE_TYPE = "messageType";
- private static final String OPERATION = "operation";
+ public static final String CLIENT_EPR = "clientEPR";
+ public static final String RESPONSE_SERVICE_NAME = "responseServiceName";
+ public static final String RESPONSE_SERVICE_CATEGORY = "responseServiceCategory";
+ public static final String SERVICE_NAME = "serviceName";
+ public static final String SERVICE_CATEGORY = "serviceCategory";
+ public static final String SERVICE_NAME_EXPRESSION = "serviceNameExpression";
+ public static final String SERVICE_CATEGORY_EXPRESSION = "serviceCategoryExpression";
+ public static final String MESSAGE_TYPE = "messageType";
+ public static final String OPERATION = "operation";
/**
* The constructor for the action.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-08-05 16:44:24 UTC (rev 218)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-08-06 13:32:47 UTC (rev 219)
@@ -114,18 +114,8 @@
// implementations found, then can select e.g. XML or
// Java as message type representation.
- String mtype=null;
+ String mtype=InteractionUtil.getTypeString(ref);
- if (ref.getNamespace() != null) {
- mtype = "{"+ref.getNamespace()+"}";
- } else {
- mtype = "";
- }
-
- if (ref.getLocalpart() != null) {
- mtype += ref.getLocalpart();
- }
-
action.setMessageType(mtype);
}
@@ -211,6 +201,9 @@
ScheduleStateAction schedule=
new ScheduleStateAction(service);
+ schedule.setDestination(recvService.getCategory(),
+ recvService.getName(), false);
+
service.addAction(schedule, position);
context.setParent(recvService);
@@ -225,7 +218,6 @@
if (interaction.getMessageSignature().getTypes().size() == 1) {
TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
- String mtype=null;
// TODO: Search for an implementation associated with
// the type reference, so that the type can be
@@ -233,17 +225,8 @@
// notation as part of the context, so that if multiple
// implementations found, then can select e.g. XML or
// Java as message type representation.
-
- if (ref.getNamespace() != null) {
- mtype = "{"+ref.getNamespace()+"}";
- } else {
- mtype = "";
- }
+ String mtype=InteractionUtil.getTypeString(ref);
- if (ref.getLocalpart() != null) {
- mtype += ref.getLocalpart();
- }
-
action.setMessageType(mtype);
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBLanguageModel.java 2008-08-05 16:44:24 UTC (rev 218)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBLanguageModel.java 2008-08-06 13:32:47 UTC (rev 219)
@@ -79,9 +79,12 @@
}
public ESBService getGatewayService() {
- // TODO Auto-generated method stub
- return null;
+ return(m_gatewayService);
}
+
+ public void setGatewayService(ESBService gw) {
+ m_gatewayService = gw;
+ }
public void validate(ModelListener l) {
// TODO Auto-generated method stub
@@ -103,6 +106,7 @@
}
private java.util.Map<String,ESBService> m_services=new java.util.Hashtable<String,ESBService>();
+ private ESBService m_gatewayService=null;
private org.w3c.dom.Element m_esbConfig=null;
private int m_count=0;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBService.java 2008-08-05 16:44:24 UTC (rev 218)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/TestESBService.java 2008-08-06 13:32:47 UTC (rev 219)
@@ -161,14 +161,20 @@
}
public boolean isGateway() {
- // TODO Auto-generated method stub
- return false;
+ return(m_gateway);
}
+ public void setGateway(boolean gw) {
+ m_gateway = gw;
+ }
+
public ESBAction getGatewayAction() {
- // TODO Auto-generated method stub
- return null;
+ return(m_gatewayAction);
}
+
+ public void setGatewayAction(ESBAction act) {
+ m_gatewayAction = act;
+ }
public void validate(ModelListener l) {
// TODO Auto-generated method stub
@@ -197,6 +203,8 @@
private Element m_service;
private List<ESBAction> m_actions=new java.util.Vector<ESBAction>();
private boolean m_root=false;
+ private boolean m_gateway=false;
+ private ESBAction m_gatewayAction=null;
private boolean m_loop=false;
private boolean m_sessionBased=false;
private boolean m_createSession=false;
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2008-08-06 13:32:47 UTC (rev 219)
@@ -0,0 +1,634 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class ConversationInteractionModelChangeRuleTest extends TestCase {
+
+ public void testInsertFirstReceiveAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setToRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 1) {
+ fail("One route expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
+ public void testInsertSecondReceiveAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, -1) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setToRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, -1) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.IMMEDIATE) != null) {
+ fail("Schedule should not be immediate");
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+newService.getActions().get(0));
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)newService.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 2) {
+ fail("Two routes expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
+ public void testInsertReceiveRequestAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(toRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(toRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR).equals(fromRoleName) == false) {
+ fail("Client EPR '"+action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR)+
+ "' invalid, expecting: "+fromRoleName);
+ }
+ }
+
+ public void testInsertFirstSendAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+ }
+
+ public void testInsertSendRequestAction() {
+ String roleName="role1";
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName(roleName);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ if (newService.getCategory().equals(action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+ }
+
+ public void testInsertSendNotReplyAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(fromRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(fromRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION).
+ equals(InteractionUtil.getRoleServiceCategoryProperty(toRoleName)) == false) {
+ fail("Service category expression '"+
+ action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION)+
+ "' invalid, expecting: "+
+ InteractionUtil.getRoleServiceCategoryProperty(toRoleName));
+ }
+
+ if (action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION).
+ equals(InteractionUtil.getRoleServiceNameProperty(toRoleName)) == false) {
+ fail("Service name expression '"+
+ action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION)+
+ "' invalid, expecting: "+
+ InteractionUtil.getRoleServiceNameProperty(toRoleName));
+ }
+ }
+
+ public void testInsertSendReplyAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(fromRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(fromRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setReplyToLabel("replyLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(SendMessageAction.CLIENT_EPR).equals(toRoleName) == false) {
+ fail("Client EPR '"+action.getPropertyValue(SendMessageAction.CLIENT_EPR)+
+ "' invalid, expecting: "+toRoleName);
+ }
+ }
+}
15 years, 9 months
Overlord SVN: r218 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: java/org/jboss/tools/overlord/jbossesb/model/change and 2 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-05 12:44:24 -0400 (Tue, 05 Aug 2008)
New Revision: 218
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/WhileModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ParallelModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/WhenModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/WhileModelChangeRuleTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhenActionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRuleTest.java
Log:
Parallel, When and While generation with unit tests.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-08-05 10:27:12 UTC (rev 217)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/Messages.properties 2008-08-05 16:44:24 UTC (rev 218)
@@ -43,5 +43,4 @@
_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify atleast one case
_UNKNOWN_PROPERTY=Property '{0}' is unknown for this action
_WHEN_ONE_OR_MORE_PATHS=When action must specify atleast one entry
-_WHEN_PATH_AFTER_JOIN=When path must not be defined after a join
_WHILE_PATH_AFTER_EXIT=While path must not be defined after an exit
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-08-05 10:27:12 UTC (rev 217)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -272,6 +272,52 @@
}
}
+ /**
+ * This method adds a path to the parallel action.
+ *
+ * @param category The service category
+ * @param name The service name
+ * @param immediate Whether invocation should be immediate
+ * @param join Whether the path is for the parallel, or join
+ * @param position The position
+ */
+ public void addPath(String category, String name,
+ boolean immediate, boolean join, int position) {
+
+ org.w3c.dom.NodeList nl=
+ getAction().getElementsByTagName(PROPERTY_ELEMENT);
+
+ org.w3c.dom.Element paths=null;
+
+ for (int i=0; paths == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ String propName=((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR);
+
+ if (propName != null && propName.equals(PATHS)) {
+ paths = (org.w3c.dom.Element)nl.item(i);
+ }
+ }
+ }
+
+ if (paths == null) {
+ paths = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
+ paths.setAttribute(NAME_ATTR, PATHS);
+
+ getAction().appendChild(paths);
+ }
+
+ org.w3c.dom.Element path=
+ getAction().getOwnerDocument().createElement(join ? JOIN : PATH);
+ path.setAttribute(SERVICE_CATEGORY, category);
+ path.setAttribute(SERVICE_NAME, name);
+
+ if (immediate) {
+ path.setAttribute(IMMEDIATE, Boolean.TRUE.toString());
+ }
+
+ paths.appendChild(path);
+ }
+
private java.util.List<ESBService> m_services=new java.util.Vector<ESBService>();
private String m_joinCategory=null;
private String m_joinName=null;
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-08-05 10:27:12 UTC (rev 217)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -31,7 +31,6 @@
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
private static final String WHEN = "when";
- private static final String JOIN = "join";
private static final String PATHS = "paths";
/**
@@ -90,20 +89,6 @@
m_services.add(service);
}
}
-
- } else if (n.getNodeName().equals(JOIN)) {
- if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
- ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
- m_joinCategory=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- m_joinName=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // Lookup service associated with category and name
- m_joinService=getService().getModel().getService(m_joinCategory, m_joinName);
-
- // Initialize link, even if service is null - this will be
- // reported as a validation error later
- getLinks().add(new ESBLink(m_joinCategory, m_joinName, m_joinService, true));
- }
}
}
}
@@ -137,9 +122,6 @@
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
int pathCount=0;
- boolean f_joined=false;
- boolean f_pathAfterJoin=false;
- boolean f_multipleJoins=false;
boolean f_serviceDetailsMissing=false;
for (int i=0; nl != null && i < nl.getLength(); i++) {
@@ -149,22 +131,11 @@
if (n instanceof org.w3c.dom.Element) {
if (n.getNodeName().equals(WHEN)) {
pathCount++;
-
- if (f_joined) {
- f_pathAfterJoin = true;
- }
if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
f_serviceDetailsMissing = true;
}
- } else if (n.getNodeName().equals(JOIN)) {
-
- if (f_joined) {
- f_multipleJoins = true;
- }
-
- f_joined = true;
}
}
}
@@ -178,22 +149,6 @@
new String[]{}), null);
}
- if (f_pathAfterJoin) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
- "_WHEN_PATH_AFTER_JOIN",
- new String[]{}), null);
- }
-
- if (f_multipleJoins) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
- "_MULTIPLE_JOINS",
- new String[]{}), null);
- }
-
if (f_serviceDetailsMissing) {
l.error(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
@@ -237,6 +192,46 @@
}
}
+ /**
+ * This method adds a path to the when action.
+ *
+ * @param category The service category
+ * @param name The service name
+ * @param position The position
+ */
+ public void addPath(String category, String name,
+ int position) {
+
+ org.w3c.dom.NodeList nl=
+ getAction().getElementsByTagName(PROPERTY_ELEMENT);
+
+ org.w3c.dom.Element paths=null;
+
+ for (int i=0; paths == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ String propName=((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR);
+
+ if (propName != null && propName.equals(PATHS)) {
+ paths = (org.w3c.dom.Element)nl.item(i);
+ }
+ }
+ }
+
+ if (paths == null) {
+ paths = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
+ paths.setAttribute(NAME_ATTR, PATHS);
+
+ getAction().appendChild(paths);
+ }
+
+ org.w3c.dom.Element path=
+ getAction().getOwnerDocument().createElement(WHEN);
+ path.setAttribute(SERVICE_CATEGORY, category);
+ path.setAttribute(SERVICE_NAME, name);
+
+ paths.appendChild(path);
+ }
+
private java.util.List<ESBService> m_services=new java.util.Vector<ESBService>();
private String m_joinCategory=null;
private String m_joinName=null;
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-08-05 10:27:12 UTC (rev 217)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -34,6 +34,8 @@
private static final String WHILE = "while";
private static final String EXIT = "exit";
private static final String PATHS = "paths";
+ public static final String MESSAGE_ELEMENT="message";
+ public static final String TYPE_ATTR="type";
/**
* The constructor for the action.
@@ -301,6 +303,66 @@
}
}
+ /**
+ * This method adds a path to the when action.
+ *
+ * @param category The service category
+ * @param name The service name
+ * @param position The position
+ */
+ public void addPath(String category, String name, boolean exit,
+ java.util.List<MessageSignature> messageTypes,
+ int position) {
+
+ org.w3c.dom.NodeList nl=
+ getAction().getElementsByTagName(PROPERTY_ELEMENT);
+
+ org.w3c.dom.Element paths=null;
+
+ for (int i=0; paths == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ String propName=((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR);
+
+ if (propName != null && propName.equals(PATHS)) {
+ paths = (org.w3c.dom.Element)nl.item(i);
+ }
+ }
+ }
+
+ if (paths == null) {
+ paths = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
+ paths.setAttribute(NAME_ATTR, PATHS);
+
+ getAction().appendChild(paths);
+ }
+
+ org.w3c.dom.Element path=
+ getAction().getOwnerDocument().createElement(exit?EXIT:WHILE);
+ path.setAttribute(SERVICE_CATEGORY, category);
+ path.setAttribute(SERVICE_NAME, name);
+
+ paths.appendChild(path);
+
+ for (int i=0; i < messageTypes.size(); i++) {
+ org.w3c.dom.Element mt=
+ getAction().getOwnerDocument().createElement(MESSAGE_ELEMENT);
+
+ if (messageTypes.get(i).getTypes().size() == 1) {
+ TypeReference ref=messageTypes.get(i).getTypes().get(0);
+ String type="";
+
+ if (ref.getNamespace() != null) {
+ type += "{"+ref.getNamespace()+"}";
+ }
+ type += ref.getLocalpart();
+
+ mt.setAttribute(TYPE_ATTR, type);
+
+ path.appendChild(mt);
+ }
+ }
+ }
+
private String m_loopCategory=null;
private String m_loopName=null;
private ESBService m_loopService=null;
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java 2008-08-05 10:27:12 UTC (rev 217)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -178,19 +178,21 @@
switchAction.addCase(subService.getCategory(),
subService.getName(), interactions, i);
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
}
}
}
@@ -220,19 +222,21 @@
switchAction.addCase(subService.getCategory(),
subService.getName(), interactions, -1);
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
}
}
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ParallelModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ParallelModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ParallelModelChangeRule.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the Parallel grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ParallelModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ protected boolean isChangeSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof Parallel &&
+ context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param position The position, where relevant
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, int position) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=(ESBService)context.getParent();
+ Parallel parallel=(Parallel)mobj;
+
+ ParallelAction parAction=new ParallelAction(service);
+
+ service.addAction(parAction, position);
+
+ for (int i=0; i < parallel.getBlocks().size(); i++) {
+ Block b=parallel.getBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < b.getContents().size(); j++) {
+ context.insert(model, b.getContents().get(j), j);
+ }
+
+ boolean immediate=true;
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to get lookahead analyser");
+ } else {
+ java.util.Iterator<Interaction> iter=
+ la.getInteractions(b, true).iterator();
+
+ while (immediate && iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ // If interaction is a receive, then immediate
+ // invocation will be false
+ immediate = InteractionUtil.isSend(interaction);
+ }
+ }
+
+ parAction.addPath(subService.getCategory(),
+ subService.getName(), immediate, false, i);
+ }
+
+ // Create the join service
+ ESBService joinService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(joinService);
+
+ context.setParent(joinService);
+
+ parAction.addPath(joinService.getCategory(),
+ joinService.getName(), false, true, -1);
+
+ return(true);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model.change");
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/WhenModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/WhenModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/WhenModelChangeRule.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the When grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class WhenModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ protected boolean isChangeSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof When &&
+ context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param position The position, where relevant
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, int position) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=(ESBService)context.getParent();
+ When when=(When)mobj;
+
+ // Check if context role is decision maker
+ if (when.getRoles().contains(context.getRole())) {
+ WhenAction action=new WhenAction(service);
+
+ service.addAction(action, position);
+
+ for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+ ConditionalBlock b=when.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < b.getContents().size(); j++) {
+ context.insert(model, b.getContents().get(j), j);
+ }
+
+ action.addPath(subService.getCategory(),
+ subService.getName(), i);
+ }
+ } else {
+
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ service.addAction(switchAction, position);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=when.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), j);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, i);
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ }
+
+ // Only record message router 'routes' if the switch
+ // receives request interactions, and it is the first
+ // session based action in the service
+ if (messageTypes.size() > 0 &&
+ service.getFirstSessionBasedAction() == switchAction) {
+ ESBService gwService=
+ esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
+ }
+
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+ }
+
+ return(true);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model.change");
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/WhileModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/WhileModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/WhileModelChangeRule.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the While repetition construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class WhileModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ protected boolean isChangeSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof While &&
+ context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param position The position, where relevant
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, int position) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=(ESBService)context.getParent();
+ While whileElem=(While)mobj;
+
+ WhileAction action=new WhileAction(service);
+
+ service.addAction(action, position);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < whileElem.getBlock().getContents().size(); j++) {
+ context.insert(model, whileElem.getBlock().getContents().get(j), j);
+ }
+
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ // Check if context role is NOT the decision maker
+ if (whileElem.getRoles().contains(context.getRole()) == false) {
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(whileElem.getBlock());
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+
+ }
+
+ action.addPath(subService.getCategory(),
+ subService.getName(), false, messageTypes, -1);
+
+ // Create exit service
+ ESBService exitService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(exitService);
+
+ context.setParent(exitService);
+
+ action.addPath(exitService.getCategory(),
+ exitService.getName(), true,
+ new java.util.Vector<MessageSignature>(), -1);
+
+ return(true);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.model.change");
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhenActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhenActionTest.java 2008-08-05 10:27:12 UTC (rev 217)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/WhenActionTest.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -193,109 +193,6 @@
}
}
- public void testValidateOutOfOrderJoin() {
- TestESBService service=new TestESBService();
-
- java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
- props.put("paths", "<property><when service-category=\"cat1\" " +
- "service-name=\"name1\" /><join service-category=\"cat3\" " +
- "service-name=\"name3\" /><when service-category=\"cat2\" " +
- "service-name=\"name2\" /></property>");
-
- org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
-
- TestESBService other1=new TestESBService();
- other1.setCategory("cat1");
- other1.setName("name1");
-
- TestESBService other2=new TestESBService();
- other2.setCategory("cat2");
- other2.setName("name2");
-
- TestESBService other3=new TestESBService();
- other3.setCategory("cat3");
- other3.setName("name3");
-
- TestESBLanguageModel model=new TestESBLanguageModel();
- model.addService(other1);
- model.addService(other2);
- model.addService(other3);
- model.addService(service);
-
- service.setModel(model);
-
- WhenAction action=new WhenAction(service, elem);
- action.initializeLinks();
-
- service.getActions().add(action);
-
- TestModelListener l=new TestModelListener();
-
- l.addExpectedError(org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
- "_WHEN_PATH_AFTER_JOIN",
- new String[]{}));
-
- action.validate(l);
-
- if (l.isValid() == false) {
- fail(l.invalidMessage());
- }
- }
-
- public void testValidateOnlyOneJoin() {
- TestESBService service=new TestESBService();
-
- java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
- props.put("paths", "<property><when service-category=\"cat1\" " +
- "service-name=\"name1\" /><when service-category=\"cat2\" " +
- "service-name=\"name2\" /><join service-category=\"cat3\" " +
- "service-name=\"name3\" /><join service-category=\"cat3\" " +
- "service-name=\"name3\" /></property>");
-
- org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
-
- TestESBService other1=new TestESBService();
- other1.setCategory("cat1");
- other1.setName("name1");
-
- TestESBService other2=new TestESBService();
- other2.setCategory("cat2");
- other2.setName("name2");
-
- TestESBService other3=new TestESBService();
- other3.setCategory("cat3");
- other3.setName("name3");
-
- TestESBLanguageModel model=new TestESBLanguageModel();
- model.addService(other1);
- model.addService(other2);
- model.addService(other3);
- model.addService(service);
-
- service.setModel(model);
-
- WhenAction action=new WhenAction(service, elem);
- action.initializeLinks();
-
- service.getActions().add(action);
-
- TestModelListener l=new TestModelListener();
-
- l.addExpectedError(org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.actions.Messages"),
- "_MULTIPLE_JOINS",
- new String[]{}));
-
- action.validate(l);
-
- if (l.isValid() == false) {
- fail(l.invalidMessage());
- }
- }
-
public void testConvert() {
TestESBService service=new TestESBService();
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRuleTest.java 2008-08-05 10:27:12 UTC (rev 217)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRuleTest.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -332,6 +332,10 @@
public void testInsertSwitchAction() {
IfModelChangeRule rule=new IfModelChangeRule();
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
TestESBLanguageModel model=new TestESBLanguageModel();
TestESBService service=(TestESBService)
@@ -412,6 +416,10 @@
public void testInsertSwitchMultipleCaseAction() {
IfModelChangeRule rule=new IfModelChangeRule();
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
TestESBLanguageModel model=new TestESBLanguageModel();
TestESBService service=(TestESBService)
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ParallelModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ParallelModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/ParallelModelChangeRuleTest.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -0,0 +1,445 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.analysis.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class ParallelModelChangeRuleTest extends TestCase {
+
+ public void testInsertParallelAction() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Parallel mobj=new Parallel();
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ Block cb2=new Block();
+ mobj.getBlocks().add(cb2);
+
+ Block cb3=new Block();
+ mobj.getBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null || s3 == null ||
+ join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s3 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ join = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 4) {
+ fail("Four path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(1) immediate not set");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(2) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(2) immediate not set");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(3) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s3.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s3.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(3) immediate not set");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(3);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+
+ public void testInsertParallelActionWithImmediateFalse() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ Parallel mobj=new Parallel();
+ conv.getBlock().getContents().add(mobj);
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ cb1.getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ join = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("path(1) should not be immediate");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+
+ public void testInsertParallelActionWithImmediateTrue() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setFromRole(role);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ Parallel mobj=new Parallel();
+ conv.getBlock().getContents().add(mobj);
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ cb1.getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ join = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(1) should be immediate");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/WhenModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/WhenModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/WhenModelChangeRuleTest.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -0,0 +1,372 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class WhenModelChangeRuleTest extends TestCase {
+
+ public void testInsertWhenAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhenAction) == false) {
+ fail("Action was not WhenAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s3 = serv;
+ }
+ }
+
+ WhenAction action=(WhenAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(2) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(3) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s3.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s3.getName());
+ }
+ }
+
+ public void testInsertSwitchAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService switchService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (switchService == null && iter.hasNext()) {
+ switchService = iter.next();
+ if (switchService == service) {
+ switchService = null;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 1) {
+ fail("Only one path child expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Switch expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(switchService.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+switchService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(switchService.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+switchService.getName());
+ }
+ }
+
+ public void testInsertSwitchMultipleCaseAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService caseService1=null;
+ ESBService caseService2=null;
+ ESBService caseService3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((caseService1 == null || caseService2 == null ||
+ caseService3 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ caseService1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ caseService2 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ caseService3 = serv;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Case expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService1.getName());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Case expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService2.getName());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService3.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService3.getName());
+ }
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/WhileModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/WhileModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/change/WhileModelChangeRuleTest.java 2008-08-05 16:44:24 UTC (rev 218)
@@ -0,0 +1,420 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.analysis.TestLookaheadAnalyser;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class WhileModelChangeRuleTest extends TestCase {
+
+ public void testInsertWhileActionInitiator() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 0) {
+ fail("Should have no message types: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileActionRecipient() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getBlock().getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 1) {
+ fail("Should have single message type: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileActionRecipientNoRecvLookahead() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setFromRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getBlock().getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, -1) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 0) {
+ fail("Should have no message type: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+}
15 years, 9 months
Overlord SVN: r217 - cdl/trunk/samples/jbossesb/purchasing/models.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-05 06:27:12 -0400 (Tue, 05 Aug 2008)
New Revision: 217
Modified:
cdl/trunk/samples/jbossesb/purchasing/models/PurchaseGoods.cdm
Log:
Updated to include identity information and change credit check information types to be compatible with other example.
Modified: cdl/trunk/samples/jbossesb/purchasing/models/PurchaseGoods.cdm
===================================================================
--- cdl/trunk/samples/jbossesb/purchasing/models/PurchaseGoods.cdm 2008-08-04 15:34:52 UTC (rev 216)
+++ cdl/trunk/samples/jbossesb/purchasing/models/PurchaseGoods.cdm 2008-08-05 10:27:12 UTC (rev 217)
@@ -6,11 +6,19 @@
<informationTypes description="This is the information type BuyFailed" name="BuyFailed" elementName="BuyFailed"/>
<informationTypes description="This is the information type BuyRequest" name="BuyRequest" elementName="BuyRequest"/>
<informationTypes description="This is the information type BuyResponse" name="BuyResponse" elementName="BuyResponse"/>
- <informationTypes description="This is the information type CreditCheckInvalid" name="CreditCheckInvalid" elementName="CreditCheckInvalid"/>
- <informationTypes description="This is the information type CreditCheckRequest" name="CreditCheckRequest" elementName="CreditCheckRequest"/>
- <informationTypes description="This is the information type CreditCheckResponse" name="CreditCheckResponse" elementName="CreditCheckResponse"/>
+ <informationTypes description="This is the information type CreditInformation" name="CreditInformation" elementName="creditInformation"/>
+ <informationTypes description="This is the information type CreditInvalid" name="CreditInvalid" elementName="creditInvalid"/>
+ <informationTypes description="This is the information type CreditValid" name="CreditValid" elementName="creditValid"/>
+ <informationTypes description="This is the information type IDType" name="IDType" typeName="xsd:string"/>
<informationTypes description="This is the information type URITokenType" name="URITokenType" typeName="xsd:anyURI"/>
- <tokens description="This is the token URIToken" name="URIToken" informationType="//@typeDefinitions/(a)informationTypes.6"/>
+ <tokens description="This is the token ID" name="ID" informationType="//@typeDefinitions/(a)informationTypes.6"/>
+ <tokens description="This is the token URIToken" name="URIToken" informationType="//@typeDefinitions/(a)informationTypes.7"/>
+ <tokenLocators description="This is the token locator BuyFailedIDLocator" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.0" query="//@id" name="BuyFailedIDLocator"/>
+ <tokenLocators description="This is the token locator BuyRequestIDLocator" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.1" query="//@id" name="BuyRequestIDLocator"/>
+ <tokenLocators description="This is the token locator BuyResponseIDLocator" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.2" query="//@id" name="BuyResponseIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckInvalidIDLocator" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.4" query="//@id" name="CreditCheckInvalidIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckRequestIDLocator" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.3" query="//@id" name="CreditCheckRequestIDLocator"/>
+ <tokenLocators description="This is the token locator CreditCheckResponseIDLocator" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.5" query="//@id" name="CreditCheckResponseIDLocator"/>
<roleTypes description="This is the role type Broker" name="Broker">
<behaviors description="This is the behavior BrokerBehavior" name="BrokerBehavior"/>
</roleTypes>
@@ -22,11 +30,21 @@
</roleTypes>
<relationshipTypes description="Relationship between Broker and CreditAgency" name="BrokerToCreditAgencyRel" firstRoleType="//@typeDefinitions/(a)roleTypes.0" secondRoleType="//@typeDefinitions/(a)roleTypes.2"/>
<relationshipTypes description="Relationship between Buyer and Broker" name="BuyerToBrokerRel" firstRoleType="//@typeDefinitions/(a)roleTypes.1" secondRoleType="//@typeDefinitions/(a)roleTypes.0"/>
- <participantTypes description="This is the participant type Broker" name="Broker" roleTypes="//@typeDefinitions/(a)roleTypes.0"/>
- <participantTypes description="This is the participant type Buyer" name="Buyer" roleTypes="//@typeDefinitions/(a)roleTypes.1"/>
- <participantTypes description="This is the participant type CreditAgency" name="CreditAgency" roleTypes="//@typeDefinitions/(a)roleTypes.2"/>
- <channelTypes description="This is the channel type BrokerChannelType" name="BrokerChannelType" referenceToken="//@typeDefinitions/(a)tokens.0" roleType="//@typeDefinitions/(a)roleTypes.0"/>
- <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/(a)tokens.0" roleType="//@typeDefinitions/(a)roleTypes.2"/>
+ <participantTypes description="This is the participant type Broker" name="Broker" roleTypes="//@typeDefinitions/(a)roleTypes.0">
+ <semanticAnnotations annotation="jboss.overlord.samples.Purchasing@Broker" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type Buyer" name="Buyer" roleTypes="//@typeDefinitions/(a)roleTypes.1">
+ <semanticAnnotations annotation="jboss.overlord.samples.Purchasing@Buyer" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type CreditAgency" name="CreditAgency" roleTypes="//@typeDefinitions/(a)roleTypes.2">
+ <semanticAnnotations annotation="jboss.overlord.samples.Purchasing@CreditAgency" name="conversationType"/>
+ </participantTypes>
+ <channelTypes description="This is the channel type BrokerChannelType" name="BrokerChannelType" referenceToken="//@typeDefinitions/(a)tokens.1" roleType="//@typeDefinitions/(a)roleTypes.0">
+ <identities description="ID" tokens="//@typeDefinitions/(a)tokens.0"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/(a)tokens.1" roleType="//@typeDefinitions/(a)roleTypes.2">
+ <identities description="ID" tokens="//@typeDefinitions/(a)tokens.0"/>
+ </channelTypes>
</typeDefinitions>
<choreographies description="Choreography flow for the PurchaseGoods process" name="PurchaseGoodsProcess" root="true">
<variableDefinitions description="Channel to facilitate interaction to Broker" name="BrokerChannel" type="//@typeDefinitions/(a)channelTypes.0"/>
@@ -35,7 +53,7 @@
<exchangeDetails description="This is the exchange details for the request exchange associated with interaction BuyRequest" name="BuyRequestRequestExchange" type="//@typeDefinitions/(a)informationTypes.1"/>
</activities>
<activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckRequest" operation="checkCredit" channelVariable="//@choreographies.0/(a)variableDefinitions.1" relationship="//@typeDefinitions/(a)relationshipTypes.0">
- <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheckRequest" name="CreditCheckRequestRequestExchange" type="//@typeDefinitions/(a)informationTypes.4"/>
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheckRequest" name="CreditCheckRequestRequestExchange" type="//@typeDefinitions/(a)informationTypes.3"/>
</activities>
<activities xsi:type="org.pi4soa.cdl:Choice">
<activities xsi:type="org.pi4soa.cdl:Sequence">
@@ -48,7 +66,7 @@
</activities>
<activities xsi:type="org.pi4soa.cdl:Sequence">
<activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckFailed" operation="checkCredit" channelVariable="//@choreographies.0/(a)variableDefinitions.1" relationship="//@typeDefinitions/(a)relationshipTypes.0">
- <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckFailed" name="CreditCheckFailedRespondExchange" type="//@typeDefinitions/(a)informationTypes.3" action="Respond" faultName="CreditCheckFailed"/>
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckFailed" name="CreditCheckFailedRespondExchange" type="//@typeDefinitions/(a)informationTypes.4" action="Respond" faultName="CreditCheckFailed"/>
</activities>
<activities xsi:type="org.pi4soa.cdl:Interaction" name="BuyFailed" operation="buy" channelVariable="//@choreographies.0/(a)variableDefinitions.0" relationship="//@typeDefinitions/(a)relationshipTypes.1">
<exchangeDetails description="This is the exchange details for the respond exchange associated with interaction BuyFailed" name="BuyFailedRespondExchange" type="//@typeDefinitions/(a)informationTypes.0" action="Respond" faultName="BuyFailed"/>
15 years, 9 months
Overlord SVN: r216 - in cdl/trunk: runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation and 3 other directories.
by overlord-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2008-08-04 11:34:52 -0400 (Mon, 04 Aug 2008)
New Revision: 216
Modified:
cdl/trunk/pom.xml
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/EPRWrapper.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/Identity.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/JoinState.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/ScheduleItem.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/Session.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/SessionManager.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/util/HibernateUtil.java
cdl/trunk/samples/pom.xml
Log:
* Update the entity table names, update it to start with "CDL_".
Modified: cdl/trunk/pom.xml
===================================================================
--- cdl/trunk/pom.xml 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/pom.xml 2008-08-04 15:34:52 UTC (rev 216)
@@ -1,218 +1,229 @@
-<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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.soa.overlord</groupId>
- <artifactId>cdl</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>Overlord::CDL</name>
- <url>http://www.jboss.org/overlord</url>
- <description>
- JBoss Overlord.
- </description>
- <scm>
- <connection>scm:svn:https://svn.jboss.org/repos/soag/cdl/trunk</connection>
- </scm>
- <developers>
- <developer>
- <name>Jeff Yu</name>
- <id>jeff.yuchang</id>
- <email>cyu(a)redhat.com</email>
- <organization>Red Hat</organization>
- <roles>
- <role>Developer</role>
- </roles>
- <timezone>+8</timezone>
- </developer>
- </developers>
- <modules>
- <module>runtime</module>
- <module>samples</module>
- </modules>
-
- <properties>
- <overlord-version>1.0-SNAPSHOT</overlord-version>
- </properties>
-
- <profiles>
- <profile>
- <id>release</id>
- <modules>
- <module>docs</module>
- <module>docs/examples/gettingstarted</module>
- </modules>
- </profile>
- <profile>
- <!--
- This profile is activated when the "generate.docs" property is set,
- as in "mvn ... -Dgenerate.docs=true ..."
- -->
- <id>docs</id>
- <activation>
- <property>
- <name>generate.docs</name>
- </property>
- </activation>
- <modules>
- <module>docs</module>
- </modules>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <aggregate>true</aggregate>
- <show>public</show>
- <title>JBoss Overlord ${project.version}</title>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
- </profile>
- </profiles>
-
- <build>
- <!-- This section defines the default plugin settings inherited by child projects. -->
- <pluginManagement>
- <plugins>
- <!-- Fixes how test resources of a project can be used in projects dependent on it -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.2</version>
- <configuration>
- <aggregate>true</aggregate>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <!-- Specify the compiler options and settings -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- <showDeprecation>false</showDeprecation>
- <showWarnings>false</showWarnings>
- </configuration>
- </plugin>
- <!-- Produce source jars during the 'verify' phase -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>verify</phase>
- <goals>
- <goal>jar</goal>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/*TestCase.java</include>
- <include>**/*Test.java</include>
- </includes>
- </configuration>
- </plugin>
- <!--
- Build a test-jar for each project, so that src/test/* resources and classes can be used
- in other projects. Also customize how the jar files are assembled.
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <archive>
- <manifest>
- <addDefaultSpecificationEntries>
- true
- </addDefaultSpecificationEntries>
- <addDefaultImplementationEntries>
- true
- </addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Implementation-URL>
- ${pom.url}
- </Implementation-URL>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
-
- <repositories>
- <repository>
- <id>jboss</id>
- <url>http://repository.jboss.com/maven2/</url>
- </repository>
-
- <repository>
- <id>jboss-snapshot</id>
- <url>http://snapshots.jboss.org/maven2</url>
- </repository>
-
- <repository>
- <id>maven.repo</id>
- <name>maven repository</name>
- <url>http://repo1.maven.org/maven2</url>
- </repository>
-
- <repository>
- <id>ibiblio</id>
- <name>ibiblio repository</name>
- <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
- </repository>
-
- <repository>
- <id>codehaus</id>
- <name>codehaus repository</name>
- <url>http://repo1.maven.org/maven2</url>
- </repository>
-
- </repositories>
-
- <distributionManagement>
- <repository>
- <!-- Copy the distribution jar file to a local checkout of the maven repository
- - This variable can be set in $MAVEN_HOME/conf/settings.xml -->
- <id>repository.jboss.org</id>
- <url>file://${jboss.repository.root}</url>
- </repository>
- </distributionManagement>
-
-</project>
-
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.soa.overlord</groupId>
+ <artifactId>cdl</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Overlord::CDL</name>
+ <url>http://www.jboss.org/overlord</url>
+ <description>
+ JBoss Overlord.
+ </description>
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/soag/cdl/trunk</connection>
+ </scm>
+ <developers>
+ <developer>
+ <name>Jeff Yu</name>
+ <id>jeff.yuchang</id>
+ <email>cyu(a)redhat.com</email>
+ <organization>Red Hat</organization>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ <timezone>+8</timezone>
+ </developer>
+ <developer>
+ <name>Gary Brown</name>
+ <id>objectiser</id>
+ <email>gary.brown(a)hattricksoftware.com</email>
+ <organization>Hattrick Software</organization>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ <timezone>+1</timezone>
+ </developer>
+ </developers>
+ <modules>
+ <module>runtime</module>
+ <module>distribution/assembly</module>
+ <module>samples</module>
+ </modules>
+
+ <properties>
+ <overlord-version>1.0-SNAPSHOT</overlord-version>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>release</id>
+ <modules>
+ <module>docs</module>
+ <module>docs/examples/gettingstarted</module>
+ </modules>
+ </profile>
+ <profile>
+ <!--
+ This profile is activated when the "generate.docs" property is set,
+ as in "mvn ... -Dgenerate.docs=true ..."
+ -->
+ <id>docs</id>
+ <activation>
+ <property>
+ <name>generate.docs</name>
+ </property>
+ </activation>
+ <modules>
+ <module>docs</module>
+ </modules>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ <show>public</show>
+ <title>JBoss Overlord ${project.version}</title>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ </profile>
+ </profiles>
+
+ <build>
+ <!-- This section defines the default plugin settings inherited by child projects. -->
+ <pluginManagement>
+ <plugins>
+ <!-- Fixes how test resources of a project can be used in projects dependent on it -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <!-- Specify the compiler options and settings -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <showDeprecation>false</showDeprecation>
+ <showWarnings>false</showWarnings>
+ </configuration>
+ </plugin>
+ <!-- Produce source jars during the 'verify' phase -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar</goal>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <!--
+ Build a test-jar for each project, so that src/test/* resources and classes can be used
+ in other projects. Also customize how the jar files are assembled.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultSpecificationEntries>
+ true
+ </addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>
+ true
+ </addDefaultImplementationEntries>
+ </manifest>
+ <manifestEntries>
+ <Implementation-URL>
+ ${pom.url}
+ </Implementation-URL>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <repositories>
+ <repository>
+ <id>jboss</id>
+ <url>http://repository.jboss.com/maven2/</url>
+ </repository>
+
+ <repository>
+ <id>jboss-snapshot</id>
+ <url>http://snapshots.jboss.org/maven2</url>
+ </repository>
+
+ <repository>
+ <id>maven.repo</id>
+ <name>maven repository</name>
+ <url>http://repo1.maven.org/maven2</url>
+ </repository>
+
+ <repository>
+ <id>ibiblio</id>
+ <name>ibiblio repository</name>
+ <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
+ </repository>
+
+ <repository>
+ <id>codehaus</id>
+ <name>codehaus repository</name>
+ <url>http://repo1.maven.org/maven2</url>
+ </repository>
+
+ </repositories>
+
+ <distributionManagement>
+ <repository>
+ <!-- Copy the distribution jar file to a local checkout of the maven repository
+ - This variable can be set in $MAVEN_HOME/conf/settings.xml -->
+ <id>repository.jboss.org</id>
+ <url>file://${jboss.repository.root}</url>
+ </repository>
+ </distributionManagement>
+
+</project>
+
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/EPRWrapper.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/EPRWrapper.java 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/EPRWrapper.java 2008-08-04 15:34:52 UTC (rev 216)
@@ -35,7 +35,7 @@
*
*/
@Entity
-@Table(name="T_EPRS")
+@Table(name="CDL_EPRS")
public class EPRWrapper implements Serializable{
private static final long serialVersionUID = 1111L;
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/Identity.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/Identity.java 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/Identity.java 2008-08-04 15:34:52 UTC (rev 216)
@@ -41,7 +41,7 @@
@Entity
-@Table(name="T_IDENTITY")
+@Table(name="CDL_IDENTITY")
public class Identity implements HibernateObject {
private static final long serialVersionUID = 1112L;
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/JoinState.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/JoinState.java 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/JoinState.java 2008-08-04 15:34:52 UTC (rev 216)
@@ -32,7 +32,7 @@
*
*/
@Entity
-@Table(name="T_JOIN_STATES")
+@Table(name="CDL_JOIN_STATES")
public class JoinState implements HibernateObject {
private static final long serialVersionUID = 1113L;
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/ScheduleItem.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/ScheduleItem.java 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/ScheduleItem.java 2008-08-04 15:34:52 UTC (rev 216)
@@ -29,7 +29,7 @@
@Entity
-@Table(name="T_SCHEDULE_ITEM")
+@Table(name="CDL_SCHEDULE_ITEM")
public class ScheduleItem implements HibernateObject {
private static final long serialVersionUID = 1114L;
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/Session.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/Session.java 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/Session.java 2008-08-04 15:34:52 UTC (rev 216)
@@ -19,6 +19,10 @@
*/
package org.jboss.soa.overlord.conversation;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -30,6 +34,7 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@@ -42,7 +47,7 @@
import org.jboss.soa.esb.message.Message;
@Entity
-@Table(name="T_SESSION")
+@Table(name="CDL_SESSION")
public class Session implements HibernateObject {
private static final long serialVersionUID = 1115L;
@@ -80,9 +85,6 @@
@Column(name = "POJO_CLASS")
private String pojoClass;
- @Column(name = "POJO_ID")
- private long pojoID;
-
@Column(name="SERVICE_NAME")
private String serviceName;
@@ -92,6 +94,10 @@
@Transient
private Object businessObject;
+ @Lob
+ @Column(name="Business_OBJECT")
+ private byte[] serializedObject;
+
public Session() {
}
@@ -323,20 +329,24 @@
this.pojoClass = pojoClass;
}
- public long getPojoID() {
- return pojoID;
- }
-
- public void setPojoID(long pojoID) {
- this.pojoID = pojoID;
- }
-
public Object getBusinessObject() {
return businessObject;
}
public void setBusinessObject(Object businessObject) {
this.businessObject = businessObject;
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream out;
+
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(this.businessObject);
+ out.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Error in setting business object of " + businessObject, e);
+ }
+ this.serializedObject = bos.toByteArray();
}
public String getServiceName() {
@@ -371,6 +381,23 @@
this.joinStates = joinStates;
}
+ public byte[] getSerializedObject() {
+ return serializedObject;
+ }
+
+ public void setSerializedObject(byte[] serializedObject) {
+ this.serializedObject = serializedObject;
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(serializedObject);
+ try {
+ ObjectInputStream in = new ObjectInputStream(bais);
+ this.businessObject = in.readObject();
+ in.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Error in reading Object", e);
+ }
+ }
+
public String toString() {
StringBuffer sbuffer = new StringBuffer();
sbuffer.append("[ Session id: " + id);
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/SessionManager.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/SessionManager.java 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/SessionManager.java 2008-08-04 15:34:52 UTC (rev 216)
@@ -45,16 +45,11 @@
org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
Class<?> pojoclass= ClassLoaderUtil.loadClass(sessionName);
Object businessState = pojoclass.newInstance();
- hibernateSession.save(businessState);
Session conversationSession = new Session();
conversationSession.setPojoClass(sessionName);
conversationSession.setStatus(SessionStatus.Active);
- if (businessState instanceof HibernateObject) {
- HibernateObject ho = (HibernateObject) businessState;
- conversationSession.setPojoID(ho.getId());
- logger.debug("Set Business State Object ID : " + ho.getId());
- }
+
conversationSession.setBusinessObject(businessState);
Service service = pojoclass.getAnnotation(Service.class);
@@ -83,16 +78,9 @@
logger.info("bound to " + key);
}
- hibernateSession.save(businessState);
-
Session conversationSession = new Session();
conversationSession.setPojoClass(sessionName);
conversationSession.setStatus(SessionStatus.Active);
- if (businessState instanceof HibernateObject) {
- HibernateObject ho = (HibernateObject) businessState;
- conversationSession.setPojoID(ho.getId());
- logger.debug("Set Business State Object ID : " + ho.getId());
- }
conversationSession.setBusinessObject(businessState);
conversationSession.setParent(parentSession);
@@ -120,10 +108,6 @@
if (sessionKey != null) {
org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
Session session = (Session) hibernateSession.load(Session.class, Long.valueOf(sessionKey));
- Class<?> pojoClass = ClassLoaderUtil.loadClass(session.getPojoClass());
- Object pojo = hibernateSession.load(pojoClass, Long.valueOf(session.getPojoID()));
- session.setBusinessObject(pojo);
-
return session;
}
@@ -197,10 +181,6 @@
}
Session session = (Session)hibernateSession.load(Session.class, theID.getSession().getId());
- Class<?> pojoClass = ClassLoaderUtil.loadClass(session.getPojoClass());
- Object pojo = hibernateSession.load(pojoClass, Long.valueOf(session.getPojoID()));
- session.setBusinessObject(pojo);
-
logger.debug("Get Session of " + session + " by using identity of " + id);
return session;
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-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java 2008-08-04 15:34:52 UTC (rev 216)
@@ -55,11 +55,11 @@
while (variable.startsWith("parent.")) {
variable = variable.substring(7);
session = session.getParent();
- if (session.getPojoID() != 0) {
+/* if (session.getPojoID() != 0) {
Class<?> pojoClass = ClassLoaderUtil.loadClass(session.getPojoClass());
Object pojo = SessionManager.getObject(session.getPojoID(), pojoClass);
session.setBusinessObject(pojo);
- }
+ }*/
}
if (stateExpression != null) {
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/util/HibernateUtil.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/util/HibernateUtil.java 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/util/HibernateUtil.java 2008-08-04 15:34:52 UTC (rev 216)
@@ -23,7 +23,6 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Configuration;
/**
* @author jeffyu
@@ -37,8 +36,7 @@
static {
try {
- Configuration configuration = new AnnotationConfiguration().configure();
- sessionFactory = configuration.buildSessionFactory();
+ sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable t) {
throw new ExceptionInInitializerError(t);
}
Modified: cdl/trunk/samples/pom.xml
===================================================================
--- cdl/trunk/samples/pom.xml 2008-08-04 15:30:18 UTC (rev 215)
+++ cdl/trunk/samples/pom.xml 2008-08-04 15:34:52 UTC (rev 216)
@@ -24,8 +24,8 @@
<modules>
- <!--module>jbossesb/purchasing</module>
- <module>jbossesb/broker</module-->
+ <module>jbossesb/purchasing</module>
+ <module>jbossesb/creditAgency</module>
</modules>
<build>
15 years, 9 months