[overlord-commits] Overlord SVN: r590 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change.
overlord-commits at lists.jboss.org
overlord-commits at lists.jboss.org
Mon Apr 20 19:13:30 EDT 2009
Author: objectiser
Date: 2009-04-20 19:13:30 -0400 (Mon, 20 Apr 2009)
New Revision: 590
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/InteractionPatterns.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java
Log:
Initial checks for the scoped invoke and fault handler for fault responses.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-04-20 22:08:19 UTC (rev 589)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-04-20 23:13:30 UTC (rev 590)
@@ -107,6 +107,25 @@
// establishing message type
if (InteractionUtil.isRequest(interaction)) {
+
+ if (InteractionPatterns.isFaultHandlerRequired(interaction)) {
+
+ Scope scope=new Scope(bpelModel);
+
+ if (context.getParent() instanceof Sequence) {
+ ((Sequence)context.getParent()).addActivity(scope, -1);
+ }
+
+ FaultHandlers fhs=new FaultHandlers(bpelModel);
+
+ Sequence seq=new Sequence(bpelModel);
+
+ scope.setActivity(seq);
+ scope.setFaultHandlers(fhs);
+
+ context.setParent(scope.getActivity());
+ }
+
act = new Invoke(bpelModel);
//pl.setMyRole(role.getName());
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/InteractionPatterns.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/InteractionPatterns.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/InteractionPatterns.java 2009-04-20 23:13:30 UTC (rev 590)
@@ -0,0 +1,95 @@
+/*
+ * 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.bpel.model.change;
+
+import org.jboss.tools.overlord.cdl.bpel.model.util.InteractionUtil;
+import org.scribble.model.Interaction;
+
+/**
+ * This class provides utility functions for detecting
+ * patterns related to interactions.
+ */
+public class InteractionPatterns {
+
+ /**
+ * This method checks whether the supplied interaction
+ * is a request that requires a scope with associated
+ * fault handlers.
+ *
+ * @param interaction The interaction
+ * @return Whether the interaction is a request requiring
+ * an outer fault handler
+ */
+ public static boolean isFaultHandlerRequired(org.scribble.model.Interaction interaction) {
+ boolean ret=false;
+
+ // Check if interaction is an invoke, and followed
+ // by a choice representing a normal and multiple
+ // fault responses
+ if (InteractionUtil.isRequest(interaction)) {
+
+ if (interaction.getParent() instanceof
+ org.scribble.model.Block) {
+ org.scribble.model.Block block=
+ (org.scribble.model.Block)interaction.getParent();
+
+ int pos=block.getContents().indexOf(interaction);
+
+ if (pos != -1 && pos < block.getContents().size()-1) {
+ org.scribble.model.Activity act=
+ block.getContents().get(pos+1);
+
+ if (act instanceof org.scribble.conversation.model.If) {
+
+ // Need to check if each path receives a
+ // response (normal and fault)
+ org.scribble.conversation.model.If choice=
+ (org.scribble.conversation.model.If)act;
+
+ if (choice.getPaths().size() > 0) {
+ ret = true;
+ }
+
+ for (int i=0; ret &&
+ i < choice.getPaths().size(); i++) {
+
+ org.scribble.model.Block path=
+ choice.getPaths().get(i);
+
+ if (path.getContents().size() == 0 ||
+ (path.getContents().get(0) instanceof Interaction) == false ||
+ InteractionUtil.isRequest((Interaction)
+ path.getContents().get(0))) {
+ ret = false;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ // TODO: Method to detect if normal response, which needs
+ // to enhance the invoke (and subsequent activities following
+ // the invoke), or a fault response needing to
+ // place itself and subsequent activities in a fault handler.
+ // Methods need to return (and set) the relevant sequence
+ // to use for subsequent activities.
+}
More information about the overlord-commits
mailing list