Author: objectiser
Date: 2008-07-01 11:14:17 -0400 (Tue, 01 Jul 2008)
New Revision: 95
Added:
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/DefaultESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.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/actions/UnsupportedAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestModelListener.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/.classpath
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/ESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java
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/ParallelAction.java
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/ReceiveMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/RetrieveSessionAction.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/actions/SetVariableAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.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/parser/JBossESBParser.java
Log:
First unit test for CreateSessionAction - refactored top level action, service and
language model components to be interfaces, to make unit testing easier.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/.classpath
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/.classpath 2008-07-01
11:15:18 UTC (rev 94)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/.classpath 2008-07-01
15:14:17 UTC (rev 95)
@@ -4,5 +4,6 @@
<classpathentry kind="src" path="src/test"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added:
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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBLanguageModel.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,339 @@
+/*
+ * 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;
+
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+
+/**
+ * This class represents an ESB model.
+ *
+ * @author gary
+ */
+public class DefaultESBLanguageModel extends org.scribble.lang.model.LanguageModel
+ implements ESBLanguageModel {
+
+ private static final String SERVICE_ELEMENT = "service";
+ private static final String SERVICES_ELEMENT = "services";
+
+ public static final String JBOSSESB_NOTATION = "jboss-esb.xml";
+
+ /**
+ * This constructor is initialized with the ESB configuration.
+ *
+ * @param source The model reference for the JBossESB configuration source
+ * @param elem The ESB configuration
+ * @param contents The textual contents
+ */
+ public DefaultESBLanguageModel(ModelReference source, org.w3c.dom.Element elem,
+ String contents) {
+ m_source = source;
+ m_esbConfig = elem;
+ m_contents = contents;
+
+ // Extract service action pipelines
+ initialize();
+ }
+
+ /**
+ * This method initializes the ESB Model.
+ */
+ protected void initialize() {
+ org.w3c.dom.NodeList services=
+ m_esbConfig.getElementsByTagName(SERVICES_ELEMENT);
+
+ org.scribble.model.DependencyManager dm=
+ (org.scribble.model.DependencyManager)
+ org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+ org.scribble.model.DependencyManager.class, null);
+
+ ModelName mname=new ModelName();
+ mname.setName(m_source.getLocalpart());
+
+ setModelName(mname);
+
+ Namespace ns=new Namespace();
+ ns.setName(m_source.getNamespace());
+ setNamespace(ns);
+
+ if (services != null && services.getLength() == 1 &&
+ services.item(0) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.NodeList nl=((org.w3c.dom.Element)
+ services.item(0)).getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getNodeName().equals(SERVICE_ELEMENT)) {
+
+ ESBService service=new DefaultESBService(this,
+ (org.w3c.dom.Element)nl.item(i));
+ String key=getKey(service.getCategory(),
+ service.getName());
+
+ m_services.put(key, service);
+ }
+ }
+
+ java.util.Iterator<ESBService> iter=m_services.values().iterator();
+
+ while (iter.hasNext()) {
+ iter.next().initializeLinks();
+ }
+
+ // Initialize the conversations
+ java.util.Iterator<ESBService> serviter=getServices().iterator();
+
+ while (serviter.hasNext()) {
+ ESBService service=serviter.next();
+
+ if (service.isRoot()) {
+ Conversation conv=new Conversation();
+
+ ModelName modelName=new ModelName();
+ modelName.setName(service.getServiceName());
+
+ conv.setModelName(modelName);
+
+ String convType=service.getConversationType();
+ if (convType != null) {
+ int index=convType.indexOf('@');
+
+ if (index != -1) {
+ // TODO: Need to think whether this should be
+ // 'implements' reference. If so, then need to change
+ // Java Lang Model parser and also Lang Model conformance
+ // rule.
+ ImplementsReference iref=
+ new ImplementsReference(ConversationModel.CONVERSATION);
+ //ConformanceReference iref=
+ // new ConformanceReference(ConversationModel.CONVERSATION);
+
+ iref.setLocatedRole(convType.substring(index+1));
+
+ // Need to locate the model name
+ modelName.setLocatedRole(new Role(iref.getLocatedRole()));
+
+ String mainpart=convType.substring(0, index);
+
+ index = mainpart.lastIndexOf(".");
+
+ if (index == -1) {
+ iref.setNamespace("");
+ iref.setLocalpart(mainpart);
+ } else {
+ iref.setNamespace(mainpart.substring(0, index));
+ iref.setLocalpart(mainpart.substring(index+1));
+ }
+
+ conv.getImplements().add(iref);
+ //conv.getConformsTo().add(iref);
+
+ dm.recordDependency(m_source, iref,
+ DependencyType.Implements);
+
+ } else {
+ logger.warning("Conversation type does not " +
+ "contain '@' located role separator");
+ }
+ } else {
+ logger.warning("No conversation type specified");
+ }
+
+ // TODO: Associate a conformance reference for the
+ // conversation type - when using Scribble dependency
+ // management, this will ensure appropriate validation
+ // when either the dependent conversation is changed, or
+ // the ESB config file changed.
+ //ConformanceReference confRef=new ConformanceReference();
+
+ //conv.getConformsTo().add(confRef);
+
+ conv.setBlock(new Block());
+
+ service.convert(conv.getBlock().getContents(),
+ new DefaultConversionContext());
+
+ getConversations().add(conv);
+ }
+ }
+ }
+
+ if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+
+ org.scribble.export.Exporter exporter=
+ (org.scribble.export.Exporter)
+ RegistryFactory.getRegistry().getExtension(
+ org.scribble.export.Exporter.class, null);
+
+ try {
+ for (int i=0; i < getConversations().size(); i++) {
+ ConversationModel model=new ConversationModel();
+
+ model.setConversation(getConversations().get(i));
+
+ org.scribble.export.text.TextFormatter formatter=
+ new org.scribble.export.text.TextFormatter();
+
+ java.io.ByteArrayOutputStream os=
+ new java.io.ByteArrayOutputStream();
+
+ formatter.setOutputStream(os);
+
+ exporter.export(model, formatter);
+
+ String str=new String(os.toByteArray());
+
+ System.out.println("EXPORTED JBOSS-ESB TEXT:");
+ System.out.println(str);
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public String getNotation() {
+ return(JBOSSESB_NOTATION);
+ }
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getModelReference() {
+ return(m_source);
+ }
+
+ /**
+ * Generate a key for use in accessing the service related to
+ * the supplied category and name.
+ *
+ * @param category The category
+ * @param name The service name
+ * @return The key
+ */
+ protected String getKey(String category, String name) {
+ return(category+"/"+name);
+ }
+
+ /**
+ * This method validates the ESB model and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+
+ java.util.Iterator<ESBService> iter=m_services.values().iterator();
+
+ while (iter.hasNext()) {
+ ESBService service=iter.next();
+
+ service.validate(l);
+ }
+ }
+
+ /**
+ * This method returns the ESB service for the supplied
+ * category and name.
+ *
+ * @param category The service category
+ * @param name The service name
+ * @return The ESB service, or null if not found
+ */
+ public ESBService getService(String category, String name) {
+ return(m_services.get(getKey(category, name)));
+ }
+
+ /**
+ * This method returns the collection of ESB services associated
+ * with the model.
+ *
+ * @return The collection of ESB services
+ */
+ public java.util.Collection<ESBService> getServices() {
+ return(m_services.values());
+ }
+
+ /**
+ * This textual contents of the model.
+ *
+ * @return The textual contents
+ */
+ public String getContents() {
+ return(m_contents);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
+
+ private ModelReference m_source=null;
+ private org.w3c.dom.Element m_esbConfig=null;
+ private String m_contents=null;
+ private java.util.Map<String,ESBService> m_services=new
java.util.Hashtable<String,ESBService>();
+
+ public class InnerModelListener implements ModelListener {
+
+ public InnerModelListener(ModelListener l) {
+ m_listener = l;
+ }
+
+ public void error(ModelObject src, String mesg, Properties props) {
+
+ if (props == null) {
+ props = new Properties();
+ }
+
+ props.put(ModelListener.RESOLUTIONS,
ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+ props.put(ModelListener.REFERENCE_MODEL, m_source);
+ props.put(ModelListener.REFERENCE_MODEL_START_POSITION,
src.getSource().getStartPosition());
+ props.put(ModelListener.REFERENCE_MODEL_END_POSITION,
src.getSource().getEndPosition());
+ if (src.getSource().getComponent() != null) {
+ props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
+ src.getSource().getComponent());
+ }
+
+ m_listener.error(src, mesg, props);
+ }
+
+ public void warning(ModelObject src, String mesg, Properties props) {
+ if (props == null) {
+ props = new Properties();
+ }
+
+ props.put(ModelListener.RESOLUTIONS,
ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+ props.put(ModelListener.REFERENCE_MODEL, m_source);
+ props.put(ModelListener.REFERENCE_MODEL_START_POSITION,
src.getSource().getStartPosition());
+ props.put(ModelListener.REFERENCE_MODEL_END_POSITION,
src.getSource().getEndPosition());
+ if (src.getSource().getComponent() != null) {
+ props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
+ src.getSource().getComponent());
+ }
+
+ m_listener.warning(src, mesg, props);
+ }
+
+ private ModelListener m_listener=null;
+ }
+}
Added:
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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/DefaultESBService.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,604 @@
+/*
+ * 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;
+
+import java.util.logging.Logger;
+
+import org.eclipse.jdt.core.*;
+import org.eclipse.core.resources.*;
+
+// TODO: Need to find alternative to JavaModel
+import org.eclipse.jdt.internal.core.*;
+
+import org.scribble.model.*;
+import org.scribble.osgi.model.*;
+
+/**
+ * This class represents an ESB service.
+ *
+ * @author gary
+ */
+public class DefaultESBService extends ModelObject implements ESBService {
+
+ private static final String SERVICE_ELEMENT = "service";
+ private static final String SERVICE_NAME_PROPERTY = "serviceName";
+ private static final String ROOT_PROPERTY = "root";
+ private static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
+ private static final String CONVERSATION_TYPE_PROPERTY = "conversationType";
+ private static final String ACTION_PACKAGE =
"org.jboss.soa.overlord.jbossesb.actions.";
+ private static final String CREATE_SESSION_ACTION_CLASS =
"org.jboss.soa.overlord.jbossesb.actions.CreateSessionAction";
+ private static final String RETRIEVE_SESSION_ACTION_CLASS =
"org.jboss.soa.overlord.jbossesb.actions.RetrieveSessionAction";
+ private static final String ACTION_ELEMENT = "action";
+ private static final String ACTIONS_ELEMENT = "actions";
+
+ /**
+ * This is the constructor for the ESB service.
+ *
+ * @param model The ESB model in which the service has been defined
+ * @param service The XML configuration of the service
+ */
+ public DefaultESBService(ESBLanguageModel model, org.w3c.dom.Element service) {
+ m_model = model;
+ m_service = service;
+
+ if (m_model != null && m_service != null) {
+ initialize();
+ }
+ }
+
+ /**
+ * This method initializes the service.
+ */
+ protected void initialize() {
+ // Check if relevant action
+ org.w3c.dom.NodeList actions=m_service.getElementsByTagName(ACTIONS_ELEMENT);
+
+ if (actions != null && actions.getLength() == 1 &&
+ actions.item(0) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.NodeList nl=((org.w3c.dom.Element)
+ actions.item(0)).getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getNodeName().equals(ACTION_ELEMENT)) {
+ m_actions.add(ESBActionFactory.createAction(this,
+ ((org.w3c.dom.Element)nl.item(i))));
+ }
+ }
+ }
+
+ // Find positional information
+ int servCount=getServicePosition();
+
+ String str=getModel().getContents();
+
+ int startPosition=str.indexOf("<service ");
+ int endPosition=-1;
+
+ while (startPosition != -1 && servCount > 0) {
+ servCount--;
+
+ endPosition = str.indexOf("</service>", startPosition);
+
+ if (servCount > 0) {
+ startPosition=str.indexOf("<service ", endPosition);
+ }
+ }
+
+ if (startPosition != -1) {
+ endPosition = str.indexOf("</service>", startPosition);
+
+ getSource().setStartPosition(startPosition);
+ getSource().setEndPosition(endPosition);
+ }
+ }
+
+ /**
+ * This method initializes the links.
+ */
+ public void initializeLinks() {
+
+ // Work through actions requesting them to
+ // establish their links
+ for (int i=0; i < m_actions.size(); i++) {
+ m_actions.get(i).initializeLinks();
+ }
+ }
+
+ /**
+ * This method validates the ESB service and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+
+ // Check that the service specifies a session
+ if (isSessionBased() && getSessionClass() == null) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_SESSION_CLASS",
+ new String[]{}), null);
+ }
+
+ for (int i=0; i < m_actions.size(); i++) {
+ m_actions.get(i).validate(l);
+ }
+ }
+
+ /**
+ * This method returns the ESB model.
+ *
+ * @return The ESB model
+ */
+ public ESBLanguageModel getModel() {
+ return(m_model);
+ }
+
+ /**
+ * This method returns the category associated with the service
+ * descriptor.
+ *
+ * @return The service category
+ */
+ public String getCategory() {
+ return(m_service.getAttribute("category"));
+ }
+
+ /**
+ * This method returns the name associated with the service
+ * descriptor.
+ *
+ * @return The service name
+ */
+ public String getName() {
+ return(m_service.getAttribute("name"));
+ }
+
+ /**
+ * This method returns the XML configuration representation of the service.
+ *
+ * @return The XML configuration for the service
+ */
+ public org.w3c.dom.Element getService() {
+ return(m_service);
+ }
+
+ /**
+ * This method returns the list of ESB actions.
+ *
+ * @return The ESB actions
+ */
+ public java.util.List<ESBAction> getActions() {
+ return(m_actions);
+ }
+
+ protected java.lang.annotation.Annotation getServiceAnnotation(String session) {
+ java.lang.annotation.Annotation ret=null;
+
+ try {
+ ClassLoader cl=getServiceClassLoader();
+
+ Class<?> cls=Class.forName(session, true, cl);
+
+ // TODO: This should be replaced by direct lookup
+ // of Service annotation - but library not available
+ // at the moment
+ java.lang.annotation.Annotation[] annotations=
+ cls.getAnnotations();
+ for (int i=0; ret == null &&
+ i < annotations.length; i++) {
+ try {
+ if (annotations[i].annotationType().getName().equals(
+ "org.jboss.soa.overlord.jbossesb.actions.Service")) {
+ ret = annotations[i];
+ }
+ } catch(Throwable ex) {
+ // Ignore
+ System.err.println("ANNOTATION: "+annotations[i].annotationType());
+ ex.printStackTrace();
+ }
+ }
+
+ } catch(Exception e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get session class '"+session+"'", e);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the ESB service represents a
+ * loop construct.
+ *
+ * @return Whether the service represents a loop
+ */
+ public boolean isLoop() {
+ boolean ret=false;
+
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null) {
+ ret = action.isLoop();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the ESB service descriptor represents
+ * a 'root' conversation.
+ *
+ * @return Whether the ESB service is associated with a root conversation
+ */
+ public boolean isRoot() {
+ boolean ret=false;
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null && action.getActionClass() != null) {
+ if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
+ String bool=action.getPropertyValue(ROOT_PROPERTY);
+ if (bool != null) {
+ ret = bool.equalsIgnoreCase("true");
+ } else {
+ String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+
+ java.lang.annotation.Annotation annotation=
+ getServiceAnnotation(session);
+
+ if (annotation != null) {
+ try {
+ java.lang.reflect.Method method=
+ annotation.getClass().getMethod("root", (Class<?>[])null);
+
+ Object val=method.invoke(annotation, (Object[])null);
+
+ if (val instanceof Boolean) {
+ ret = ((Boolean)val).booleanValue();
+ }
+ } catch(Throwable t) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get 'root' annotation value", t);
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the service description name associated with the
+ * ESB service.
+ *
+ * @return The service description name
+ */
+ public String getServiceName() {
+ String ret=null;
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null) {
+ if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS) ||
+ action.getActionClass().equals(RETRIEVE_SESSION_ACTION_CLASS)) {
+ ret = action.getPropertyValue(SERVICE_NAME_PROPERTY);
+
+ if (ret == null) {
+ String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+
+ java.lang.annotation.Annotation annotation=
+ getServiceAnnotation(session);
+
+ if (annotation != null) {
+ try {
+ java.lang.reflect.Method method=
+ annotation.getClass().getMethod("name", (Class<?>[])null);
+
+ Object val=method.invoke(annotation, (Object[])null);
+
+ if (val instanceof String) {
+ ret = (String)val;
+ }
+ } catch(Throwable t) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get 'name' annotation value", t);
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the conversation type associated with the
+ * ESB service.
+ *
+ * @return The conversation type
+ */
+ public String getConversationType() {
+ String ret=null;
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null) {
+ if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
+ ret = action.getPropertyValue(CONVERSATION_TYPE_PROPERTY);
+
+ if (ret == null) {
+ String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+
+ java.lang.annotation.Annotation annotation=
+ getServiceAnnotation(session);
+
+ if (annotation != null) {
+ try {
+ java.lang.reflect.Method method=
+ annotation.getClass().getMethod("conversationType",
(Class<?>[])null);
+
+ Object val=method.invoke(annotation, (Object[])null);
+
+ if (val instanceof String) {
+ ret = (String)val;
+ }
+ } catch(Throwable t) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get 'name' annotation value", t);
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the session name associated with the service
+ * descriptor.
+ *
+ * @return The session name
+ */
+ public String getSessionName() {
+ String ret=null;
+ ESBAction action=null;
+
+ for (int i=0; action == null && i < m_actions.size(); i++) {
+ action=m_actions.get(i);
+
+ if (action.isSessionBased() == false) {
+ action = null;
+ }
+ }
+
+ if (action != null &&
+ action.getActionClass().startsWith(ACTION_PACKAGE)) {
+ ret = action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the session class associated with the service
+ * descriptor.
+ *
+ * @return The session class
+ */
+ public Class<?> getSessionClass() {
+ Class<?> ret=null;
+ String session=getSessionName();
+
+ if (session != null) {
+ try {
+ ClassLoader cl=getServiceClassLoader();
+
+ ret = Class.forName(session, true, cl);
+
+ } catch(Exception e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to get session class '"+session+"'", e);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the service is related to a behavioural
+ * session.
+ *
+ * @return Whether the service is session based
+ */
+ public boolean isSessionBased() {
+ boolean ret=false;
+
+ for (int i=0; ret == false && i < m_actions.size(); i++) {
+ ret = m_actions.get(i).isSessionBased();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method converts the actions associated with the ESB service into
+ * activities that can be checked for conformance against a conversation
+ * type.
+ *
+ * @param activities The target list of activities associated with the
+ * ESB actions being converted
+ * @param context The conversion context
+ */
+ public void convert(java.util.List<Activity> activities,
+ ConversionContext context) {
+
+ context.processing(this);
+
+ for (int i=0; i < m_actions.size(); i++) {
+ ((ESBAction)m_actions.get(i)).convert(activities, context);
+ }
+
+ context.processed(this);
+ }
+
+ /**
+ * This method returns the position of the service node within the
+ * ESB configuration.
+ *
+ * @return The service node position
+ */
+ public int getServicePosition() {
+ org.w3c.dom.Node services=m_service.getParentNode();
+ int servCount=0;
+ boolean f_end=false;
+
+ for (int i=0; f_end == false &&
+ i < services.getChildNodes().getLength(); i++) {
+ org.w3c.dom.Node serv=services.getChildNodes().item(i);
+
+ if (serv.getNodeName().equals(SERVICE_ELEMENT)) {
+ servCount++;
+ if (serv == m_service) {
+ f_end = true;
+ }
+ }
+ }
+
+ return(servCount);
+ }
+
+ /**
+ * This method returns a custom classloader that uses the project's
+ * classpath to locate classes referenced by the ESB config file.
+ *
+ * @see
http://dev.eclipse.org/newslists/news.eclipse.tools.jdt/msg17769.html
+ *
+ * @return The classloader
+ * @throws Exception Failed to obtain the classloader
+ */
+ public ClassLoader getServiceClassLoader() throws Exception {
+ java.net.URLClassLoader classLoader=null;
+ IFile file=OSGIModelRepository.getFile(getModel().getModelReference());
+
+ if (file != null) {
+ IJavaProject javaProject=JavaCore.create(file.getProject());
+ IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
+ String wsPath = javaProject.getProject().getLocation().toPortableString();
+ String firstEntryLocation = javaProject.getPath().toPortableString();
+ int idx = wsPath.indexOf(firstEntryLocation);
+ wsPath = wsPath.substring(0,idx);
+
+ String fullPath = null;
+
+ java.net.URL[] urls = new java.net.URL[entries.length+1];
+ int i = 0;
+ urls[i++] = new java.io.File(wsPath +
+ javaProject.getOutputLocation().toPortableString()).toURL();
+
+ for (IClasspathEntry entry : entries) {
+ if(entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+ IResource project =
+ ResourcesPlugin.getWorkspace().getRoot().findMember(entry.getPath());
+ String projectPath =
+ JavaCore.create(project.getProject()).getOutputLocation().toPortableString();
+ fullPath = wsPath + projectPath;
+ } else {
+ // TODO: Need to find alternative to this internal class (JavaModel)
+ Object resource =
+ JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(),entry.getPath(),true);
+
+ if (resource instanceof IResource) {
+ IResource iFile = (IResource) resource;
+ fullPath = iFile.getLocation().toPortableString();
+ } else if (resource instanceof java.io.File) {
+ java.io.File resfile = (java.io.File) resource;
+ fullPath = resfile.getAbsolutePath();
+ }
+ }
+
+ urls[i++] = new java.io.File(fullPath).toURL();
+ }
+
+ classLoader = new java.net.URLClassLoader(urls,String.class.getClassLoader());
+ }
+
+ return(classLoader);
+ }
+
+ public int hashCode() {
+ return(m_service.hashCode());
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof DefaultESBService) {
+ DefaultESBService other=(DefaultESBService)obj;
+
+ if (m_service == other.m_service) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ public String toString() {
+ return("ESBService:
"+getCategory()+"/"+getName()+"["+getSource()+"]");
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
+
+ private ESBLanguageModel m_model=null;
+ private org.w3c.dom.Element m_service=null;
+ private java.util.List<ESBAction> m_actions=new
java.util.Vector<ESBAction>();
+}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -1,343 +0,0 @@
-/*
- * 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;
-
-import java.util.logging.Logger;
-
-import org.scribble.model.*;
-
-/**
- * This is the generic ESB action class.
- *
- * @author gary
- */
-public abstract class ESBAction extends ModelObject {
-
- private static final String ACTION_ELEMENT = "action";
- //private static final String SERVICE_ELEMENT = "service";
- private static final String VALUE_ATTR = "value";
- private static final String NAME_ATTR = "name";
- private static final String PROPERTY_ELEMENT = "property";
- private static final String CLASS_PROPERTY = "class";
-
- protected static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
-
- /**
- * The default constructor.
- */
- protected ESBAction() {
- }
-
- /**
- * This method initializes the action.
- *
- * @param service The reference to the service in which
- * the action is contained
- * @param action The XML configuration details for the action
- */
- protected void init(ESBService service,
- org.w3c.dom.Element action) {
- m_service = service;
- m_action = action;
-
- // Find positional information
- int servCount=m_service.getServicePosition();
- int actionCount=getActionPosition();
-
- String str=m_service.getModel().getContents();
-
- int startPosition=str.indexOf("<service ");
- int endPosition=-1;
-
- while (startPosition != -1 && servCount > 0) {
- servCount--;
-
- endPosition = str.indexOf("</service>", startPosition);
-
- if (servCount > 0) {
- startPosition=str.indexOf("<service ", endPosition);
- }
- }
-
- if (actionCount > 0 &&
- startPosition != -1 && endPosition != -1) {
- startPosition=str.indexOf("<action ", startPosition);
- endPosition=-1;
-
- while (startPosition != -1 && actionCount > 0) {
- actionCount--;
-
- endPosition = str.indexOf("</action>", startPosition);
-
- if (actionCount > 0) {
- startPosition=str.indexOf("<action ", endPosition);
- }
- }
- }
-
- getSource().setStartPosition(startPosition);
- getSource().setEndPosition(endPosition);
- }
-
- /**
- * This method initializes the links with the ESB service descriptors
- * identified in each path of the action.
- */
- protected void initializeLinks() {
- }
-
- /**
- * This method validates the ESB action and reports warnings or
- * errors to the supplied model listener.
- *
- * @param l The model listener
- */
- public void validate(ModelListener l) {
-
- String[] mandatory=getMandatoryProperties();
-
- for (int i=0; i < mandatory.length; i++) {
- if (getPropertyValue(mandatory[i]) == null) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_NOT_SPECIFIED_PROPERTY",
- new String[]{mandatory[i]}), null);
- }
- }
-
- String session=getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
-
- if (session != null) {
- // Validate that the business object type exists
- try {
- ClassLoader cl=getService().getProjectLoader();
-
- try {
- Class.forName(session, true, cl);
- } catch(ClassNotFoundException cfne) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_NOT_FOUND_BUSINESS_OBJECT_TYPE",
- new String[]{session}), null);
- }
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to load business class '"+session+"'", e);
- }
- }
-
- // Validate links
- for (int i=0; i < m_links.size(); i++) {
- ESBLink link=(ESBLink)m_links.get(i);
-
- if (link.getService() == null) {
- // If target service not found, then report error
- // unless it is a remote service, so defined in a
- // different file
- if (link.isRemote() == false) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_NOT_FOUND_SERVICE_DESCRIPTOR",
- new String[]{link.getCategory(),link.getName()}), null);
- }
- } else if (getService().getSessionName() != null &&
- isPerform() == false &&
- getService().getSessionName().equals(
- link.getService().getSessionName()) == false) {
-
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_MISMATCH_SESSION_CLASS",
- new String[]{link.getCategory(),link.getName()}), null);
- }
- }
- }
-
- /**
- * This method determines if the action represents a loop construct.
- *
- * @return Whether the action represents a loop construct
- */
- public boolean isLoop() {
- return(false);
- }
-
- /**
- * This method determines whether the action is related to a behavioural
- * session.
- *
- * @return Whether the action is session based
- */
- public boolean isSessionBased() {
- return(true);
- }
-
- /**
- * This method indicates whether this action performs another
- * sub-conversation.
- *
- * @return Whether the action is a 'perform'
- */
- public boolean isPerform() {
- return(false);
- }
-
- /**
- * This method returns the mandatory property names.
- *
- * @return The mandatory property names
- */
- protected String[] getMandatoryProperties() {
- return(new String[0]);
- }
-
- /**
- * This method returns the action's class name.
- *
- * @return The action's class name
- */
- public String getActionClass() {
- return(m_action.getAttribute(CLASS_PROPERTY));
- }
-
- /**
- * This method returns the property value associated
- * with the supplied name.
- *
- * @param property The property name
- * @return The property value, or null if not found
- */
- public String getPropertyValue(String property) {
- String ret=null;
-
- org.w3c.dom.NodeList nl=m_action.getChildNodes();
-
- for (int i=0; ret == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
- ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
- equals(property)) {
- ret = ((org.w3c.dom.Element)nl.item(i)).getAttribute(VALUE_ATTR);
- }
- }
-
- return(ret);
- }
-
- /**
- * This method returns the 'property' child nodes, associated with the
- * supplied property name, within the action configuration.
- *
- * @param property The property name
- * @return The list of child nodes
- */
- public org.w3c.dom.NodeList getPropertyChildNodes(String property) {
- org.w3c.dom.NodeList ret=null;
-
- org.w3c.dom.NodeList nl=m_action.getChildNodes();
-
- for (int i=0; ret == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
- ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
- equals(property)) {
- ret = ((org.w3c.dom.Element)nl.item(i)).getChildNodes();
- }
- }
-
- return(ret);
- }
-
- /**
- * This method returns the reference to the service that contains the
- * action.
- *
- * @return The service
- */
- protected ESBService getService() {
- return(m_service);
- }
-
- /**
- * This method returns the XML configuration representation of the action.
- *
- * @return The XML configuration for the action
- */
- public org.w3c.dom.Element getAction() {
- return(m_action);
- }
-
- /**
- * This method returns the list of links established by this action.
- *
- * @return The list of links
- */
- protected java.util.List<ESBLink> getLinks() {
- return(m_links);
- }
-
- /**
- * This method converts the ESB action into an equivalent
- * behavioural description for conformance checking.
- *
- * @param activities The list of activities that will contain
- * the converted action(s)
- * @param context The conversion context
- */
- public abstract void convert(java.util.List<Activity> activities,
- ConversionContext context);
-
- /**
- * This method returns the node position of the action configuration
- * within the service descriptor.
- *
- * @return The action position
- */
- protected int getActionPosition() {
- org.w3c.dom.Element service=(org.w3c.dom.Element)
- getAction().getParentNode().getParentNode();
-
- int actionCount=0;
- boolean f_end=false;
-
- org.w3c.dom.NodeList acts=service.getElementsByTagName(ACTION_ELEMENT);
-
- for (int i=0; f_end == false &&
- i < acts.getLength(); i++) {
- org.w3c.dom.Node act=acts.item(i);
-
- actionCount++;
- if (act == getAction()) {
- f_end = true;
- }
- }
-
- return(actionCount);
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
-
- private ESBService m_service=null;
- private org.w3c.dom.Element m_action=null;
- private java.util.List<ESBLink> m_links=new java.util.Vector<ESBLink>();
-}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents the generic ESB action class.
+ *
+ * @author gary
+ */
+public interface ESBAction {
+
+ /**
+ * This method initializes the links with the ESB service descriptors
+ * identified in each path of the action.
+ */
+ public void initializeLinks();
+
+ /**
+ * This method validates the ESB action and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l);
+
+ /**
+ * This method determines if the action represents a loop construct.
+ *
+ * @return Whether the action represents a loop construct
+ */
+ public boolean isLoop();
+
+ /**
+ * This method determines whether the action is related to a behavioural
+ * session.
+ *
+ * @return Whether the action is session based
+ */
+ public boolean isSessionBased();
+
+ /**
+ * This method indicates whether this action performs another
+ * sub-conversation.
+ *
+ * @return Whether the action is a 'perform'
+ */
+ public boolean isPerform();
+
+ /**
+ * This method returns the action's class name.
+ *
+ * @return The action's class name
+ */
+ public String getActionClass();
+
+ /**
+ * This method returns the property value associated
+ * with the supplied name.
+ *
+ * @param property The property name
+ * @return The property value, or null if not found
+ */
+ public String getPropertyValue(String property);
+
+ /**
+ * This method returns the XML configuration representation of the action.
+ *
+ * @return The XML configuration for the action
+ */
+ public org.w3c.dom.Element getAction();
+
+ /**
+ * This method converts the ESB action into an equivalent
+ * behavioural description for conformance checking.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ public void convert(java.util.List<Activity> activities,
+ ConversionContext context);
+
+}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -1,81 +0,0 @@
-/*
- * 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;
-
-import java.util.logging.Logger;
-
-/**
- * This class provides a factory for ESBAction instances.
- *
- * @author gary
- */
-public class ESBActionFactory {
-
- private static final String MODEL_ACTION_PACKAGE =
- "org.jboss.tools.overlord.jbossesb.model.actions";
- private static final String CLASS_ATTR = "class";
- private static final String CONVERSATION_ACTION_PACKAGE =
- "org.jboss.soa.overlord.jbossesb.actions";
-
- /**
- * This method creates an ESBAction instance relevant to the
- * supplied JBossESB action, associated with the supplied
- * service.
- *
- * @param service The service
- * @param action The XML configuration of the action
- * @return The ESBAction instance
- */
- public static ESBAction createAction(ESBService service,
- org.w3c.dom.Element action) {
- ESBAction ret=null;
- String actionType=action.getAttribute(CLASS_ATTR);
-
- // Check that it is a conversation based ESB action
- if (actionType.startsWith(CONVERSATION_ACTION_PACKAGE)) {
- int index=actionType.lastIndexOf('.');
- if (index != -1) {
- String actionName=actionType.substring(index+1);
-
- try {
- Class<?> cls=(Class<?>)
- Class.forName(MODEL_ACTION_PACKAGE+"."+actionName);
-
- ret = (ESBAction)cls.newInstance();
-
- ret.init(service, action);
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Unable to find action class '"+
- MODEL_ACTION_PACKAGE+"."+actionName+"'", e);
- }
- }
- }
-
- if (ret == null) {
- // Unrecognised or unsupported action
- ret = new UnsupportedAction();
- ret.init(service, action);
- }
-
- return(ret);
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
-}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBActionFactory.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,84 @@
+/*
+ * 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;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.jbossesb.model.actions.UnsupportedAction;
+
+/**
+ * This class provides a factory for ESBAction instances.
+ *
+ * @author gary
+ */
+public class ESBActionFactory {
+
+ private static final String MODEL_ACTION_PACKAGE =
+ "org.jboss.tools.overlord.jbossesb.model.actions";
+ private static final String CLASS_ATTR = "class";
+ private static final String CONVERSATION_ACTION_PACKAGE =
+ "org.jboss.soa.overlord.jbossesb.actions";
+
+ /**
+ * This method creates an ESBAction instance relevant to the
+ * supplied JBossESB action, associated with the supplied
+ * service.
+ *
+ * @param service The service
+ * @param action The XML configuration of the action
+ * @return The ESBAction instance
+ */
+ public static ESBAction createAction(ESBService service,
+ org.w3c.dom.Element action) {
+ ESBAction ret=null;
+ String actionType=action.getAttribute(CLASS_ATTR);
+
+ // Check that it is a conversation based ESB action
+ if (actionType.startsWith(CONVERSATION_ACTION_PACKAGE)) {
+ int index=actionType.lastIndexOf('.');
+ if (index != -1) {
+ String actionName=actionType.substring(index+1);
+
+ try {
+ Class<?> cls=(Class<?>)
+ Class.forName(MODEL_ACTION_PACKAGE+"."+actionName);
+
+ java.lang.reflect.Constructor<?> con=
+ cls.getConstructor(new Class<?>[]{ESBService.class,
+ org.w3c.dom.Element.class});
+
+ ret = (ESBAction)con.newInstance(new Object[]{service, action});
+
+ } catch(Exception e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Unable to find action class '"+
+ MODEL_ACTION_PACKAGE+"."+actionName+"'", e);
+ }
+ }
+ }
+
+ if (ret == null) {
+ // Unrecognised or unsupported action
+ ret = new UnsupportedAction(service, action);
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
+}
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBLanguageModel.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,11 +17,6 @@
*/
package org.jboss.tools.overlord.jbossesb.model;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryFactory;
import org.scribble.model.*;
/**
@@ -29,232 +24,26 @@
*
* @author gary
*/
-public class ESBLanguageModel extends org.scribble.lang.model.LanguageModel {
+public interface ESBLanguageModel {
- private static final String SERVICE_ELEMENT = "service";
- private static final String SERVICES_ELEMENT = "services";
-
public static final String JBOSSESB_NOTATION = "jboss-esb.xml";
/**
- * This constructor is initialized with the ESB configuration.
+ * This method validates the ESB model and reports warnings or
+ * errors to the supplied model listener.
*
- * @param source The model reference for the JBossESB configuration source
- * @param elem The ESB configuration
- * @param contents The textual contents
+ * @param l The model listener
*/
- public ESBLanguageModel(ModelReference source, org.w3c.dom.Element elem,
- String contents) {
- m_source = source;
- m_esbConfig = elem;
- m_contents = contents;
-
- // Extract service action pipelines
- initialize();
- }
+ public void validate(ModelListener l);
/**
- * This method initializes the ESB Model.
- */
- protected void initialize() {
- org.w3c.dom.NodeList services=
- m_esbConfig.getElementsByTagName(SERVICES_ELEMENT);
-
- org.scribble.model.DependencyManager dm=
- (org.scribble.model.DependencyManager)
- org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
- org.scribble.model.DependencyManager.class, null);
-
- ModelName mname=new ModelName();
- mname.setName(m_source.getLocalpart());
-
- setModelName(mname);
-
- Namespace ns=new Namespace();
- ns.setName(m_source.getNamespace());
- setNamespace(ns);
-
- if (services != null && services.getLength() == 1 &&
- services.item(0) instanceof org.w3c.dom.Element) {
- org.w3c.dom.NodeList nl=((org.w3c.dom.Element)
- services.item(0)).getChildNodes();
-
- for (int i=0; i < nl.getLength(); i++) {
-
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(SERVICE_ELEMENT)) {
-
- ESBService service=new ESBService(this,
- (org.w3c.dom.Element)nl.item(i));
- String key=getKey(service.getCategory(),
- service.getName());
-
- m_services.put(key, service);
- }
- }
-
- java.util.Iterator<ESBService> iter=m_services.values().iterator();
-
- while (iter.hasNext()) {
- iter.next().initializeLinks();
- }
-
- // Initialize the conversations
- java.util.Iterator<ESBService> serviter=getServices().iterator();
-
- while (serviter.hasNext()) {
- ESBService service=serviter.next();
-
- if (service.isRoot()) {
- Conversation conv=new Conversation();
-
- ModelName modelName=new ModelName();
- modelName.setName(service.getServiceName());
-
- conv.setModelName(modelName);
-
- String convType=service.getConversationType();
- if (convType != null) {
- int index=convType.indexOf('@');
-
- if (index != -1) {
- // TODO: Need to think whether this should be
- // 'implements' reference. If so, then need to change
- // Java Lang Model parser and also Lang Model conformance
- // rule.
- ImplementsReference iref=
- new ImplementsReference(ConversationModel.CONVERSATION);
- //ConformanceReference iref=
- // new ConformanceReference(ConversationModel.CONVERSATION);
-
- iref.setLocatedRole(convType.substring(index+1));
-
- // Need to locate the model name
- modelName.setLocatedRole(new Role(iref.getLocatedRole()));
-
- String mainpart=convType.substring(0, index);
-
- index = mainpart.lastIndexOf(".");
-
- if (index == -1) {
- iref.setNamespace("");
- iref.setLocalpart(mainpart);
- } else {
- iref.setNamespace(mainpart.substring(0, index));
- iref.setLocalpart(mainpart.substring(index+1));
- }
-
- conv.getImplements().add(iref);
- //conv.getConformsTo().add(iref);
-
- dm.recordDependency(m_source, iref,
- DependencyType.Implements);
-
- } else {
- logger.warning("Conversation type does not " +
- "contain '@' located role separator");
- }
- } else {
- logger.warning("No conversation type specified");
- }
-
- // TODO: Associate a conformance reference for the
- // conversation type - when using Scribble dependency
- // management, this will ensure appropriate validation
- // when either the dependent conversation is changed, or
- // the ESB config file changed.
- //ConformanceReference confRef=new ConformanceReference();
-
- //conv.getConformsTo().add(confRef);
-
- conv.setBlock(new Block());
-
- service.convert(conv.getBlock().getContents(),
- new DefaultConversionContext());
-
- getConversations().add(conv);
- }
- }
- }
-
- if (logger.isLoggable(java.util.logging.Level.FINEST)) {
-
- org.scribble.export.Exporter exporter=
- (org.scribble.export.Exporter)
- RegistryFactory.getRegistry().getExtension(
- org.scribble.export.Exporter.class, null);
-
- try {
- for (int i=0; i < getConversations().size(); i++) {
- ConversationModel model=new ConversationModel();
-
- model.setConversation(getConversations().get(i));
-
- org.scribble.export.text.TextFormatter formatter=
- new org.scribble.export.text.TextFormatter();
-
- java.io.ByteArrayOutputStream os=
- new java.io.ByteArrayOutputStream();
-
- formatter.setOutputStream(os);
-
- exporter.export(model, formatter);
-
- String str=new String(os.toByteArray());
-
- System.out.println("EXPORTED JBOSS-ESB TEXT:");
- System.out.println(str);
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public String getNotation() {
- return(JBOSSESB_NOTATION);
- }
-
- /**
* This method returns the source model reference.
*
* @return The source model reference
*/
- public ModelReference getModelReference() {
- return(m_source);
- }
+ public ModelReference getModelReference();
/**
- * Generate a key for use in accessing the service related to
- * the supplied category and name.
- *
- * @param category The category
- * @param name The service name
- * @return The key
- */
- protected String getKey(String category, String name) {
- return(category+"/"+name);
- }
-
- /**
- * This method validates the ESB model and reports warnings or
- * errors to the supplied model listener.
- *
- * @param l The model listener
- */
- public void validate(ModelListener l) {
-
- java.util.Iterator<ESBService> iter=m_services.values().iterator();
-
- while (iter.hasNext()) {
- ESBService service=iter.next();
-
- service.validate(l);
- }
- }
-
- /**
* This method returns the ESB service for the supplied
* category and name.
*
@@ -262,9 +51,7 @@
* @param name The service name
* @return The ESB service, or null if not found
*/
- public ESBService getService(String category, String name) {
- return(m_services.get(getKey(category, name)));
- }
+ public ESBService getService(String category, String name);
/**
* This method returns the collection of ESB services associated
@@ -272,67 +59,13 @@
*
* @return The collection of ESB services
*/
- public java.util.Collection<ESBService> getServices() {
- return(m_services.values());
- }
+ public java.util.Collection<ESBService> getServices();
/**
* This textual contents of the model.
*
* @return The textual contents
*/
- protected String getContents() {
- return(m_contents);
- }
+ public String getContents();
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
-
- private ModelReference m_source=null;
- private org.w3c.dom.Element m_esbConfig=null;
- private String m_contents=null;
- private java.util.Map<String,ESBService> m_services=new
java.util.Hashtable<String,ESBService>();
-
- public class InnerModelListener implements ModelListener {
-
- public InnerModelListener(ModelListener l) {
- m_listener = l;
- }
-
- public void error(ModelObject src, String mesg, Properties props) {
-
- if (props == null) {
- props = new Properties();
- }
-
- props.put(ModelListener.RESOLUTIONS,
ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
- props.put(ModelListener.REFERENCE_MODEL, m_source);
- props.put(ModelListener.REFERENCE_MODEL_START_POSITION,
src.getSource().getStartPosition());
- props.put(ModelListener.REFERENCE_MODEL_END_POSITION,
src.getSource().getEndPosition());
- if (src.getSource().getComponent() != null) {
- props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
- src.getSource().getComponent());
- }
-
- m_listener.error(src, mesg, props);
- }
-
- public void warning(ModelObject src, String mesg, Properties props) {
- if (props == null) {
- props = new Properties();
- }
-
- props.put(ModelListener.RESOLUTIONS,
ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
- props.put(ModelListener.REFERENCE_MODEL, m_source);
- props.put(ModelListener.REFERENCE_MODEL_START_POSITION,
src.getSource().getStartPosition());
- props.put(ModelListener.REFERENCE_MODEL_END_POSITION,
src.getSource().getEndPosition());
- if (src.getSource().getComponent() != null) {
- props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
- src.getSource().getComponent());
- }
-
- m_listener.warning(src, mesg, props);
- }
-
- private ModelListener m_listener=null;
- }
}
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/ESBService.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,109 +17,19 @@
*/
package org.jboss.tools.overlord.jbossesb.model;
-//import org.eclipse.jdt.core.IJavaElement;
-//import org.eclipse.jdt.core.dom.*;
-import java.util.logging.Logger;
-
-import org.eclipse.jdt.core.*;
-import org.eclipse.core.resources.*;
-
-// TODO: Need to find alternative to JavaModel
-import org.eclipse.jdt.internal.core.*;
-
-
import org.scribble.model.*;
-import org.scribble.osgi.model.*;
/**
- * This class represents an ESB service.
+ * This interface represents an ESB service.
*
* @author gary
*/
-public class ESBService extends ModelObject {
+public interface ESBService {
- private static final String SERVICE_ELEMENT = "service";
- private static final String SERVICE_NAME_PROPERTY = "serviceName";
- private static final String ROOT_PROPERTY = "root";
- private static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
- private static final String CONVERSATION_TYPE_PROPERTY = "conversationType";
- private static final String ACTION_PACKAGE =
"org.jboss.soa.overlord.jbossesb.actions.";
- private static final String CREATE_SESSION_ACTION_CLASS =
"org.jboss.soa.overlord.jbossesb.actions.CreateSessionAction";
- private static final String RETRIEVE_SESSION_ACTION_CLASS =
"org.jboss.soa.overlord.jbossesb.actions.RetrieveSessionAction";
- private static final String ACTION_ELEMENT = "action";
- private static final String ACTIONS_ELEMENT = "actions";
-
/**
- * This is the constructor for the ESB service.
- *
- * @param model The ESB model in which the service has been defined
- * @param service The XML configuration of the service
- */
- protected ESBService(ESBLanguageModel model, org.w3c.dom.Element service) {
- m_model = model;
- m_service = service;
-
- initialize();
- }
-
- /**
- * This method initializes the service.
- */
- protected void initialize() {
- // Check if relevant action
- org.w3c.dom.NodeList actions=m_service.getElementsByTagName(ACTIONS_ELEMENT);
-
- if (actions != null && actions.getLength() == 1 &&
- actions.item(0) instanceof org.w3c.dom.Element) {
- org.w3c.dom.NodeList nl=((org.w3c.dom.Element)
- actions.item(0)).getChildNodes();
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(ACTION_ELEMENT)) {
- m_actions.add(ESBActionFactory.createAction(this,
- ((org.w3c.dom.Element)nl.item(i))));
- }
- }
- }
-
- // Find positional information
- int servCount=getServicePosition();
-
- String str=getModel().getContents();
-
- int startPosition=str.indexOf("<service ");
- int endPosition=-1;
-
- while (startPosition != -1 && servCount > 0) {
- servCount--;
-
- endPosition = str.indexOf("</service>", startPosition);
-
- if (servCount > 0) {
- startPosition=str.indexOf("<service ", endPosition);
- }
- }
-
- if (startPosition != -1) {
- endPosition = str.indexOf("</service>", startPosition);
-
- getSource().setStartPosition(startPosition);
- getSource().setEndPosition(endPosition);
- }
- }
-
- /**
* This method initializes the links.
*/
- protected void initializeLinks() {
-
- // Work through actions requesting them to
- // establish their links
- for (int i=0; i < m_actions.size(); i++) {
- m_actions.get(i).initializeLinks();
- }
- }
+ public void initializeLinks();
/**
* This method validates the ESB service and reports warnings or
@@ -127,40 +37,15 @@
*
* @param l The model listener
*/
- public void validate(ModelListener l) {
-
- // Check that the service specifies a session
- if (isSessionBased() && getSessionClass() == null) {
- l.error(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.jbossesb.model.Messages"),
- "_NOT_SPECIFIED_SESSION_CLASS",
- new String[]{}), null);
- }
-
- for (int i=0; i < m_actions.size(); i++) {
- m_actions.get(i).validate(l);
- }
- }
+ public void validate(ModelListener l);
/**
- * This method returns the ESB model.
- *
- * @return The ESB model
- */
- public ESBLanguageModel getModel() {
- return(m_model);
- }
-
- /**
* This method returns the category associated with the service
* descriptor.
*
* @return The service category
*/
- public String getCategory() {
- return(m_service.getAttribute("category"));
- }
+ public String getCategory();
/**
* This method returns the name associated with the service
@@ -168,88 +53,36 @@
*
* @return The service name
*/
- public String getName() {
- return(m_service.getAttribute("name"));
- }
+ public String getName();
/**
+ * This method returns the ESB model.
+ *
+ * @return The ESB model
+ */
+ public ESBLanguageModel getModel();
+
+ /**
* This method returns the XML configuration representation of the service.
*
* @return The XML configuration for the service
*/
- public org.w3c.dom.Element getService() {
- return(m_service);
- }
+ public org.w3c.dom.Element getService();
/**
* This method returns the list of ESB actions.
*
* @return The ESB actions
*/
- public java.util.List<ESBAction> getActions() {
- return(m_actions);
- }
+ public java.util.List<ESBAction> getActions();
- protected java.lang.annotation.Annotation getServiceAnnotation(String session) {
- java.lang.annotation.Annotation ret=null;
-
- try {
- ClassLoader cl=getProjectLoader();
-
- Class<?> cls=Class.forName(session, true, cl);
-
- // TODO: This should be replaced by direct lookup
- // of Service annotation - but library not available
- // at the moment
- java.lang.annotation.Annotation[] annotations=
- cls.getAnnotations();
- for (int i=0; ret == null &&
- i < annotations.length; i++) {
- try {
- if (annotations[i].annotationType().getName().equals(
- "org.jboss.soa.overlord.jbossesb.actions.Service")) {
- ret = annotations[i];
- }
- } catch(Throwable ex) {
- // Ignore
- System.err.println("ANNOTATION: "+annotations[i].annotationType());
- ex.printStackTrace();
- }
- }
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get session class '"+session+"'", e);
- }
-
- return(ret);
- }
-
/**
* This method determines whether the ESB service represents a
* loop construct.
*
* @return Whether the service represents a loop
*/
- public boolean isLoop() {
- boolean ret=false;
-
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null) {
- ret = action.isLoop();
- }
-
- return(ret);
- }
+ public boolean isLoop();
/**
* This method determines whether the ESB service descriptor represents
@@ -257,50 +90,7 @@
*
* @return Whether the ESB service is associated with a root conversation
*/
- public boolean isRoot() {
- boolean ret=false;
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null) {
- if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
- String bool=action.getPropertyValue(ROOT_PROPERTY);
- if (bool != null) {
- ret = bool.equalsIgnoreCase("true");
- } else {
- String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
-
- java.lang.annotation.Annotation annotation=
- getServiceAnnotation(session);
-
- if (annotation != null) {
- try {
- java.lang.reflect.Method method=
- annotation.getClass().getMethod("root", (Class<?>[])null);
-
- Object val=method.invoke(annotation, (Object[])null);
-
- if (val instanceof Boolean) {
- ret = ((Boolean)val).booleanValue();
- }
- } catch(Throwable t) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get 'root' annotation value", t);
- }
- }
- }
- }
- }
-
- return(ret);
- }
+ public boolean isRoot();
/**
* This method returns the service description name associated with the
@@ -308,50 +98,7 @@
*
* @return The service description name
*/
- public String getServiceName() {
- String ret=null;
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null) {
- if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS) ||
- action.getActionClass().equals(RETRIEVE_SESSION_ACTION_CLASS)) {
- ret = action.getPropertyValue(SERVICE_NAME_PROPERTY);
-
- if (ret == null) {
- String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
-
- java.lang.annotation.Annotation annotation=
- getServiceAnnotation(session);
-
- if (annotation != null) {
- try {
- java.lang.reflect.Method method=
- annotation.getClass().getMethod("name", (Class<?>[])null);
-
- Object val=method.invoke(annotation, (Object[])null);
-
- if (val instanceof String) {
- ret = (String)val;
- }
- } catch(Throwable t) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get 'name' annotation value", t);
- }
- }
- }
- }
- }
-
- return(ret);
- }
+ public String getServiceName();
/**
* This method returns the conversation type associated with the
@@ -359,49 +106,7 @@
*
* @return The conversation type
*/
- public String getConversationType() {
- String ret=null;
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null) {
- if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
- ret = action.getPropertyValue(CONVERSATION_TYPE_PROPERTY);
-
- if (ret == null) {
- String session=action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
-
- java.lang.annotation.Annotation annotation=
- getServiceAnnotation(session);
-
- if (annotation != null) {
- try {
- java.lang.reflect.Method method=
- annotation.getClass().getMethod("conversationType",
(Class<?>[])null);
-
- Object val=method.invoke(annotation, (Object[])null);
-
- if (val instanceof String) {
- ret = (String)val;
- }
- } catch(Throwable t) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get 'name' annotation value", t);
- }
- }
- }
- }
- }
-
- return(ret);
- }
+ public String getConversationType();
/**
* This method returns the session name associated with the service
@@ -409,25 +114,7 @@
*
* @return The session name
*/
- public String getSessionName() {
- String ret=null;
- ESBAction action=null;
-
- for (int i=0; action == null && i < m_actions.size(); i++) {
- action=m_actions.get(i);
-
- if (action.isSessionBased() == false) {
- action = null;
- }
- }
-
- if (action != null &&
- action.getActionClass().startsWith(ACTION_PACKAGE)) {
- ret = action.getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
- }
-
- return(ret);
- }
+ public String getSessionName();
/**
* This method returns the session class associated with the service
@@ -435,40 +122,15 @@
*
* @return The session class
*/
- public Class<?> getSessionClass() {
- Class<?> ret=null;
- String session=getSessionName();
-
- if (session != null) {
- try {
- ClassLoader cl=getProjectLoader();
-
- ret = Class.forName(session, true, cl);
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to get session class '"+session+"'", e);
- }
- }
-
- return(ret);
- }
-
+ public Class<?> getSessionClass();
+
/**
* This method determines whether the service is related to a behavioural
* session.
*
* @return Whether the service is session based
*/
- public boolean isSessionBased() {
- boolean ret=false;
-
- for (int i=0; ret == false && i < m_actions.size(); i++) {
- ret = m_actions.get(i).isSessionBased();
- }
-
- return(ret);
- }
+ public boolean isSessionBased();
/**
* This method converts the actions associated with the ESB service into
@@ -480,16 +142,7 @@
* @param context The conversion context
*/
public void convert(java.util.List<Activity> activities,
- ConversionContext context) {
-
- context.processing(this);
-
- for (int i=0; i < m_actions.size(); i++) {
- ((ESBAction)m_actions.get(i)).convert(activities, context);
- }
-
- context.processed(this);
- }
+ ConversionContext context);
/**
* This method returns the position of the service node within the
@@ -497,26 +150,8 @@
*
* @return The service node position
*/
- protected int getServicePosition() {
- org.w3c.dom.Node services=m_service.getParentNode();
- int servCount=0;
- boolean f_end=false;
+ public int getServicePosition();
- for (int i=0; f_end == false &&
- i < services.getChildNodes().getLength(); i++) {
- org.w3c.dom.Node serv=services.getChildNodes().item(i);
-
- if (serv.getNodeName().equals(SERVICE_ELEMENT)) {
- servCount++;
- if (serv == m_service) {
- f_end = true;
- }
- }
- }
-
- return(servCount);
- }
-
/**
* This method returns a custom classloader that uses the project's
* classpath to locate classes referenced by the ESB config file.
@@ -526,80 +161,6 @@
* @return The classloader
* @throws Exception Failed to obtain the classloader
*/
- protected ClassLoader getProjectLoader() throws Exception {
- java.net.URLClassLoader classLoader=null;
- IFile file=OSGIModelRepository.getFile(getModel().getModelReference());
-
- if (file != null) {
- IJavaProject javaProject=JavaCore.create(file.getProject());
- IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
- String wsPath = javaProject.getProject().getLocation().toPortableString();
- String firstEntryLocation = javaProject.getPath().toPortableString();
- int idx = wsPath.indexOf(firstEntryLocation);
- wsPath = wsPath.substring(0,idx);
-
- String fullPath = null;
-
- java.net.URL[] urls = new java.net.URL[entries.length+1];
- int i = 0;
- urls[i++] = new java.io.File(wsPath +
- javaProject.getOutputLocation().toPortableString()).toURL();
+ public ClassLoader getServiceClassLoader() throws Exception;
- for (IClasspathEntry entry : entries) {
- if(entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
- IResource project =
- ResourcesPlugin.getWorkspace().getRoot().findMember(entry.getPath());
- String projectPath =
- JavaCore.create(project.getProject()).getOutputLocation().toPortableString();
- fullPath = wsPath + projectPath;
- } else {
- // TODO: Need to find alternative to this internal class (JavaModel)
- Object resource =
- JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(),entry.getPath(),true);
-
- if (resource instanceof IResource) {
- IResource iFile = (IResource) resource;
- fullPath = iFile.getLocation().toPortableString();
- } else if (resource instanceof java.io.File) {
- java.io.File resfile = (java.io.File) resource;
- fullPath = resfile.getAbsolutePath();
- }
- }
-
- urls[i++] = new java.io.File(fullPath).toURL();
- }
-
- classLoader = new java.net.URLClassLoader(urls,String.class.getClassLoader());
- }
-
- return(classLoader);
- }
-
- public int hashCode() {
- return(m_service.hashCode());
- }
-
- public boolean equals(Object obj) {
- boolean ret=false;
-
- if (obj instanceof ESBService) {
- ESBService other=(ESBService)obj;
-
- if (m_service == other.m_service) {
- ret = true;
- }
- }
-
- return(ret);
- }
-
- public String toString() {
- return("ESBService:
"+getCategory()+"/"+getName()+"["+getSource()+"]");
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
-
- private ESBLanguageModel m_model=null;
- private org.w3c.dom.Element m_service=null;
- private java.util.List<ESBAction> m_actions=new
java.util.Vector<ESBAction>();
}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -1,52 +0,0 @@
-/*
- * 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;
-
-import org.scribble.model.*;
-
-/**
- * This class represents an unsupported (or custom) action within
- * the conversation based ESB service descriptor.
- *
- * @author gary
- */
-public class UnsupportedAction extends ESBAction {
-
- /**
- * This method determines whether the action is related to a behavioural
- * session.
- *
- * @return Whether the action is session based
- */
- public boolean isSessionBased() {
- return(false);
- }
-
- /**
- * This method converts the ESB action into an equivalent
- * behavioural description for conformance checking.
- *
- * @param activities The list of activities that will contain
- * the converted action(s)
- * @param context The conversion context
- */
- public void convert(java.util.List<Activity> activities,
- ConversionContext context) {
- }
-
-}
Added:
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
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,359 @@
+/*
+ * 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.actions;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.jboss.tools.overlord.jbossesb.model.*;
+
+/**
+ * This is the generic ESB action class.
+ *
+ * @author gary
+ */
+public abstract class AbstractESBAction extends ModelObject
+ implements ESBAction {
+
+ private static final String ACTION_ELEMENT = "action";
+ //private static final String SERVICE_ELEMENT = "service";
+ private static final String VALUE_ATTR = "value";
+ private static final String NAME_ATTR = "name";
+ private static final String PROPERTY_ELEMENT = "property";
+ private static final String CLASS_PROPERTY = "class";
+
+ protected static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
+
+ /**
+ * The default constructor.
+ */
+ protected AbstractESBAction(ESBService service,
+ org.w3c.dom.Element action) {
+ init(service, action);
+ }
+
+ /**
+ * This method initializes the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ protected void init(ESBService service,
+ org.w3c.dom.Element action) {
+ m_service = service;
+ m_action = action;
+
+ if (m_service.getModel() != null &&
+ m_service.getModel().getContents() != null) {
+
+ // Find positional information
+ int servCount=m_service.getServicePosition();
+ int actionCount=getActionPosition();
+
+ String str=m_service.getModel().getContents();
+
+ int startPosition=str.indexOf("<service ");
+ int endPosition=-1;
+
+ while (startPosition != -1 && servCount > 0) {
+ servCount--;
+
+ endPosition = str.indexOf("</service>", startPosition);
+
+ if (servCount > 0) {
+ startPosition=str.indexOf("<service ", endPosition);
+ }
+ }
+
+ if (actionCount > 0 &&
+ startPosition != -1 && endPosition != -1) {
+ startPosition=str.indexOf("<action ", startPosition);
+ endPosition=-1;
+
+ while (startPosition != -1 && actionCount > 0) {
+ actionCount--;
+
+ endPosition = str.indexOf("</action>", startPosition);
+
+ if (actionCount > 0) {
+ startPosition=str.indexOf("<action ", endPosition);
+ }
+ }
+ }
+
+ getSource().setStartPosition(startPosition);
+ getSource().setEndPosition(endPosition);
+ }
+ }
+
+ /**
+ * This method initializes the links with the ESB service descriptors
+ * identified in each path of the action.
+ */
+ public void initializeLinks() {
+ }
+
+ /**
+ * This method validates the ESB action and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+
+ String[] mandatory=getMandatoryProperties();
+
+ for (int i=0; i < mandatory.length; i++) {
+ if (getPropertyValue(mandatory[i]) == null) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_SPECIFIED_PROPERTY",
+ new String[]{mandatory[i]}), null);
+ }
+ }
+
+ String session=getPropertyValue(BUSINESS_OBJECT_TYPE_PROPERTY);
+
+ if (session != null) {
+ // Validate that the business object type exists
+ try {
+ ClassLoader cl=getService().getServiceClassLoader();
+
+ try {
+ Class.forName(session, true, cl);
+ } catch(ClassNotFoundException cfne) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_BUSINESS_OBJECT_TYPE",
+ new String[]{session}), null);
+ }
+
+ } catch(Exception e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to load business class '"+session+"'", e);
+ }
+ }
+
+ // Validate links
+ for (int i=0; i < m_links.size(); i++) {
+ ESBLink link=(ESBLink)m_links.get(i);
+
+ if (link.getService() == null) {
+ // If target service not found, then report error
+ // unless it is a remote service, so defined in a
+ // different file
+ if (link.isRemote() == false) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{link.getCategory(),link.getName()}), null);
+ }
+ } else if (getService().getSessionName() != null &&
+ isPerform() == false &&
+ getService().getSessionName().equals(
+ link.getService().getSessionName()) == false) {
+
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.jbossesb.model.Messages"),
+ "_MISMATCH_SESSION_CLASS",
+ new String[]{link.getCategory(),link.getName()}), null);
+ }
+ }
+ }
+
+ /**
+ * This method determines if the action represents a loop construct.
+ *
+ * @return Whether the action represents a loop construct
+ */
+ public boolean isLoop() {
+ return(false);
+ }
+
+ /**
+ * This method determines whether the action is related to a behavioural
+ * session.
+ *
+ * @return Whether the action is session based
+ */
+ public boolean isSessionBased() {
+ return(true);
+ }
+
+ /**
+ * This method indicates whether this action performs another
+ * sub-conversation.
+ *
+ * @return Whether the action is a 'perform'
+ */
+ public boolean isPerform() {
+ return(false);
+ }
+
+ /**
+ * This method returns the mandatory property names.
+ *
+ * @return The mandatory property names
+ */
+ protected String[] getMandatoryProperties() {
+ return(new String[0]);
+ }
+
+ /**
+ * This method returns the action's class name.
+ *
+ * @return The action's class name
+ */
+ public String getActionClass() {
+ String ret=null;
+
+ if (m_action != null) {
+ ret = m_action.getAttribute(CLASS_PROPERTY);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the property value associated
+ * with the supplied name.
+ *
+ * @param property The property name
+ * @return The property value, or null if not found
+ */
+ public String getPropertyValue(String property) {
+ String ret=null;
+
+ if (m_action != null) {
+ org.w3c.dom.NodeList nl=m_action.getChildNodes();
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
+ ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
+ equals(property)) {
+ ret = ((org.w3c.dom.Element)nl.item(i)).getAttribute(VALUE_ATTR);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the 'property' child nodes, associated with the
+ * supplied property name, within the action configuration.
+ *
+ * @param property The property name
+ * @return The list of child nodes
+ */
+ public org.w3c.dom.NodeList getPropertyChildNodes(String property) {
+ org.w3c.dom.NodeList ret=null;
+
+ org.w3c.dom.NodeList nl=m_action.getChildNodes();
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
+ ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
+ equals(property)) {
+ ret = ((org.w3c.dom.Element)nl.item(i)).getChildNodes();
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the reference to the service that contains the
+ * action.
+ *
+ * @return The service
+ */
+ protected ESBService getService() {
+ return(m_service);
+ }
+
+ /**
+ * This method returns the XML configuration representation of the action.
+ *
+ * @return The XML configuration for the action
+ */
+ public org.w3c.dom.Element getAction() {
+ return(m_action);
+ }
+
+ /**
+ * This method returns the list of links established by this action.
+ *
+ * @return The list of links
+ */
+ protected java.util.List<ESBLink> getLinks() {
+ return(m_links);
+ }
+
+ /**
+ * This method converts the ESB action into an equivalent
+ * behavioural description for conformance checking.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ public abstract void convert(java.util.List<Activity> activities,
+ ConversionContext context);
+
+ /**
+ * This method returns the node position of the action configuration
+ * within the service descriptor.
+ *
+ * @return The action position
+ */
+ protected int getActionPosition() {
+ org.w3c.dom.Element service=(org.w3c.dom.Element)
+ getAction().getParentNode().getParentNode();
+
+ int actionCount=0;
+ boolean f_end=false;
+
+ org.w3c.dom.NodeList acts=service.getElementsByTagName(ACTION_ELEMENT);
+
+ for (int i=0; f_end == false &&
+ i < acts.getLength(); i++) {
+ org.w3c.dom.Node act=acts.item(i);
+
+ actionCount++;
+ if (act == getAction()) {
+ f_end = true;
+ }
+ }
+
+ return(actionCount);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model");
+
+ private ESBService m_service=null;
+ private org.w3c.dom.Element m_action=null;
+ private java.util.List<ESBLink> m_links=new java.util.Vector<ESBLink>();
+}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -19,6 +19,7 @@
import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.ESBService;
import org.scribble.model.*;
/**
@@ -26,9 +27,21 @@
*
* @author gary
*/
-public class CreateSessionAction extends ESBAction {
+public class CreateSessionAction extends AbstractESBAction {
private static final String CONVERSATION_TYPE = "conversationType";
+
+ /**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public CreateSessionAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
/**
* This method validates the ESB action and reports warnings or
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/GetVariableAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -19,8 +19,7 @@
import java.util.logging.Logger;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
/**
@@ -28,11 +27,23 @@
*
* @author gary
*/
-public class GetVariableAction extends ESBAction {
+public class GetVariableAction extends AbstractESBAction {
private static final String VARIABLE = "variable";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public GetVariableAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class IfAction extends ESBAction {
+public class IfAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -39,11 +36,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public IfAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
/**
@@ -35,7 +32,7 @@
*
* @author gary
*/
-public class MessageRouterAction extends ESBAction {
+public class MessageRouterAction extends AbstractESBAction {
private static final String INITIATE = "initiate";
private static final String SERVICE_NAME = "service-name";
@@ -44,11 +41,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public MessageRouterAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class ParallelAction extends ESBAction {
+public class ParallelAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -38,11 +35,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public ParallelAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/PerformAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class PerformAction extends ESBAction {
+public class PerformAction extends AbstractESBAction {
private static final String SERVICE_NAME = "serviceName";
private static final String SERVICE_CATEGORY = "serviceCategory";
@@ -37,11 +34,23 @@
private static final String JOIN_SERVICE_CATEGORY = "joinServiceCategory";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public PerformAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
m_category=getPropertyValue(SERVICE_CATEGORY);
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,8 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.conversation.model.*;
import org.scribble.model.*;
@@ -27,13 +26,25 @@
*
* @author gary
*/
-public class ReceiveMessageAction extends ESBAction {
+public class ReceiveMessageAction extends AbstractESBAction {
private static final String IDENTITIES = "identities";
private static final String MESSAGE_TYPE = "messageType";
private static final String OPERATION = "operation";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public ReceiveMessageAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/RetrieveSessionAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/RetrieveSessionAction.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/RetrieveSessionAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,8 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
/**
@@ -26,11 +25,23 @@
*
* @author gary
*/
-public class RetrieveSessionAction extends ESBAction {
+public class RetrieveSessionAction extends AbstractESBAction {
private static final String IDENTITIES = "identities";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public RetrieveSessionAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,9 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.jboss.tools.overlord.jbossesb.model.ESBService;
@@ -28,18 +26,30 @@
*
* @author gary
*/
-public class ScheduleStateAction extends ESBAction {
+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";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public ScheduleStateAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
String serviceCategory=getPropertyValue(SERVICE_CATEGORY);
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.conversation.model.*;
import org.scribble.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class SendMessageAction extends ESBAction {
+public class SendMessageAction extends AbstractESBAction {
private static final String IDENTITIES = "identities";
private static final String CLIENT_EPR = "clientEPR";
@@ -41,11 +38,23 @@
private static final String OPERATION = "operation";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public SendMessageAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
String serviceCategory=getPropertyValue(SERVICE_CATEGORY);
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SetVariableAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -19,8 +19,7 @@
import java.util.logging.Logger;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
/**
@@ -28,11 +27,23 @@
*
* @author gary
*/
-public class SetVariableAction extends ESBAction {
+public class SetVariableAction extends AbstractESBAction {
private static final String VARIABLE = "variable";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public SetVariableAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class SwitchAction extends ESBAction {
+public class SwitchAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -37,11 +34,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public SwitchAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/UnsupportedAction.java
(from rev 92,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/UnsupportedAction.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/UnsupportedAction.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/UnsupportedAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,65 @@
+/*
+ * 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.actions;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.scribble.model.*;
+
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *
+ * @author gary
+ */
+public class UnsupportedAction extends AbstractESBAction {
+
+ /**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public UnsupportedAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
+ * This method determines whether the action is related to a behavioural
+ * session.
+ *
+ * @return Whether the action is session based
+ */
+ public boolean isSessionBased() {
+ return(false);
+ }
+
+ /**
+ * This method converts the ESB action into an equivalent
+ * behavioural description for conformance checking.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ public void convert(java.util.List<Activity> activities,
+ ConversionContext context) {
+ }
+
+}
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class WhenAction extends ESBAction {
+public class WhenAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -38,11 +35,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public WhenAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
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-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -17,10 +17,7 @@
*/
package org.jboss.tools.overlord.jbossesb.model.actions;
-import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
-import org.jboss.tools.overlord.jbossesb.model.ESBAction;
-import org.jboss.tools.overlord.jbossesb.model.ESBLink;
-import org.jboss.tools.overlord.jbossesb.model.ESBService;
+import org.jboss.tools.overlord.jbossesb.model.*;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -29,7 +26,7 @@
*
* @author gary
*/
-public class WhileAction extends ESBAction {
+public class WhileAction extends AbstractESBAction {
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
@@ -39,11 +36,23 @@
private static final String PATHS = "paths";
/**
+ * The constructor for the action.
+ *
+ * @param service The reference to the service in which
+ * the action is contained
+ * @param action The XML configuration details for the action
+ */
+ public WhileAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@Override
- protected void initializeLinks() {
+ public void initializeLinks() {
super.initializeLinks();
org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/parser/JBossESBParser.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/parser/JBossESBParser.java 2008-07-01
11:15:18 UTC (rev 94)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/parser/JBossESBParser.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -50,7 +50,7 @@
*/
public Model parse(ModelReference ref, InputStream is,
ModelListener l) {
- ESBLanguageModel ret=null;
+ DefaultESBLanguageModel ret=null;
org.scribble.model.DependencyManager dm=
(org.scribble.model.DependencyManager)
@@ -86,7 +86,7 @@
// Identify the model associated with the
// changed resource
- ret = new ESBLanguageModel(ref, doc.getDocumentElement(),
+ ret = new DefaultESBLanguageModel(ref, doc.getDocumentElement(),
new String(b));
} catch(Exception e) {
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionActionTest.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,114 @@
+/*
+ * 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.actions;
+
+import junit.framework.TestCase;
+
+public class CreateSessionActionTest extends TestCase {
+
+ public void testValidateFirstAction() {
+ TestESBService service=new TestESBService();
+
+ UnsupportedAction unsupported=new UnsupportedAction(service, null);
+
+ CreateSessionAction action=new CreateSessionAction(service, null);
+
+ service.getActions().add(action);
+ service.getActions().add(unsupported);
+
+ TestModelListener l=new TestModelListener();
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateNotFirstAction() {
+ TestESBService service=new TestESBService();
+
+ UnsupportedAction unsupported=new UnsupportedAction(service, null);
+
+ CreateSessionAction action=new CreateSessionAction(service, null);
+
+ service.getActions().add(unsupported);
+ 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"),
+ "_MUST_BE_FIRST_ACTION",
+ new String[]{"CreateSession"}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateRootNoConversationType() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, null);
+
+ CreateSessionAction action=new CreateSessionAction(service, elem);
+
+ 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"),
+ "_NOT_SPECIFIED_CONVERSATION_TYPE",
+ new String[]{}));
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+
+ public void testValidateRootWithConversationType() {
+ TestESBService service=new TestESBService();
+ service.setRoot(true);
+
+ java.util.Map<String,String> props=new
java.util.Hashtable<String,String>();
+ props.put("conversationType", "test.Type");
+
+ org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+
+ CreateSessionAction action=new CreateSessionAction(service, elem);
+
+ service.getActions().add(action);
+
+ TestModelListener l=new TestModelListener();
+
+ action.validate(l);
+
+ if (l.isValid() == false) {
+ fail(l.invalidMessage());
+ }
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/ESBActionTestUtil.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,61 @@
+/*
+ * 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.actions;
+
+public class ESBActionTestUtil {
+
+ public static org.w3c.dom.Element getAction(String actionClass,
+ java.util.Map<String,String> simpleProps,
+ java.util.Map<String,org.w3c.dom.Element> customProps) {
+
+ org.w3c.dom.Element ret=null;
+
+ // Create an empty document
+ try {
+ org.w3c.dom.Document doc=javax.xml.parsers.DocumentBuilderFactory.
+ newInstance().newDocumentBuilder().newDocument();
+
+ if (doc != null) {
+ ret = doc.createElement("action");
+
+ if (actionClass != null) {
+ ret.setAttribute("class", actionClass);
+ }
+
+ if (simpleProps != null) {
+ java.util.Iterator<String> props=simpleProps.keySet().iterator();
+
+ while (props.hasNext()) {
+ String key=props.next();
+ String value=simpleProps.get(key);
+
+ org.w3c.dom.Element
property=ret.getOwnerDocument().createElement("property");
+ ret.appendChild(property);
+
+ property.setAttribute("name", key);
+ property.setAttribute("value", value);
+ }
+ }
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestESBService.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,120 @@
+/*
+ * 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.actions;
+
+import java.util.List;
+
+import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
+import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel;
+import org.scribble.model.Activity;
+import org.scribble.model.ModelListener;
+import org.w3c.dom.Element;
+
+public class TestESBService implements org.jboss.tools.overlord.jbossesb.model.ESBService
{
+
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List<ESBAction> getActions() {
+ return(m_actions);
+ }
+
+ public String getCategory() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getConversationType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ESBLanguageModel getModel() {
+ return(m_model);
+ }
+
+ public Element getService() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ClassLoader getServiceClassLoader() throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getServiceName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getServicePosition() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Class<?> getSessionClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getSessionName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void initializeLinks() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isLoop() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setRoot(boolean bool) {
+ m_root = bool;
+ }
+
+ public boolean isRoot() {
+ return(m_root);
+ }
+
+ public boolean isSessionBased() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void validate(ModelListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private ESBLanguageModel m_model=null;
+ private List<ESBAction> m_actions=new java.util.Vector<ESBAction>();
+ private boolean m_root=false;
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestModelListener.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestModelListener.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/model/actions/TestModelListener.java 2008-07-01
15:14:17 UTC (rev 95)
@@ -0,0 +1,84 @@
+/*
+ * 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.actions;
+
+import java.util.Properties;
+
+import org.scribble.model.ModelObject;
+
+public class TestModelListener implements org.scribble.model.ModelListener {
+
+ public void error(ModelObject modelObject, String mesg, Properties props) {
+ reported(mesg);
+ }
+
+ public void warning(ModelObject modelObject, String mesg, Properties props) {
+ reported(mesg);
+ }
+
+ protected void reported(String mesg) {
+ if (mesg != null) {
+
+ // Check if in the list of messages to be
+ // detected
+ if (m_errorsToDetect.contains(mesg)) {
+ m_errorsToDetect.remove(mesg);
+ } else {
+ m_unexpectedErrors.add(mesg);
+ }
+ }
+ }
+
+ public void addExpectedError(String mesg) {
+ m_errorsToDetect.add(mesg);
+ }
+
+ public boolean isValid() {
+ // If there are no more errors to detect, and no
+ // unexpected errors have been reported, then
+ // the expression has been validated as expected
+ return(m_errorsToDetect.size() == 0 &&
+ m_unexpectedErrors.size() == 0);
+ }
+
+ public String invalidMessage() {
+ String ret="\r\n";
+
+ if (m_errorsToDetect.size() > 0) {
+ ret += "Errors not detected:\r\n";
+
+ for (int i=0; i < m_errorsToDetect.size(); i++) {
+ ret += m_errorsToDetect.get(i)+"\r\n";
+ }
+ }
+
+ if (m_unexpectedErrors.size() > 0) {
+ ret += "Unexpected Errors:\r\n";
+
+ for (int i=0; i < m_unexpectedErrors.size(); i++) {
+ ret += m_unexpectedErrors.get(i)+"\r\n";
+ }
+ }
+
+ return(ret);
+ }
+
+ private java.util.List<String> m_errorsToDetect=new
java.util.Vector<String>();
+ private java.util.List<String> m_unexpectedErrors=new
java.util.Vector<String>();
+ private java.util.List<String> m_messages=new java.util.Vector<String>();
+}