Overlord SVN: r474 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb: src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-02-01 13:28:52 -0500 (Sun, 01 Feb 2009)
New Revision: 474
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/TypeReferenceModelChangeRule.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
Log:
Add the type reference update change rule for the stateless conversation model.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-02-01 16:42:47 UTC (rev 473)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-02-01 18:28:52 UTC (rev 474)
@@ -28,6 +28,7 @@
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless.ConversationModelChangeRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless.ConversationInteractionModelChangeRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless.IfModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless.TypeReferenceModelChangeRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.LanguageToConversationModelChangeRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationModelChangeRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationInteractionModelChangeRule,
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/TypeReferenceModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/TypeReferenceModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/TypeReferenceModelChangeRule.java 2009-02-01 18:28:52 UTC (rev 474)
@@ -0,0 +1,173 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateless;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Type Reference.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class TypeReferenceModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof TypeReference &&
+ toObj instanceof TypeReference &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless() == true) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ TypeReference fromTypeRef=(TypeReference)fromObj;
+ TypeReference toTypeRef=(TypeReference)toObj;
+ ConversationInteraction toInteraction=null;
+ ConversationInteraction fromInteraction=null;
+
+ if (toTypeRef != null && toTypeRef.getParent() instanceof MessageSignature &&
+ toTypeRef.getParent().getParent() instanceof ConversationInteraction) {
+ toInteraction = (ConversationInteraction)toTypeRef.getParent().getParent();
+ }
+
+ if (fromTypeRef != null && fromTypeRef.getParent() instanceof MessageSignature &&
+ fromTypeRef.getParent().getParent() instanceof ConversationInteraction) {
+ fromInteraction = (ConversationInteraction)fromTypeRef.getParent().getParent();
+ }
+
+ // Get action from 'toInteraction'
+ if (toInteraction != null &&
+ toInteraction.getSource().getObject() instanceof
+ AbstractInteractionMessageAction) {
+ AbstractInteractionMessageAction ma=
+ (AbstractInteractionMessageAction)
+ toInteraction.getSource().getObject();
+
+ ESBService service = ma.getService();
+
+ String origMesgType=ma.getMessageType();
+
+ // Set message type
+ setMessageType(ma, fromInteraction);
+
+ // Update message type in router if appropriate
+ if (InteractionUtil.isSend(fromInteraction) == false &&
+ fromInteraction.getReplyToLabel() == null) {
+ updateRouterMessageType(esbModel, service,
+ origMesgType, ma);
+ }
+
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected void updateRouterMessageType(ESBLanguageModel esbModel,
+ ESBService service, String origMesgType,
+ AbstractInteractionMessageAction ma) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof SwitchAction) {
+ SwitchAction mra=(SwitchAction)
+ gwAction;
+
+ org.w3c.dom.Element route=
+ mra.getCaseElement(service.getCategory(),
+ service.getName());
+
+ if (route != null) {
+ org.w3c.dom.NodeList nl=
+ route.getElementsByTagName(SwitchAction.MESSAGE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element mesg=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (mesg.getAttribute(SwitchAction.TYPE_ATTR).
+ equals(origMesgType)) {
+ mesg.setAttribute(SwitchAction.TYPE_ATTR,
+ ma.getMessageType());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void setMessageType(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+
+ if (interaction.getMessageSignature().getTypes().size() == 1) {
+ TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+
+ // TODO: Search for an implementation associated with
+ // the type reference, so that the type can be
+ // abstract - possibly have the required message type
+ // notation as part of the context, so that if multiple
+ // implementations found, then can select e.g. XML or
+ // Java as message type representation.
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ action.setMessageType(mtype);
+ }
+ }
+}
15 years, 2 months
Overlord SVN: r473 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-02-01 11:42:47 -0500 (Sun, 01 Feb 2009)
New Revision: 473
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
Log:
Add diagnostic information to export stateless model as text.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-29 20:55:30 UTC (rev 472)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-02-01 16:42:47 UTC (rev 473)
@@ -160,6 +160,36 @@
new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION));
if (statelessConversation != null) {
+
+ if (logger.isLoggable(Level.FINEST)) {
+ try {
+ org.scribble.export.Exporter exporter=
+ (org.scribble.export.Exporter)
+ RegistryFactory.getRegistry().getExtension(
+ org.scribble.export.Exporter.class, null);
+
+ 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(statelessConversation,
+ new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION),
+ formatter);
+
+ String str=new String(os.toByteArray());
+
+ System.out.println("EXPORTED CDM TO JBESB STATELESS:");
+ System.out.println(str);
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
lcm.setConversation(statelessConversation);
} else {
logger.severe("Failed to transform to stateless conversation");
15 years, 2 months