[overlord-commits] Overlord SVN: r32 - in trunk/tools/jbossesb: META-INF and 15 other directories.
overlord-commits at lists.jboss.org
overlord-commits at lists.jboss.org
Wed Jun 18 12:27:17 EDT 2008
Author: objectiser
Date: 2008-06-18 12:27:17 -0400 (Wed, 18 Jun 2008)
New Revision: 32
Added:
trunk/tools/jbossesb/.classpath
trunk/tools/jbossesb/Copyright.txt
trunk/tools/jbossesb/META-INF/
trunk/tools/jbossesb/META-INF/MANIFEST.MF
trunk/tools/jbossesb/build.properties
trunk/tools/jbossesb/plugin.xml
trunk/tools/jbossesb/src/
trunk/tools/jbossesb/src/org/
trunk/tools/jbossesb/src/org/jboss/
trunk/tools/jbossesb/src/org/jboss/internal/
trunk/tools/jbossesb/src/org/jboss/internal/soa/
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBActionFactory.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBLanguageModel.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBLink.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBService.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/UnsupportedAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/CreateSessionAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/IfAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/Messages.properties
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ParallelAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ReceiveMessageAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/RetrieveSessionAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ScheduleStateAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/SendMessageAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/SwitchAction.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/JBossESBNotation.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/JBossESBParser.java
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/validation/
trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/validation/ESBLanguageModelValidationRule.java
trunk/tools/jbossesb/src/org/jboss/soa/
trunk/tools/jbossesb/src/org/jboss/soa/overlord/
trunk/tools/jbossesb/src/org/jboss/soa/overlord/jbossesb/
trunk/tools/jbossesb/src/org/jboss/soa/overlord/jbossesb/eclipse/
trunk/tools/jbossesb/src/org/jboss/soa/overlord/jbossesb/eclipse/Activator.java
Log:
Initial version of Eclipse plugin for deriving a conversation type from a jboss-esb.xml configuration file, for conformance checking against a choreography.
Added: trunk/tools/jbossesb/.classpath
===================================================================
--- trunk/tools/jbossesb/.classpath (rev 0)
+++ trunk/tools/jbossesb/.classpath 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/jbossesb/Copyright.txt
===================================================================
--- trunk/tools/jbossesb/Copyright.txt (rev 0)
+++ trunk/tools/jbossesb/Copyright.txt 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
Added: trunk/tools/jbossesb/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/jbossesb/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/jbossesb/META-INF/MANIFEST.MF 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss Overlord JBossESB Plug-in
+Bundle-SymbolicName: org.jboss.soa.overlord.jbossesb;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.soa.overlord.jbossesb.eclipse.Activator
+Bundle-Vendor: www.jboss.org
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core,
+ org.scribble,
+ org.scribble.osgi,
+ org.scribble.conversation.model,
+ org.scribble.lang.model
+Eclipse-LazyStart: true
+Export-Package: org.jboss.internal.soa.overlord.jbossesb.model
+Bundle-ClassPath: .
+Scribble-Extensions: org.jboss.internal.soa.overlord.jbossesb.parser.JBossESBParser,
+ org.jboss.internal.soa.overlord.jbossesb.parser.JBossESBNotation,
+ org.jboss.internal.soa.overlord.jbossesb.validation.ESBLanguageModelValidationRule
Added: trunk/tools/jbossesb/build.properties
===================================================================
--- trunk/tools/jbossesb/build.properties (rev 0)
+++ trunk/tools/jbossesb/build.properties 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/tools/jbossesb/plugin.xml
===================================================================
--- trunk/tools/jbossesb/plugin.xml (rev 0)
+++ trunk/tools/jbossesb/plugin.xml 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ id="org.jboss.internal.soa.overlord.jbossesb.extension"
+ name="JBossESB model extension"
+ point="org.scribble.extension">
+ </extension>
+
+</plugin>
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,279 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model;
+
+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";
+ /**
+ * 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=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) {
+
+ // Validate links
+ for (int i=0; i < m_links.size(); i++) {
+ ESBLink link=(ESBLink)m_links.get(i);
+
+ // Don't report message links, if
+ // service not found, as may be defined in
+ // another file.
+ if (link.getService() == null &&
+ link.isControl()) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.internal.soa.overlord.jbossesb.model.actions.Messages"),
+ "_NOT_FOUND_SERVICE_DESCRIPTOR",
+ new String[]{link.getCategory(),link.getName()}), null);
+ }
+ }
+ }
+
+ /**
+ * 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)
+ */
+ public abstract void convert(java.util.List<Activity> activities);
+
+ /**
+ * This method returns the position of the service node within the
+ * ESB configuration.
+ *
+ * @return The service node position
+ */
+ protected int getServicePosition() {
+ org.w3c.dom.Element service=(org.w3c.dom.Element)
+ getAction().getParentNode().getParentNode();
+
+ org.w3c.dom.Node services=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 == service) {
+ f_end = true;
+ }
+ }
+ }
+
+ return(servCount);
+ }
+
+ /**
+ * 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 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: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBActionFactory.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBActionFactory.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBActionFactory.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,73 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model;
+
+/**
+ * This class provides a factory for ESBAction instances.
+ *
+ * @author gary
+ */
+public class ESBActionFactory {
+
+ private static final String MODEL_ACTION_PACKAGE =
+ "org.jboss.internal.soa.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) {
+ e.printStackTrace();
+ }
+ }
+ } else {
+ // Unrecognised or unsupported action
+ ret = new UnsupportedAction();
+ ret.init(service, action);
+ }
+
+ return(ret);
+ }
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBLanguageModel.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBLanguageModel.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBLanguageModel.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,294 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model;
+
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+
+/**
+ * This class represents an ESB model.
+ *
+ * @author gary
+ */
+public class ESBLanguageModel extends org.scribble.lang.model.LanguageModel {
+
+ 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 ESBLanguageModel(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 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());
+
+ getConversations().add(conv);
+ }
+ }
+
+ }
+ }
+
+ @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()) {
+ iter.next().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
+ */
+ protected String getContents() {
+ return(m_contents);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.internal.soa.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());
+
+ 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());
+
+ m_listener.warning(src, mesg, props);
+ }
+
+ private ModelListener m_listener=null;
+ }
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBLink.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBLink.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBLink.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,89 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model;
+
+/**
+ * This class represents the link from a ESB action to a service
+ * descriptor.
+ *
+ * @author gary
+ */
+public class ESBLink {
+
+ /**
+ * This is the constructor for the link.
+ *
+ * @param category The service category of the target service descriptor
+ * @param name The service name of the target descriptor
+ * @param service A reference to the service model containing the action
+ * that links to the service descriptor
+ * @param control Whether the link is a control link, if not then it
+ * represents a message link (i.e. to another service)
+ */
+ public ESBLink(String category, String name,
+ ESBService service, boolean control) {
+ m_category = category;
+ m_name = name;
+ m_service = service;
+ m_control = control;
+ }
+
+ /**
+ * This method indicates whether this is a control
+ * link, as opposed to a message link.
+ *
+ * @return Whether the link is a control link
+ */
+ public boolean isControl() {
+ return(m_control);
+ }
+
+ /**
+ * This method returns the service category.
+ *
+ * @return The service category
+ */
+ public String getCategory() {
+ return(m_category);
+ }
+
+ /**
+ * This method returns the service name.
+ *
+ * @return The service name
+ */
+ public String getName() {
+ return(m_name);
+ }
+
+ /**
+ * This method returns the reference to ESB Service
+ * model containing the action that links to the
+ * target service descriptor.
+ *
+ * @return The ESB service
+ */
+ public ESBService getService() {
+ return(m_service);
+ }
+
+ private String m_category=null;
+ private String m_name=null;
+ private ESBService m_service=null;
+ private boolean m_control=false;
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBService.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBService.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/ESBService.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,396 @@
+/*
+ * 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.internal.soa.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.
+ *
+ * @author gary
+ */
+public class ESBService extends ModelObject {
+
+ 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 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))));
+ }
+ }
+ }
+ }
+
+ /**
+ * 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();
+ }
+ }
+
+ /**
+ * 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) {
+
+ 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 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;
+
+ IFile file=OSGIModelRepository.getFile(getModel().getModelReference());
+
+ if (file != null) {
+ IJavaProject jproj=JavaCore.create(file.getProject());
+
+ try {
+ ClassLoader cl=getProjectLoader(jproj);
+
+ 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) {
+ e.printStackTrace();
+ }
+ }
+
+ 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;
+
+ if (m_actions.size() > 0) {
+ ESBAction action=(ESBAction)m_actions.get(0);
+
+ 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;
+
+ if (m_actions.size() > 0) {
+ ESBAction action=(ESBAction)m_actions.get(0);
+
+ 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;
+
+ if (m_actions.size() > 0) {
+ ESBAction action=(ESBAction)m_actions.get(0);
+
+ if (action.getActionClass().equals(CREATE_SESSION_ACTION_CLASS)) {
+ ret = action.getPropertyValue(CONVERSATION_TYPE_PROPERTY);
+
+ if (ret == null) {
+ /* TODO: Uncomment when conversationType defined on Service annotation
+ 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 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
+ */
+ public void convert(java.util.List<Activity> activities) {
+
+ for (int i=0; i < m_actions.size(); i++) {
+ ((ESBAction)m_actions.get(i)).convert(activities);
+ }
+ }
+
+ /**
+ * 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
+ *
+ * @param javaProject The Java project containing the config file
+ * @return The classloader
+ * @throws Exception Failed to obtain the classloader
+ */
+ private static ClassLoader getProjectLoader(IJavaProject javaProject)
+ throws Exception {
+ 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 file = (java.io.File) resource;
+ fullPath = file.getAbsolutePath();
+ }
+ }
+
+ urls[i++] = new java.io.File(fullPath).toURL();
+ }
+
+ java.net.URLClassLoader classLoader = new
+ java.net.URLClassLoader(urls,String.class.getClassLoader());
+
+ return(classLoader);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.internal.soa.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>();
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/UnsupportedAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/UnsupportedAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/UnsupportedAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,40 @@
+/*
+ * 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.internal.soa.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 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+ }
+
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/CreateSessionAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/CreateSessionAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/CreateSessionAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,40 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model.actions;
+
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBAction;
+import org.scribble.model.*;
+
+/**
+ * The model component for the 'CreateSessionAction'.
+ *
+ * @author gary
+ */
+public class CreateSessionAction extends ESBAction {
+
+ /**
+ * 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+ }
+
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/IfAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/IfAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/IfAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,125 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model.actions;
+
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBAction;
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBLink;
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBService;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * The model component for the 'IfAction'.
+ *
+ * @author gary
+ */
+public class IfAction extends ESBAction {
+
+ private static final String SERVICE_NAME = "service-name";
+ private static final String SERVICE_CATEGORY = "service-category";
+ private static final String ELSE = "else";
+ private static final String ELSEIF = "elseif";
+ private static final String IF = "if";
+ private static final String PATHS = "paths";
+
+ /**
+ * This method initializes the links with the ESB service descriptors
+ * identified in each path of the action.
+ */
+ @Override
+ protected void initializeLinks() {
+ super.initializeLinks();
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element &&
+ (n.getNodeName().equals(IF) ||
+ n.getNodeName().equals(ELSEIF) ||
+ n.getNodeName().equals(ELSE))) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ ESBService service=getService().getModel().getService(category, name);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(category, name, service, true));
+ }
+ }
+ }
+
+ /**
+ * This method validates the ESB action and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ super.validate(l);
+
+ // TODO: Validate if/elseif/else order, if decision-method
+ // specified, that method exists, if expression, then
+ // validate the expression etc.
+ }
+
+ /**
+ * 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+
+ If choice=new If();
+ activities.add(choice);
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element &&
+ (n.getNodeName().equals(IF) ||
+ n.getNodeName().equals(ELSEIF) ||
+ n.getNodeName().equals(ELSE))) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // TODO: Convert the conditional expression if defined
+
+ ConditionalBlock cond=new ConditionalBlock();
+ choice.getConditionalBlocks().add(cond);
+
+ ESBService service=getService().getModel().getService(category, name);
+
+ if (service != null) {
+ service.convert(cond.getContents());
+ }
+ }
+ }
+ }
+
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/Messages.properties
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/Messages.properties (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/Messages.properties 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,19 @@
+# /*
+# * 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.
+# */
+
+_NOT_FOUND_SERVICE_DESCRIPTOR=Service descriptor for category '{0}' and name '{1}' not found
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ParallelAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ParallelAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ParallelAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,116 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model.actions;
+
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBAction;
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBLink;
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBService;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * The model component for the 'ParallelAction'.
+ *
+ * @author gary
+ */
+public class ParallelAction extends ESBAction {
+
+ private static final String SERVICE_NAME = "service-name";
+ private static final String SERVICE_CATEGORY = "service-category";
+ private static final String JOIN = "join";
+ private static final String PATH = "path";
+ private static final String PATHS = "paths";
+
+ /**
+ * This method initializes the links with the ESB service descriptors
+ * identified in each path of the action.
+ */
+ @Override
+ protected void initializeLinks() {
+ super.initializeLinks();
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element &&
+ (n.getNodeName().equals(PATH) ||
+ n.getNodeName().equals(JOIN))) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ ESBService service=getService().getModel().getService(category, name);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(category, name, service, true));
+ }
+ }
+ }
+
+ /**
+ * 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+
+ Parallel parallel=new Parallel();
+ activities.add(parallel);
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element) {
+ if (n.getNodeName().equals(PATH)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ Block block=new Block();
+ parallel.getBlocks().add(block);
+
+ ESBService service=getService().getModel().getService(category, name);
+
+ if (service != null) {
+ service.convert(block.getContents());
+ }
+ } else if (n.getNodeName().equals(JOIN)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ ESBService service=getService().getModel().getService(category, name);
+
+ if (service != null) {
+ // Join activities should be added after the
+ // parallel construct
+ service.convert(activities);
+ }
+ }
+ }
+ }
+ }
+
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ReceiveMessageAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ReceiveMessageAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ReceiveMessageAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,74 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model.actions;
+
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBAction;
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+
+/**
+ * The model component for the 'ReceiveMessageAction'.
+ *
+ * @author gary
+ */
+public class ReceiveMessageAction extends ESBAction {
+
+ private static final String MESSAGE_TYPE = "messageType";
+ private static final String OPERATION = "operation";
+
+ /**
+ * 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+
+ ConversationInteraction recv=new ConversationInteraction();
+ activities.add(recv);
+
+ MessageSignature ms=new MessageSignature();
+ recv.setMessageSignature(ms);
+
+ ms.setOperation(getPropertyValue(OPERATION));
+
+ String type=getPropertyValue(MESSAGE_TYPE);
+ if (type != null && type.length() > 0) {
+ String ns=null;
+ String local=type;
+
+ if (type.charAt(0) == '{') {
+ int endindex=type.indexOf('}');
+
+ if (endindex != -1) {
+ ns = type.substring(1, endindex);
+ local = type.substring(endindex+1);
+ }
+ }
+
+ TypeReference ref=new TypeReference();
+ ref.setLocalpart(local);
+ ref.setNamespace(ns);
+
+ ms.getTypes().add(ref);
+ }
+
+ // TODO: Initialize the 'to' role to be this participant
+ }
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/RetrieveSessionAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/RetrieveSessionAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/RetrieveSessionAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,40 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model.actions;
+
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBAction;
+import org.scribble.model.*;
+
+/**
+ * The model component for the 'RetrieveSessionAction'.
+ *
+ * @author gary
+ */
+public class RetrieveSessionAction extends ESBAction {
+
+ /**
+ * 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+ }
+
+}
\ No newline at end of file
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ScheduleStateAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ScheduleStateAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/ScheduleStateAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,40 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model.actions;
+
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBAction;
+import org.scribble.model.*;
+
+/**
+ * The model component for the 'ScheduleStateAction'.
+ *
+ * @author gary
+ */
+public class ScheduleStateAction extends ESBAction {
+
+ /**
+ * 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+ }
+
+}
\ No newline at end of file
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/SendMessageAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/SendMessageAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/SendMessageAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,133 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model.actions;
+
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBAction;
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBLink;
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBService;
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+
+/**
+ * The model component for the 'SendMessageAction'.
+ *
+ * @author gary
+ */
+public class SendMessageAction extends ESBAction {
+
+ private static final String RESPONSE_SERVICE_NAME = "responseServiceName";
+ private static final String RESPONSE_SERVICE_CATEGORY = "responseServiceCategory";
+ private static final String SERVICE_NAME = "serviceName";
+ private static final String SERVICE_CATEGORY = "serviceCategory";
+ private static final String MESSAGE_TYPE = "messageType";
+ private static final String OPERATION = "operation";
+
+ /**
+ * This method initializes the links with the ESB service descriptors
+ * identified in each path of the action.
+ */
+ @Override
+ protected void initializeLinks() {
+ super.initializeLinks();
+
+ String serviceCategory=getPropertyValue(SERVICE_CATEGORY);
+ String serviceName=getPropertyValue(SERVICE_NAME);
+ String responseServiceCategory=getPropertyValue(RESPONSE_SERVICE_CATEGORY);
+ String responseServiceName=getPropertyValue(RESPONSE_SERVICE_NAME);
+
+ if (serviceCategory != null && serviceName != null) {
+ ESBService service=getService().getModel().getService(
+ serviceCategory, serviceName);
+
+ getLinks().add(new ESBLink(serviceCategory, serviceName,
+ service, false));
+ }
+
+ if (responseServiceCategory != null && responseServiceName != null) {
+ ESBService service=getService().getModel().getService(
+ responseServiceCategory, responseServiceName);
+
+ getLinks().add(new ESBLink(responseServiceCategory,
+ responseServiceName, service, true));
+ }
+ }
+
+ /**
+ * 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+
+ ConversationInteraction send=new ConversationInteraction();
+ activities.add(send);
+
+ send.derivedFrom(this);
+
+ MessageSignature ms=new MessageSignature();
+ send.setMessageSignature(ms);
+
+ ms.setOperation(getPropertyValue(OPERATION));
+
+ String type=getPropertyValue(MESSAGE_TYPE);
+ if (type != null && type.length() > 0) {
+ String ns=null;
+ String local=type;
+
+ if (type.charAt(0) == '{') {
+ int endindex=type.indexOf('}');
+
+ if (endindex != -1) {
+ ns = type.substring(1, endindex);
+ local = type.substring(endindex+1);
+ }
+ }
+
+ TypeReference ref=new TypeReference();
+ ref.setLocalpart(local);
+ ref.setNamespace(ns);
+
+ ms.getTypes().add(ref);
+ }
+
+ // TODO: Initialize the 'to' role (possibly to a
+ // namespace=service category and localpart=service
+ // name. This would need to be mapped when doing
+ // conformance checking - might be an issue, may
+ // need to declare the name.
+
+ // Check if a response control link has been
+ // specified
+ String responseServiceCategory=getPropertyValue(RESPONSE_SERVICE_CATEGORY);
+ String responseServiceName=getPropertyValue(RESPONSE_SERVICE_NAME);
+
+ if (responseServiceCategory != null && responseServiceName != null) {
+ ESBService service=getService().getModel().getService(
+ responseServiceCategory, responseServiceName);
+
+ // Add activities from the 'response' service descriptor into
+ // the set of activities. If service not found, then ignore
+ // here as will be reported as part of the validation of links.
+ if (service != null) {
+ service.convert(activities);
+ }
+ }
+ }
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/SwitchAction.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/SwitchAction.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/model/actions/SwitchAction.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,105 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.model.actions;
+
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBAction;
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBLink;
+import org.jboss.internal.soa.overlord.jbossesb.model.ESBService;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * The model component for the 'SwitchAction'.
+ *
+ * @author gary
+ */
+public class SwitchAction extends ESBAction {
+
+ private static final String SERVICE_NAME = "service-name";
+ private static final String SERVICE_CATEGORY = "service-category";
+ private static final String CASE = "case";
+ private static final String PATHS = "paths";
+
+ /**
+ * This method initializes the links with the ESB service descriptors
+ * identified in each path of the action.
+ */
+ @Override
+ protected void initializeLinks() {
+ super.initializeLinks();
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element &&
+ n.getNodeName().equals(CASE)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Lookup service associated with category and name
+ ESBService service=getService().getModel().getService(category, name);
+
+ // Initialize link, even if service is null - this will be
+ // reported as a validation error later
+ getLinks().add(new ESBLink(category, name, service, true));
+ }
+ }
+ }
+
+ /**
+ * 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)
+ */
+ public void convert(java.util.List<Activity> activities) {
+
+ org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+
+ If choice=new If();
+ activities.add(choice);
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element &&
+ n.getNodeName().equals(CASE)) {
+ String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+ String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+
+ // Conditional block with no expression - i.e. the
+ // expression is non-observable, as the path will be
+ // selected based on the next message that arrives
+ ConditionalBlock block=new ConditionalBlock();
+ choice.getConditionalBlocks().add(block);
+
+ ESBService service=getService().getModel().getService(category, name);
+
+ if (service != null) {
+ service.convert(block.getContents());
+ }
+ }
+ }
+ }
+
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/JBossESBNotation.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/JBossESBNotation.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/JBossESBNotation.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,72 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.jboss.internal.soa.overlord.jbossesb.model.*;
+
+/**
+ *
+ *
+ * @author gary
+ */
+ at RegistryInfo(extension=org.scribble.parser.Notation.class)
+public class JBossESBNotation implements org.scribble.parser.Notation {
+
+ /**
+ * This method returns the code for the notation.
+ *
+ * @return The notation code
+ */
+ public String getCode() {
+ return(ESBLanguageModel.JBOSSESB_NOTATION);
+ }
+
+ /**
+ * This method returns the name of the notation.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return("JBossESB");
+ }
+
+ /**
+ * This method returns the initial description associated
+ * with the supplied reference.
+ *
+ * @param ref The reference
+ * @return The initial description, or null if no description
+ */
+ public String getInitialDescription(ModelReference ref) {
+ StringBuffer buf=new StringBuffer();
+
+ return(buf.toString());
+ }
+
+ /**
+ * This method determines whether the Scribble editor should
+ * be used for editing the notation.
+ *
+ * @return Whether the Scribble editor should be used
+ */
+ public boolean useScribbleEditor() {
+ return(false);
+ }
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/JBossESBParser.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/JBossESBParser.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/parser/JBossESBParser.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,101 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.parser;
+
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.scribble.model.*;
+import org.jboss.internal.soa.overlord.jbossesb.model.*;
+import org.scribble.extensions.*;
+import org.scribble.parser.Parser;
+
+/**
+ * This JBossESB implementation of the Parser interface.
+ *
+ * @author gary
+ */
+ at RegistryInfo(extension=Parser.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class JBossESBParser implements Parser {
+
+ /**
+ * This method parses the source located using the supplied
+ * scribble reference, to return a model. If any
+ * errors are detected, they will be reported to the parser
+ * listener.
+ *
+ * @param ref The scribble source reference
+ * @param is The input stream
+ * @param l The model listener
+ * @return The model, or null if not found
+ */
+ public Model parse(ModelReference ref, InputStream is,
+ ModelListener l) {
+ ESBLanguageModel ret=null;
+
+ org.scribble.model.DependencyManager dm=
+ (org.scribble.model.DependencyManager)
+ org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+ org.scribble.model.DependencyManager.class, null);
+
+ if (dm != null) {
+
+ // Clear the dependencies so that they can be
+ // re-initialized during the parsing of the model
+ dm.clearDependencies(ref);
+ }
+
+ try {
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+
+ byte[] b=new byte[is.available()];
+ is.read(b);
+
+ // Need to load original input stream and then
+ // provide a second input stream, as some input stream
+ // implementations don't support 'reset' operation,
+ // and therefore this was the only way to extract the
+ // content and also provide the stream to the XML
+ // document builder.
+ java.io.ByteArrayInputStream bais=new java.io.ByteArrayInputStream(b);
+
+ org.w3c.dom.Document doc=builder.parse(bais);
+
+ // Identify the model associated with the
+ // changed resource
+ ret = new ESBLanguageModel(ref, doc.getDocumentElement(),
+ new String(b));
+
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load model", e);
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.internal.soa.overlord.jbossesb.parser");
+}
Added: trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/validation/ESBLanguageModelValidationRule.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/validation/ESBLanguageModelValidationRule.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/internal/soa/overlord/jbossesb/validation/ESBLanguageModelValidationRule.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,64 @@
+/*
+ * 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.internal.soa.overlord.jbossesb.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.jboss.internal.soa.overlord.jbossesb.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * conversation.
+ *
+ * @author gary
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ESBLanguageModelValidationRule extends AbstractValidationRule {
+
+ /**
+ * This is the default constructor.
+ */
+ public ESBLanguageModelValidationRule() {
+ }
+
+ /**
+ * This method determines whether the rule is appropriate for
+ * the supplied model object.
+ *
+ * @param obj The model object
+ * @return Whether the rule is appropriate
+ */
+ public boolean isSupported(ModelObject obj) {
+ return(obj instanceof ESBLanguageModel);
+ }
+
+ /**
+ * This method validates the supplied model object.
+ *
+ * @param obj The model object
+ * @param context The context
+ * @param l The listener
+ */
+ public void validate(ModelObject obj, ValidationContext context,
+ ModelListener l) {
+ ESBLanguageModel model=(ESBLanguageModel)obj;
+
+ model.validate(l);
+ }
+}
Added: trunk/tools/jbossesb/src/org/jboss/soa/overlord/jbossesb/eclipse/Activator.java
===================================================================
--- trunk/tools/jbossesb/src/org/jboss/soa/overlord/jbossesb/eclipse/Activator.java (rev 0)
+++ trunk/tools/jbossesb/src/org/jboss/soa/overlord/jbossesb/eclipse/Activator.java 2008-06-18 16:27:17 UTC (rev 32)
@@ -0,0 +1,69 @@
+/*
+ * 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.soa.overlord.jbossesb.eclipse;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author gary
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.soa.overlord.jbossesb";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
More information about the overlord-commits
mailing list