Overlord SVN: r355 - in cdl/trunk/docs/docbook/userguide/src/main: module and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-09-30 11:53:47 -0400 (Tue, 30 Sep 2008)
New Revision: 355
Added:
cdl/trunk/docs/docbook/userguide/src/main/module/conversation-aware-esb.xml
cdl/trunk/docs/docbook/userguide/src/main/module/conversation-validation-with-cdl.xml
Modified:
cdl/trunk/docs/docbook/userguide/src/main/master.xml
Log:
Started migration of other docs into docbook UserGuide. Conversation-validation-with-cdl - converted two sections, but remaining sections will not be converted - one relates to installation which is now handled in the 'getting started' part, and the other describes running the Trailblazer example, which is covered in the samples guide. Possible that some of the images may be useful in the samples guide - and also may want to 'docbook' the samples guide.
Modified: cdl/trunk/docs/docbook/userguide/src/main/master.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/src/main/master.xml 2008-09-30 13:34:41 UTC (rev 354)
+++ cdl/trunk/docs/docbook/userguide/src/main/master.xml 2008-09-30 15:53:47 UTC (rev 355)
@@ -1,16 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
-]>
-
-<book lang="en">
- <bookinfo>
- <title>JBoss Overlord CDL 1.0</title>
- <subtitle>User Guide</subtitle>
- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/author_group.xml"/>
- </bookinfo>
-
- <toc/>
- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/getting_started.xml"/>
-
-</book>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
+]>
+
+<book lang="en">
+ <bookinfo>
+ <title>JBoss Overlord CDL 1.0</title>
+ <subtitle>User Guide</subtitle>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/author_group.xml"/>
+ </bookinfo>
+
+ <toc/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/getting_started.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/conversation-validation-with-cdl.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/conversation-aware-esb.xml"/>
+
+</book>
Added: cdl/trunk/docs/docbook/userguide/src/main/module/conversation-aware-esb.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/src/main/module/conversation-aware-esb.xml (rev 0)
+++ cdl/trunk/docs/docbook/userguide/src/main/module/conversation-aware-esb.xml 2008-09-30 15:53:47 UTC (rev 355)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="conversationawareesb">
+ <title>Conversation Aware ESB</title>
+ <section>
+ <title></title>
+ <section>
+ <title></title>
+ <para>
+ </para>
+ </section>
+ </section>
+</chapter>
Added: cdl/trunk/docs/docbook/userguide/src/main/module/conversation-validation-with-cdl.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/src/main/module/conversation-validation-with-cdl.xml (rev 0)
+++ cdl/trunk/docs/docbook/userguide/src/main/module/conversation-validation-with-cdl.xml 2008-09-30 15:53:47 UTC (rev 355)
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="conversationvalidationwithcdl">
+ <title>Conversation Validation with CDL</title>
+ <section>
+ <title>Conversation Validation</title>
+ <section>
+ <title>Overview</title>
+ <para>
+ Conversation validation is a form of runtime governance concerned with the dynamic behaviour of a system.
+ </para>
+ <para>
+When coupled with a choreography description model of a system, this means having the ability to ensure that the way a collection of services interact correctly adheres to a description of the business process being enacted.
+ </para>
+ <para>
+This section introduces the choreography description language (CDL) defined by W3C, and the <emphasis>pi4soa</emphasis> open source project which provides an editor for creating choreography descriptions, as well as utilizing these descriptions for runtime validation and execution purposes.
+
+ </para>
+ </section>
+
+ <section>
+ <title>WS-CDL</title>
+
+ <para>
+WS-CDL, or Web Service Choreography Description Language, is a candidate recommendation from W3C. Although associated with W3C and Web Services, it is important to begin by stating that the Choreography Description Language (CDL) is <emphasis role="bold">not</emphasis> web service specific.
+ </para>
+ <para>
+The purpose of CDL is to enable the interactions between a collection of peer to peer services to be described from a neutral (or global) perspective. This is different to other standards, such as WS-BPEL, that describe interactions from a service specific viewpoint.
+ </para>
+ <para>
+In essence a choreography description declares roles which will pass messages between each other, called interactions. The interactions are ordered based on a number of structuring mechanism which enables loops, conditional, choices and parallelism to be described. In CDL variables used for messages and for conditionals are all situated at roles. There is no shared state rather there is a precise description of the state at each role and a precise description of how these roles interact in order to reach some notion of common state in which information is exchanged and processed between them.
+ </para>
+ <para>
+In CDL we use interactions and these structuring mechanisms to describe the observable behaviour, the messages exchanges and the rules for those exchanges and any supporting observable state on which they depend, of a system.
+ </para>
+ </section>
+
+ <section>
+ <title>pi4soa</title>
+ <para>
+<emphasis>pi4soa</emphasis> is an open source project established to demonstrate the potential benefits that a global model (as described using CDL) can provide when building an SOA. The open source project is managed by the Pi4 Technologies Foundation, which is a collaboration between industry and academia.
+ </para>
+ <para>
+Building complex distributed systems, without introducing unintended consequences, is a real challenge. Although the Choreography Description Language provides a means of describing complex systems at a higher level, and therefore help to reduce such complexity, it does not necessarily guarantee that erronous situations cannot occur due to inappropriately specified interactions. The research, being carried out by members of the Pi4 Technologies Foundation, into the global model and endpoint projection is targeted at identifying potential unintended consequences, to ensure that a global description of a system can be reliably executed and can be free from unintended consequences.
+ </para>
+ <para>
+The tool suite currently offers the ability to:
+ </para>
+ <para>
+ <itemizedlist>
+ <listitem>
+ Define a choreography description
+ </listitem>
+ <listitem>
+ Export the description to a range of other formats, such as BPMN, UML activity/state/sequence models, and HTML
+ </listitem>
+ <listitem>
+ Define scenarios (equivalent to sequence diagrams), with example messages, which can then be simulated against an associated choreography
+ </listitem>
+ <listitem>
+ Generate template endpoint implementations:
+ <para>
+ <itemizedlist>
+ <listitem>
+ WS-BPEL for deployment in ActiveBPEL
+ </listitem>
+ <listitem>
+ Java stubs for execution with the pi4soa state machine, with deployment options for Apache Axis, J2EE (JBoss, Glassfish) and JBoss ESB
+ </listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+ </section>
+
+ <section>
+ <title>Configuration of Conversation Validation</title>
+
+ <section>
+ <title>Central Configuration</title>
+ <para>
+The principle mechanism used for validating conversations within an ESB is through the use of a global filter registered with the <emphasis>jbossesb-properties.xml</emphasis>. This file is located in the <emphasis>$JBossESB/server/default/deploy/jbossesb.sar</emphasis> folder.
+ </para>
+ <informalexample>
+ <programlisting>
+ <properties name="filters">
+ ...
+ <property name="org.jboss.soa.esb.filter.10"
+ value="org.pi4soa.jbossesb.validator.ValidatorFilter"/>
+ </properties>
+ </programlisting>
+ </informalexample>
+
+ <para>
+This filter is installed as part of the installation process for the Overlord-CDL distribution.
+ </para>
+ <para>
+The information concerning what destinations will be validated, and to which choreography/participant they relate, are contained within the <emphasis>validator-config.xml</emphasis> file, contained within the <emphasis>overlord-cdl-validator.esb</emphasis> bundle.
+ </para>
+ <para>
+An example of the contents of this file, as used by the TrailBlazer example, is:
+ </para>
+ <informalexample>
+ <programlisting>
+ <validator active="true" >
+ <service cdmFilePath="models/TrailBlazer.cdm"
+ participantType="LoanBrokerParticipant" >
+ <output epr="jms:queue/esb-tb-creditAgencyQueue" />
+ <input epr="jms:queue/esb-tb-creditAgencyQueue_reply" />
+ <output epr="jms:queue/esb-tb-jmsBankRequestQueue" />
+ <output epr="jms:queue/esb-tb-fileBankRequestQueue" />
+ <input epr="jms:queue/esb-tb-jmsBankResponseQueue" />
+ <output epr="jms:queue/esb-tb-customerNotifier" />
+ <input epr="jms:queue/esb-tb-fileBankResponseQueue" />
+ </service>
+ <service cdmFilePath="models/TrailBlazer.cdm"
+ participantType="CreditAgencyParticipant" >
+ <input epr="jms:queue/esb-tb-creditAgencyQueue" />
+ <output epr="jms:queue/esb-tb-creditAgencyQueue_reply" />
+ </service>
+ <service cdmFilePath="models/TrailBlazer.cdm"
+ participantType="BankParticipant" >
+ <input epr="jms:queue/esb-tb-jmsBankRequestQueue" />
+ <input epr="jms:queue/esb-tb-fileBankRequestQueue" />
+ <output epr="jms:queue/esb-tb-jmsBankResponseQueue" />
+ <output epr="jms:queue/esb-tb-fileBankResponseQueue" />
+ </service>
+ <service cdmFilePath="models/TrailBlazer.cdm"
+ participantType="NotifierParticipant" >
+ <input epr="jms:queue/esb-tb-customerNotifier" />
+ </service>
+ </validator>
+ </programlisting>
+ </informalexample>
+
+ <para>
+The 'validator' element has a single boolean attribute called 'active', which determines whether active or passive validation is used. Active validation means that any erronous messages, that conflict with the behaviour as described in the choreography, should be prevented from being received or sent. Passive validation means that the message will continue to be received or sent, and errors will only be reported for information purposes.
+ </para>
+ <note>
+ <para>
+ It is important to note that if 'active' validation is used, then the validation mechanism will be an integral part of the message flow. This may have a slight performance impact on the delivery of messages between services.
+ </para>
+ </note>
+ <para>
+Within the 'validator' element is a list of 'service' elements, one per service being validated. The behaviour of the service being validated is identified by specifying the choreography model and the participant type within the choreography model. Therefore, within the above configuration, the first set of destinations (eprs) are associated with the <emphasis>LoanBrokerParticipant</emphasis> defined within the choreography description model found in the file <filename>model/TrailBlazer.cdm</filename>, which will be located within the <emphasis>overlord-cdl-validator.esb</emphasis> bundle.
+ </para>
+ <para>
+The elements contained within the 'service' element define the <emphasis>input</emphasis> and <emphasis>output</emphasis> eprs (Endpoint References) that are associated with the service. The <emphasis>input</emphasis> eprs are the destinations on which messages will be received and the <emphasis>output</emphasis> eprs are the destinations on which messages will be sent by the service.
+ </para>
+ <para>
+The format of the 'epr' attribute will be specific to the type of transport used for the ESB aware destination. Currently only JMS is supported, and can be identified by the protocol prefix 'jms:'.
+ </para>
+
+ </section>
+
+ <section>
+ <title>Local Configuration using <emphasis>ValidationAction</emphasis></title>
+ <para>
+Although it is preferrable to validate an .esb bundle using the central configuration, there are times when it is not possible to know the specific destination used to send a message to or from a service. In these situations, it will be necessary to explicitly insert an action into a service descriptor's action pipeline, to observe the message.
+ </para>
+ <para>
+This can be achieved using the <emphasis>org.pi4soa.jbossesb.validator.ValidationAction</emphasis>, which can be configured with the following properties:
+ </para>
+
+ <informalexample>
+ <programlisting>
+ <action name="LoanBrokerValidatorAction1"
+ class="org.pi4soa.jbossesb.validator.ValidationAction"
+ process="processMessage" >
+ <property name="cdmFilePath" value="models/TrailBlazer.cdm" />
+ <property name="participantType" value="LoanBrokerParticipant" />
+ <property name="inbound" value="true" />
+ <property name="request" value="true" />
+ </action>
+ </programlisting>
+ </informalexample>
+
+ <para>
+The <emphasis>cdmFilePath</emphasis> references the choreography description model, which will usually be a relative path within the <emphasis>overlord-cdl-validator.esb</emphasis> bundle. The <emphasis>participantType</emphasis> property defines which participant the validator action is representing. The optional <emphasis>inbound</emphasis> property indicates whether the message on the action pipeline is being received (true) or sent (false). The optional <emphasis>request</emphasis> property can be used to determine whether the message on the action pipeline represents a request (true) or response/notification (false).
+ </para>
+ </section>
+ </section>
+</chapter>
15 years, 7 months
Overlord SVN: r354 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src: test/org/jboss/tools/overlord/cdl/jbossesb/model/change and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-09-30 09:34:41 -0400 (Tue, 30 Sep 2008)
New Revision: 354
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRuleTest.java
Log:
Midway insertion support for If and Parallel.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java 2008-09-30 13:34:41 UTC (rev 354)
@@ -90,9 +90,11 @@
public boolean insert(ModelChangeContext context,
Model model, ModelObject mobj, ModelObject ref) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=(ESBService)context.getParent();
+ ESBService service=getESBService(context, ref);
If ifElem=(If)mobj;
+ int pos=getInsertionPosition(service, ref);
+
ESBService joinService=
esbModel.createService(service.getCategory(),
esbModel.getUniqueServiceName(service.getCategory(),
@@ -103,253 +105,311 @@
// Check if should be an 'if' or a 'switch' action
if (ifElem.getRoles().contains(context.getRole())) {
- // If action, because the role is a decision maker
- IfAction ifAction=new IfAction(service);
+ insertIf(context, model, service, ifElem, joinService, pos);
+ } else {
+ insertSwitch(context, model, service, ifElem, joinService, pos);
+ }
+
+
+ context.setParent(joinService);
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ protected void insertIf(ModelChangeContext context,
+ Model model, ESBService service,
+ If ifElem, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // If action, because the role is a decision maker
+ IfAction ifAction=new IfAction(service);
+
+ service.addAction(ifAction, pos);
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
- service.addAction(ifAction, -1);
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
- for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
+ esbModel.addService(subService);
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
- boolean immediate=false;
-
- ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
- subService.getCategory(), subService.getName(),
- immediate, null, i);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
+ boolean immediate=false;
+
+ ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
+ subService.getCategory(), subService.getName(),
+ immediate, null, i);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
}
+ }
+
+ if (ifElem.getElseBlock() != null) {
- if (ifElem.getElseBlock() != null) {
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
- esbModel.addService(subService);
+ esbModel.addService(subService);
- context.setParent(subService);
-
- for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
- context.insert(model,
- ifElem.getElseBlock().getContents().get(j), null);
- }
-
- boolean immediate=false;
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), null);
+ }
+
+ boolean immediate=false;
- ifAction.addPath(IfAction.ELSE,
- subService.getCategory(), subService.getName(),
- immediate, null, -1);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
+ ifAction.addPath(IfAction.ELSE,
+ subService.getCategory(), subService.getName(),
+ immediate, null, -1);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- if (service.getFirstSessionBasedAction() == ifAction &&
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
ifElem.getEnclosingDefinition() instanceof Conversation) {
- ifAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
((Conversation)ifElem.getEnclosingDefinition())));
}
- } else {
+ }
+
+ if (service.getFirstSessionBasedAction() == ifAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ ifAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ protected void insertSwitch(ModelChangeContext context,
+ Model model, ESBService service,
+ If ifElem, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // Check if 'when' needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
- // Switch action, as role is a decision observer
- SwitchAction switchAction=new SwitchAction(service);
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService switchService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(switchService);
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
- if (la == null) {
- logger.severe("Failed to find lookahead analyser");
- }
+ schedule.setDestination(switchService.getCategory(),
+ switchService.getName(), false);
- service.addAction(switchAction, -1);
+ service.addAction(schedule, pos);
+
+ context.setParent(switchService);
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
+ service = switchService;
+ pos = -1;
+ }
- for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ service.addAction(switchAction, pos);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
- esbModel.addService(subService);
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
+ esbModel.addService(subService);
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(cb);
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, i);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, i);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
}
}
}
+ }
+
+ if (ifElem.getElseBlock() != null) {
- if (ifElem.getElseBlock() != null) {
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
- esbModel.addService(subService);
+ esbModel.addService(subService);
- context.setParent(subService);
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), null);
+ }
- for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
- context.insert(model,
- ifElem.getElseBlock().getContents().get(j), null);
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(ifElem.getElseBlock());
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, -1);
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(ifElem.getElseBlock());
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, -1);
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
}
}
}
+ }
+
+ // Only record message router 'routes' if the switch
+ // receives request interactions, and it is the first
+ // session based action in the service
+ if (messageTypes.size() > 0 &&
+ service.getFirstSessionBasedAction() == switchAction) {
+ ESBService gwService=
+ esbModel.getGatewayService();
- // Only record message router 'routes' if the switch
- // receives request interactions, and it is the first
- // session based action in the service
- if (messageTypes.size() > 0 &&
- service.getFirstSessionBasedAction() == switchAction) {
- ESBService gwService=
- esbModel.getGatewayService();
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- mra.addRoute(service.getCategory(),
- service.getName(),
- false, messageTypes);
- }
- }
- }
-
- if (service.getFirstSessionBasedAction() == switchAction &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
}
- context.setParent(joinService);
-
- return(true);
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
}
private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.jbossesb.model.change");
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java 2008-09-30 13:34:41 UTC (rev 354)
@@ -89,9 +89,11 @@
public boolean insert(ModelChangeContext context,
Model model, ModelObject mobj, ModelObject ref) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=(ESBService)context.getParent();
+ ESBService service=getESBService(context, ref);
Parallel parallel=(Parallel)mobj;
+ int pos=getInsertionPosition(service, ref);
+
// Create the join service
ESBService joinService=
esbModel.createService(service.getCategory(),
@@ -103,7 +105,7 @@
// Create and configure the parallel action
ParallelAction parAction=new ParallelAction(service);
- service.addAction(parAction, -1);
+ service.addAction(parAction, pos);
for (int i=0; i < parallel.getBlocks().size(); i++) {
Block b=parallel.getBlocks().get(i);
@@ -172,6 +174,17 @@
((Conversation)parallel.getEnclosingDefinition())));
}
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
return(true);
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java 2008-09-30 13:34:41 UTC (rev 354)
@@ -183,7 +183,7 @@
When when, ESBService joinService, int pos) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
- // Check if receive needs to be placed in new service
+ // Check if 'when' needs to be placed in new service
// descriptor - i.e. if insert at end, but current service
// already has service based actions, or reference object
// provided, but is not first position
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRuleTest.java 2008-09-30 11:09:07 UTC (rev 353)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRuleTest.java 2008-09-30 13:34:41 UTC (rev 354)
@@ -105,6 +105,157 @@
}
}
+ public void testInsertIfActionWithSubsequentActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (ifService == null) {
+ ifService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertIfActionWithPrecedingActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof IfAction) == false) {
+ fail("Action 2 was not IfAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (ifService == null) {
+ ifService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
public void testInsertIfElseIfAction() {
IfModelChangeRule rule=new IfModelChangeRule();
@@ -733,4 +884,186 @@
schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
}
}
+
+ public void testInsertSwitchActionWithSubsequentActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService switchService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((switchService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (switchService == null) {
+ switchService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertSwitchActionWithPrecedingActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("First action not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
+
+ ESBService addedService=model.getService(
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+
+ if (addedService == null) {
+ fail("Failed to find service '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"' '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
+ }
+
+ if (addedService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRuleTest.java 2008-09-30 11:09:07 UTC (rev 353)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRuleTest.java 2008-09-30 13:34:41 UTC (rev 354)
@@ -509,4 +509,116 @@
fail("Join should not be immediate");
}
}
+
+ public void testInsertParallelMiddleAction() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Parallel mobj=new Parallel();
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ Block cb2=new Block();
+ mobj.getBlocks().add(cb2);
+
+ Block cb3=new Block();
+ mobj.getBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(1);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 4) {
+ fail("Four path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(3);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Expecting 1 join action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Action was not test ESB action 2: "+join.getActions().get(0));
+ }
+ }
}
15 years, 7 months
Overlord SVN: r353 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src: test/org/jboss/tools/overlord/cdl/jbossesb/model/change and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-09-30 07:09:07 -0400 (Tue, 30 Sep 2008)
New Revision: 353
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRuleTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/AbstractESBModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRuleTest.java
Log:
Minor refactoring and adding support for mid way insertion to run, spawn and while.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/AbstractESBModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/AbstractESBModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/AbstractESBModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -74,6 +74,27 @@
}
/**
+ * This method determines the insertion position based on the
+ * supplied service and optional reference model object.
+ *
+ * @param service The service
+ * @param ref The optional reference model object
+ * @return The position, or -1 if at end
+ */
+ protected int getInsertionPosition(ESBService service, ModelObject ref) {
+ int ret=-1;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
+ ret = service.getActions().indexOf((ESBAction)
+ ref.getSource().getObject());
+ }
+
+ return(ret);
+ }
+
+ /**
* This method determines whether an 'initiator' action,
* inserted at the defined position in the specified
* service, should actually be placed in a new scheduled
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -119,23 +119,19 @@
setMessageType(action, interaction);
- int pos=-1;
boolean f_subsequentInitiator=false;
boolean f_moveActions=false;
// Check if reference model object provided, and if so,
// if it has a position within the service
- if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
- pos = service.getActions().indexOf((ESBAction)
- ref.getSource().getObject());
-
- // Check if subsequent action(s) are initiators
- if (pos != -1) {
- for (int i=pos; f_subsequentInitiator == false &&
- i < service.getActions().size(); i++) {
- f_subsequentInitiator =
- service.getActions().get(i).isInitiator();
- }
+ int pos=getInsertionPosition(service, ref);
+
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
}
}
@@ -255,23 +251,19 @@
ESBService service=getESBService(context, ref);
ESBService endService=service;
- int pos=-1;
int endPos=-1;
boolean f_subsequentInitiator=false;
// Check if reference model object provided, and if so,
// if it has a position within the service
- if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
- pos = service.getActions().indexOf((ESBAction)
- ref.getSource().getObject());
+ int pos=getInsertionPosition(service, ref);
- // Check if subsequent action(s) are initiators
- if (pos != -1) {
- for (int i=pos; f_subsequentInitiator == false &&
- i < service.getActions().size(); i++) {
- f_subsequentInitiator =
- service.getActions().get(i).isInitiator();
- }
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
}
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -89,12 +89,14 @@
public boolean insert(ModelChangeContext context,
Model model, ModelObject mobj, ModelObject ref) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=(ESBService)context.getParent();
+ ESBService service=getESBService(context, ref);
Run run=(Run)mobj;
+ int pos=getInsertionPosition(service, ref);
+
PerformAction action=new PerformAction(service);
- service.addAction(action, -1);
+ service.addAction(action, pos);
String category=ConversationUtil.getServiceCategory(run.getDefinition());
String name=ConversationUtil.getServiceName(run.getDefinition());
@@ -121,6 +123,17 @@
action.setReturnDestination(returnService.getCategory(),
returnService.getName());
+ // If reference provided, then move subsequent activities
+ // to the 'return service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ returnService.addAction(act, -1);
+ }
+ }
+
return(true);
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -87,12 +87,14 @@
@Override
public boolean insert(ModelChangeContext context,
Model model, ModelObject mobj, ModelObject ref) {
- ESBService service=(ESBService)context.getParent();
+ ESBService service=getESBService(context, ref);
Spawn spawn=(Spawn)mobj;
+ int pos=getInsertionPosition(service, ref);
+
PerformAction action=new PerformAction(service);
- service.addAction(action, -1);
+ service.addAction(action, pos);
String category=ConversationUtil.getServiceCategory(spawn.getDefinition());
String name=ConversationUtil.getServiceName(spawn.getDefinition());
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -92,15 +92,8 @@
ESBService service=getESBService(context, ref);
When when=(When)mobj;
- int pos=-1;
+ int pos=getInsertionPosition(service, ref);
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
- pos = service.getActions().indexOf((ESBAction)
- ref.getSource().getObject());
- }
-
// Create join service
ESBService joinService=
esbModel.createService(service.getCategory(),
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -89,13 +89,19 @@
public boolean insert(ModelChangeContext context,
Model model, ModelObject mobj, ModelObject ref) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=(ESBService)context.getParent();
+ ESBService service=getESBService(context, ref);
+ ESBService original=service;
While whileElem=(While)mobj;
- // Check if current service is session based
- // If so, then need to put while in a separate new
- // service
- if (service.isSessionBased()) {
+ int pos=getInsertionPosition(service, ref);
+
+ // Check if action needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
ESBService whileService=
esbModel.createService(service.getCategory(),
esbModel.getUniqueServiceName(service.getCategory(),
@@ -113,7 +119,7 @@
schedule.setDestination(whileService.getCategory(),
whileService.getName(),
whileElem.getRoles().contains(context.getRole()));
- ((ESBService)context.getParent()).addAction(schedule, -1);
+ service.addAction(schedule, pos);
context.setParent(whileService);
@@ -221,7 +227,18 @@
action.addPath(exitService.getCategory(),
exitService.getName(), true,
new java.util.Vector<MessageSignature>(), -1);
-
+
+ // If reference provided, then move subsequent activities
+ // to the 'exit service'
+ if (pos != -1) {
+ for (int i=pos+1; i < original.getActions().size();) {
+ ESBAction act=original.getActions().get(i);
+ original.getActions().remove(i);
+
+ exitService.addAction(act, -1);
+ }
+ }
+
return(true);
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRuleTest.java 2008-09-29 14:57:24 UTC (rev 352)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRuleTest.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -145,4 +145,143 @@
newService.getName());
}
}
+
+ public void testInsertPerformActionMiddle() {
+ String runName="subconv";
+
+ RunModelChangeRule rule=new RunModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Run mobj=new Run();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ if (newService.getCategory().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
+ fail("Perform return service category '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)) == false) {
+ fail("Perform return service name '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Return service should have 1 action: "+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Expecting test ESB action 2: "+newService.getActions().get(0));
+ }
+
+ }
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRuleTest.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -0,0 +1,220 @@
+/*
+ * 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.jbossesb.model.change;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.cdl.jbossesb.model.change.RunModelChangeRule;
+import org.jboss.tools.overlord.cdl.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class SpawnModelChangeRuleTest extends TestCase {
+
+ public void testInsertPerformAction() {
+ String runName="subconv";
+
+ SpawnModelChangeRule rule=new SpawnModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Spawn mobj=new Spawn();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(0);
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ }
+
+ public void testInsertPerformActionMiddle() {
+ String runName="subconv";
+
+ SpawnModelChangeRule rule=new SpawnModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Spawn mobj=new Spawn();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 3) {
+ fail("Expecting 3 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (service.getActions().get(2) != act2) {
+ fail("Expecting test ESB action 2: "+service.getActions().get(2));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ }
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRuleTest.java 2008-09-29 14:57:24 UTC (rev 352)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRuleTest.java 2008-09-30 11:09:07 UTC (rev 353)
@@ -430,7 +430,10 @@
model.addService(service);
// Make session based service
- service.setSessionBased(true);
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
TestModelChangeContext context=new TestModelChangeContext();
context.setParent(service);
@@ -478,16 +481,20 @@
}
// Check actions
- if (service.getActions().size() != 1) {
+ if (service.getActions().size() != 2) {
fail("Expecting 1 action: "+service.getActions().size());
}
- if ((service.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(0));
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action: "+service.getActions().get(0));
}
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
ScheduleStateAction whileSchedule=(ScheduleStateAction)
- service.getActions().get(0);
+ service.getActions().get(1);
if (model.getServices().size() != 4) {
fail("Four services expected: "+model.getServices().size());
@@ -581,4 +588,119 @@
"' not expected: "+s2.getName());
}
}
+
+ public void testInsertWhileMiddleAction() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Make session based service
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction whileSchedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService whileService=null;
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null || whileService == null) &&
+ iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ whileService = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ }
+
+ if (s2.getActions().size() != 1) {
+ fail("Expecting 1 action in exit service: "+s2.getActions().size());
+ }
+
+ if (s2.getActions().get(0) != act2) {
+ fail("Action in exit is not test ESB action: "+s2.getActions().get(0));
+ }
+ }
}
15 years, 7 months
Overlord SVN: r352 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src: test/org/jboss/tools/overlord/cdl/jbossesb/model/change and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-09-29 10:57:24 -0400 (Mon, 29 Sep 2008)
New Revision: 352
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/AbstractESBModelChangeRule.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRuleTest.java
Log:
Refactor model change rules to derive from ESB specific abstract class. Modify 'when' model change insertion to cater for insertion in any position - and define appropriate tests.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/AbstractESBModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/AbstractESBModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/AbstractESBModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -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.tools.overlord.cdl.jbossesb.model.change;
+
+import org.jboss.tools.overlord.cdl.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+
+/**
+ * This is the abstract ESB model change rule.
+ */
+public abstract class AbstractESBModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if ((context.getParent() instanceof ESBService ||
+ (ref != null && ref.getSource().getObject()
+ instanceof AbstractESBAction &&
+ ((AbstractESBAction)ref.getSource().getObject()).getService() != null)) &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the ESB service associated with the
+ * optional model object reference or the context.
+ *
+ * @param context The context
+ * @param ref The optional model object
+ * @return The ESB service, or null if not found
+ */
+ protected ESBService getESBService(ModelChangeContext context,
+ ModelObject ref) {
+ ESBService ret=(ESBService)context.getParent();
+
+ if (ref != null && ref.getSource().getObject() instanceof AbstractESBAction) {
+ ret = ((AbstractESBAction)ref.getSource().getObject()).getService();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether an 'initiator' action,
+ * inserted at the defined position in the specified
+ * service, should actually be placed in a new scheduled
+ * service.
+ *
+ * @param service The current service
+ * @param pos The insertion position in that service
+ * @return Whether a new service needs to be scheduled to
+ * accommodate the initiator action
+ */
+ protected boolean shouldScheduleNewService(ESBService service,
+ int pos) {
+ boolean ret=false;
+
+ for (int i=0; ret == false && i < pos; i++) {
+ ESBAction action=service.getActions().get(i);
+
+ if (action.isSessionBased() && !action.isCreateSession()) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-28 17:38:27 UTC (rev 351)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -31,7 +31,7 @@
* This is the model change rule for the Conversation Interaction.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ConversationInteractionModelChangeRule extends AbstractModelChangeRule {
+public class ConversationInteractionModelChangeRule extends AbstractESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
@@ -51,11 +51,7 @@
boolean ret=false;
if (mobj instanceof ConversationInteraction &&
- (context.getParent() instanceof ESBService ||
- (ref != null && ref.getSource().getObject()
- instanceof AbstractESBAction &&
- ((AbstractESBAction)ref.getSource().getObject()).getService() != null)) &&
- model instanceof ESBLanguageModel) {
+ super.isInsertSupported(context, model, mobj, ref)) {
ret = true;
}
@@ -253,17 +249,6 @@
}
}
- protected ESBService getESBService(ModelChangeContext context,
- ModelObject ref) {
- ESBService ret=(ESBService)context.getParent();
-
- if (ref != null && ref.getSource().getObject() instanceof AbstractESBAction) {
- ret = ((AbstractESBAction)ref.getSource().getObject()).getService();
- }
-
- return(ret);
- }
-
protected void insertReceive(ModelChangeContext context,
ESBLanguageModel esbModel, ConversationInteraction interaction,
ModelObject ref) {
@@ -372,8 +357,6 @@
// Check if existing actions need to be moved
if (pos != -1 && service != endService) {
for (int i=pos+1; i < service.getActions().size();) {
- //ESBService extraService=(ESBService)context.getParent();
-
ESBAction act=service.getActions().get(i);
service.getActions().remove(i);
@@ -427,21 +410,6 @@
}
}
- protected boolean shouldScheduleNewService(ESBService service,
- int pos) {
- boolean ret=false;
-
- for (int i=0; ret == false && i < pos; i++) {
- ESBAction action=service.getActions().get(i);
-
- if (action.isSessionBased() && !action.isCreateSession()) {
- ret = true;
- }
- }
-
- return(ret);
- }
-
/**
* This method determines whether the rule is appropriate
* for the supplied type of model, parent (in the context)
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java 2008-09-28 17:38:27 UTC (rev 351)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -33,7 +33,7 @@
* This is the model change rule for the If grouping construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class IfModelChangeRule extends AbstractModelChangeRule {
+public class IfModelChangeRule extends AbstractESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
@@ -52,8 +52,7 @@
boolean ret=false;
if (mobj instanceof If &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
+ super.isInsertSupported(context, model, mobj, ref)) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java 2008-09-28 17:38:27 UTC (rev 351)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -32,7 +32,7 @@
* This is the model change rule for the Parallel grouping construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ParallelModelChangeRule extends AbstractModelChangeRule {
+public class ParallelModelChangeRule extends AbstractESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
@@ -51,8 +51,7 @@
boolean ret=false;
if (mobj instanceof Parallel &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
+ super.isInsertSupported(context, model, mobj, ref)) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java 2008-09-28 17:38:27 UTC (rev 351)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -32,7 +32,7 @@
* This is the model change rule for the Run composition construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class RunModelChangeRule extends AbstractModelChangeRule {
+public class RunModelChangeRule extends AbstractESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
@@ -51,8 +51,7 @@
boolean ret=false;
if (mobj instanceof Run &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
+ super.isInsertSupported(context, model, mobj, ref)) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java 2008-09-28 17:38:27 UTC (rev 351)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -31,7 +31,7 @@
* This is the model change rule for the Spawn composition construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class SpawnModelChangeRule extends AbstractModelChangeRule {
+public class SpawnModelChangeRule extends AbstractESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
@@ -50,8 +50,7 @@
boolean ret=false;
if (mobj instanceof Spawn &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
+ super.isInsertSupported(context, model, mobj, ref)) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java 2008-09-28 17:38:27 UTC (rev 351)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -32,7 +32,7 @@
* This is the model change rule for the When grouping construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class WhenModelChangeRule extends AbstractModelChangeRule {
+public class WhenModelChangeRule extends AbstractESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
@@ -51,8 +51,7 @@
boolean ret=false;
if (mobj instanceof When &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
+ super.isInsertSupported(context, model, mobj, ref)) {
ret = true;
}
@@ -90,9 +89,19 @@
public boolean insert(ModelChangeContext context,
Model model, ModelObject mobj, ModelObject ref) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=(ESBService)context.getParent();
+ ESBService service=getESBService(context, ref);
When when=(When)mobj;
+ int pos=-1;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
+ pos = service.getActions().indexOf((ESBAction)
+ ref.getSource().getObject());
+ }
+
+ // Create join service
ESBService joinService=
esbModel.createService(service.getCategory(),
esbModel.getUniqueServiceName(service.getCategory(),
@@ -102,158 +111,218 @@
// Check if context role is decision maker
if (when.getRoles().contains(context.getRole())) {
- WhenAction action=new WhenAction(service);
- service.addAction(action, -1);
-
- for (int i=0; i < when.getConditionalBlocks().size(); i++) {
- ConditionalBlock b=when.getConditionalBlocks().get(i);
+ insertWhen(context, model, service,
+ when, joinService, pos);
+ } else {
+ insertSwitch(context, model, service,
+ when, joinService, pos);
+ }
+
+ context.setParent(joinService);
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
- context.setParent(subService);
-
- for (int j=0; j < b.getContents().size(); j++) {
- context.insert(model, b.getContents().get(j), null);
- }
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
-
- ((ESBService)context.getParent()).addAction(schedule, -1);
+ protected void insertWhen(ModelChangeContext context,
+ Model model, ESBService service,
+ When when, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ WhenAction action=new WhenAction(service);
+
+ service.addAction(action, pos);
+
+ for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+ ConditionalBlock b=when.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- when.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
+ context.setParent(subService);
+
+ for (int j=0; j < b.getContents().size(); j++) {
+ context.insert(model, b.getContents().get(j), null);
+ }
- action.addPath(subService.getCategory(),
- subService.getName(), i);
- }
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
- if (service.getFirstSessionBasedAction() == action &&
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
when.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
((Conversation)when.getEnclosingDefinition())));
}
- } else {
+
+ action.addPath(subService.getCategory(),
+ subService.getName(), i);
+ }
+
+ if (service.getFirstSessionBasedAction() == action &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+ }
+
+ protected void insertSwitch(ModelChangeContext context,
+ Model model, ESBService service,
+ When when, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // Check if receive needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
- // Switch action, as role is a decision observer
- SwitchAction switchAction=new SwitchAction(service);
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService switchService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(switchService);
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
- if (la == null) {
- logger.severe("Failed to find lookahead analyser");
- }
+ schedule.setDestination(switchService.getCategory(),
+ switchService.getName(), false);
- service.addAction(switchAction, -1);
+ service.addAction(schedule, pos);
+
+ context.setParent(switchService);
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
+ service = switchService;
+ pos = -1;
+ }
- for (int i=0; i < when.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=when.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ service.addAction(switchAction, pos);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
- esbModel.addService(subService);
+ for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=when.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
+ esbModel.addService(subService);
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(cb);
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, i);
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
-
- ((ESBService)context.getParent()).addAction(schedule, -1);
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, i);
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- when.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+
+ ((ESBService)context.getParent()).addAction(schedule, -1);
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
}
}
}
+ }
- // Only record message router 'routes' if the switch
- // receives request interactions, and it is the first
- // session based action in the service
- if (messageTypes.size() > 0 &&
- service.getFirstSessionBasedAction() == switchAction) {
- ESBService gwService=
- esbModel.getGatewayService();
+ // Only record message router 'routes' if the switch
+ // receives request interactions, and it is the first
+ // session based action in the service
+ if (messageTypes.size() > 0 &&
+ service.getFirstSessionBasedAction() == switchAction) {
+ ESBService gwService=
+ esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- mra.addRoute(service.getCategory(),
- service.getName(),
- false, messageTypes);
- }
- }
- }
-
- if (service.getFirstSessionBasedAction() == switchAction &&
- when.getEnclosingDefinition() instanceof Conversation) {
- switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
}
-
- context.setParent(joinService);
-
- return(true);
+
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
}
private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.jbossesb.model.change");
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java 2008-09-28 17:38:27 UTC (rev 351)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -32,7 +32,7 @@
* This is the model change rule for the While repetition construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class WhileModelChangeRule extends AbstractModelChangeRule {
+public class WhileModelChangeRule extends AbstractESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
@@ -51,8 +51,7 @@
boolean ret=false;
if (mobj instanceof While &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
+ super.isInsertSupported(context, model, mobj, ref)) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRuleTest.java 2008-09-28 17:38:27 UTC (rev 351)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRuleTest.java 2008-09-29 14:57:24 UTC (rev 352)
@@ -226,6 +226,194 @@
}
}
+ public void testInsertWhenActionWithSubsequentActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhenAction) == false) {
+ fail("Action was not WhenAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+
+ public void testInsertWhenActionWithPrecedingActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof WhenAction) == false) {
+ fail("Action 2 was not WhenAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action 2");
+ }
+ }
+
public void testInsertSwitchAction() {
WhenModelChangeRule rule=new WhenModelChangeRule();
@@ -510,4 +698,206 @@
schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
}
}
+
+ public void testInsertSwitchActionWithSubsequentActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ ESBService caseService1=null;
+ ESBService caseService2=null;
+ ESBService caseService3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((caseService1 == null || caseService2 == null ||
+ caseService3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ caseService1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ caseService2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ caseService3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertSwitchActionWithPrecedingActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("First action not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
+
+ ESBService addedService=model.getService(
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+
+ if (addedService == null) {
+ fail("Failed to find service '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"' '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
+ }
+
+ if (addedService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 6) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
}
15 years, 7 months
Overlord SVN: r351 - in cdl/trunk: distribution and 12 other directories.
by overlord-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2008-09-28 13:38:27 -0400 (Sun, 28 Sep 2008)
New Revision: 351
Added:
cdl/trunk/distribution/src/main/release/version.properties
Modified:
cdl/trunk/distribution/pom.xml
cdl/trunk/distribution/src/main/assembly/bin.xml
cdl/trunk/distribution/src/main/release/install/build.xml
cdl/trunk/docs/docbook/userguide/pom.xml
cdl/trunk/docs/docbook/userguide/src/main/module/getting_started.xml
cdl/trunk/pom.xml
cdl/trunk/runtime/jbossesb-assembly/pom.xml
cdl/trunk/runtime/jbossesb/pom.xml
cdl/trunk/samples/jbossesb/brokerage/broker/pom.xml
cdl/trunk/samples/jbossesb/brokerage/supplier/pom.xml
cdl/trunk/samples/jbossesb/common/creditAgency/pom.xml
cdl/trunk/samples/jbossesb/purchasing/store/pom.xml
cdl/trunk/samples/pom.xml
Log:
* Complete the getting_started document to docbook version.
* Add version.properties, so that in the install/build.xml doesn't need to be hard coded version number.
* Add docbook generated documents into the distribution.
* update the runtime module name from 'jbossesb' to 'cdl-jbossesb', so that the mvn eclipse:eclipse will produce the 'cdl-jbossesb' as default project name.
Modified: cdl/trunk/distribution/pom.xml
===================================================================
--- cdl/trunk/distribution/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/distribution/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -34,12 +34,12 @@
<dependencies>
<dependency>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb</artifactId>
+ <artifactId>cdl-jbossesb</artifactId>
<version>${pom.version}</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb-assembly</artifactId>
+ <artifactId>cdl-jbossesb-assembly</artifactId>
<version>${pom.version}</version>
<type>esb</type>
</dependency>
Modified: cdl/trunk/distribution/src/main/assembly/bin.xml
===================================================================
--- cdl/trunk/distribution/src/main/assembly/bin.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/distribution/src/main/assembly/bin.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -38,12 +38,18 @@
<outputDirectory>modules/validator-jbossesb-${cdl.version}</outputDirectory>
</fileSet>
+ <fileSet>
+ <directory>../runtime/jbossesb-assembly/target/overlord-cdl-runtime-jbossesb</directory>
+ <outputDirectory>modules/runtime-jbossesb-${cdl.version}</outputDirectory>
+ </fileSet>
+
<!--Copy files like License and samples etc -->
<fileSet>
<directory>src/main/release</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.txt</include>
+ <include>*.properties</include>
</includes>
</fileSet>
@@ -60,6 +66,13 @@
</includes>
</fileSet>
+ <!-- Copy docbook generated documents -->
+ <fileSet>
+ <directory>../docs/docbook/userguide/target/docbook/publish/en-US</directory>
+ <outputDirectory>docs/userguide</outputDirectory>
+ </fileSet>
+
+ <!-- Copy samples -->
<fileSet>
<directory>src/main/release/samples/jbossesb</directory>
<outputDirectory>samples</outputDirectory>
@@ -88,7 +101,7 @@
<dependencySet>
<outputDirectory>samples/libs</outputDirectory>
<includes>
- <include>org.jboss.soa.overlord.cdl.runtime:jbossesb</include>
+ <include>org.jboss.soa.overlord.cdl.runtime:cdl-jbossesb</include>
<include>org.jboss.jbossesb:rosetta</include>
<include>org.jboss.jbossesb:config-model</include>
<include>log4j:log4j</include>
@@ -106,45 +119,39 @@
<outputDirectory>samples/brokerage/broker/lib</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>org.jboss.soa.overlord.cdl.runtime:jbossesb</include>
+ <include>org.jboss.soa.overlord.cdl.runtime:cdl-jbossesb</include>
<include>org.jboss.jbossesb:rosetta</include>
<include>log4j:log4j</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>samples/brokerage/supplier/lib</outputDirectory>
- <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
+ <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>org.jboss.soa.overlord.cdl.runtime:jbossesb</include>
+ <include>org.jboss.soa.overlord.cdl.runtime:cdl-jbossesb</include>
<include>org.jboss.jbossesb:rosetta</include>
<include>log4j:log4j</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>samples/purchasing/store/lib</outputDirectory>
- <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
+ <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>org.jboss.soa.overlord.cdl.runtime:jbossesb</include>
+ <include>org.jboss.soa.overlord.cdl.runtime:cdl-jbossesb</include>
<include>org.jboss.jbossesb:rosetta</include>
<include>log4j:log4j</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>samples/common/creditAgency/lib</outputDirectory>
- <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
+ <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>org.jboss.soa.overlord.cdl.runtime:jbossesb</include>
+ <include>org.jboss.soa.overlord.cdl.runtime:cdl-jbossesb</include>
<include>org.jboss.jbossesb:rosetta</include>
<include>log4j:log4j</include>
</includes>
</dependencySet>
- <dependencySet>
- <outputDirectory>modules</outputDirectory>
- <includes>
- <include>org.jboss.soa.overlord.cdl.runtime:jbossesb-assembly</include>
- </includes>
- </dependencySet>
</dependencySets>
</assembly>
Modified: cdl/trunk/distribution/src/main/release/install/build.xml
===================================================================
--- cdl/trunk/distribution/src/main/release/install/build.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/distribution/src/main/release/install/build.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -5,6 +5,7 @@
<!-- Load Build Properties File -->
<property file="${org.jboss.esb.deployment.properties}"/>
+ <property file="../version.properties" />
<property name="server.dir" value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}"/>
<property name="conf.dir" value="${server.dir}/conf"/>
@@ -25,18 +26,20 @@
</target>
<target name="deploy-cdl-runtime" description="Deploys Overlord CDL Runtime to the server">
- <echo message="unpack overlord cdl runtime to JBoss ESB server" />
- <unzip src="${modules}/jbossesb-assembly-1.0-SNAPSHOT.esb" dest="${deploy.dir}/overlord-cdl-runtime.esb" />
+ <echo message="Deploy overlord cdl runtime to JBoss ESB server" />
+ <copy todir="${deploy.dir}/overlord-cdl-runtime.esb">
+ <fileset dir="${modules}/runtime-jbossesb-${cdl.version}" />
+ </copy>
</target>
<target name="undeploy-cdl-runtime" description="Undeploys Overlord CDL Runtime">
- <echo message="Remove the overlord-cdl-runtime.esb from JBoss ESB server" />
+ <echo message="Undeploy the overlord-cdl-runtime.esb from JBoss ESB server" />
<delete dir="${deploy.dir}/overlord-cdl-runtime.esb" />
</target>
<target name="deploy-cdl-validator" depends="check.deploy.props" description="Deploys Overlord CDL validator to the server">
<echo message="Deploy Overlord CDL validator" />
- <ant dir="${modules}/validator-jbossesb-1.0-SNAPSHOT" target="deploy">
+ <ant dir="${modules}/validator-jbossesb-${cdl.version}" target="deploy">
<property name="org.jboss.esb.server.home" value="${org.jboss.esb.server.home}"/>
<property name="org.jboss.esb.server.config" value="${org.jboss.esb.server.config}"/>
</ant>
@@ -44,7 +47,7 @@
<target name="undeploy-cdl-validator" depends="check.deploy.props" description="Undeploys Overlord CDL validator to the server">
<echo message="Undeploy Overlord CDL validator" />
- <ant dir="${modules}/validator-jbossesb-1.0-SNAPSHOT" target="undeploy">
+ <ant dir="${modules}/validator-jbossesb-${cdl.version}" target="undeploy">
<property name="org.jboss.esb.server.home" value="${org.jboss.esb.server.home}"/>
<property name="org.jboss.esb.server.config" value="${org.jboss.esb.server.config}"/>
</ant>
Added: cdl/trunk/distribution/src/main/release/version.properties
===================================================================
--- cdl/trunk/distribution/src/main/release/version.properties (rev 0)
+++ cdl/trunk/distribution/src/main/release/version.properties 2008-09-28 17:38:27 UTC (rev 351)
@@ -0,0 +1 @@
+cdl.version=1.0-SNAPSHOT
Modified: cdl/trunk/docs/docbook/userguide/pom.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/docs/docbook/userguide/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -62,6 +62,11 @@
<stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
<finalName>UserGuide.pdf</finalName>
</format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
<format>
<formatName>html_single</formatName>
<stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
Modified: cdl/trunk/docs/docbook/userguide/src/main/module/getting_started.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/src/main/module/getting_started.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/docs/docbook/userguide/src/main/module/getting_started.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -173,7 +173,7 @@
<orderedlist>
<listitem>JBossAS (version 4.2.3.GA or higher), available from http://www.jboss.org/jbossas</listitem>
<listitem>JBossESB (version 4.4.GA or higher), available from http://www.jboss.org/jbossesb</listitem>
- <listitem>Overlord CDL (version 1.0.SNAPSHOT or higher) </listitem>
+ <listitem>Overlord CDL (version 1.0-SNAPSHOT or higher) </listitem>
<listitem>
pi4soa (version 2.0.0 or higher), available from http://www.pi4soa.org
<note>
@@ -202,6 +202,55 @@
Then follow the instructions in the JBossESB installation (install/readme.txt), to deploy JBossESB into the JBossAS environment.
</para>
</listitem>
+
+ <listitem>
+ Install the Overlord CDL distribution
+ <para>
+ Unpack the Overlord CDL distribution into a location alongside the JBossAS installation.
+ </para>
+ <para>
+ <itemizedlist>
+ <listitem>
+ Edit the <emphasis role="bold">install/deployment.properties</emphasis> file to update the JBossAS and JBossESB location settings.
+ </listitem>
+ <listitem>
+ From the install folder, run: <command> ant deploy</command>to deploy both the Overlord CDL conversational ESB actions and service validation capabilities.
+ Or <command>ant deploy-overlord-cdl-runtime</command> to deploy just the conversational ESB actions support, or <command>ant deploy-overlord-cdl-validator</command> to deploy just the service validation capability.
+ </listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
+
+ <listitem>
+ Install pi4soa
+ <para>
+ Unpack the pi4soa pre-packaged Eclipse version into a location alongside the JBossAS installation, or install the relevant plugins (as described on the pi4soa wiki) into an existing Eclipse environment.
+ </para>
+ <para>
+ If just the service validation capabilities are being used, then no further configuration of the Eclipse environment is necessary.
+ However if the conversational ESB actions, with conformance checking against a Choreography Description, will be used, then the following additional steps will be required:
+ </para>
+ <para>
+ <itemizedlist>
+ <listitem>
+ Start the Eclipse environment
+ </listitem>
+ <listitem>
+ Select the “Help - > Software Updates...” menu item
+ </listitem>
+ <listitem>
+ From the <emphasis role="bold"> Available Software</emphasis> tab, press the “Add Site...” button
+ </listitem>
+ <listitem>
+ Press the “Local” button, browse to locate the <emphasis role="bold">tools</emphasis> folder in the Overlord CDL distribution,
+ and then press the OK button. This will cause the local Eclipse update site, bundled with the Overlord CDL distribution, to be add to the <emphasis role="bold"> Available Software </emphasis> tab.
+ </listitem>
+ <listitem>
+ Select the root node of the newly added local update site, and then press the “Install” button and follow the instructions to install the plugins.
+ </listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
</orderedlist>
</section>
Modified: cdl/trunk/pom.xml
===================================================================
--- cdl/trunk/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -38,6 +38,7 @@
</developers>
<modules>
<module>runtime</module>
+ <module>docs/docbook</module>
<module>distribution</module>
</modules>
Modified: cdl/trunk/runtime/jbossesb/pom.xml
===================================================================
--- cdl/trunk/runtime/jbossesb/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/runtime/jbossesb/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb</artifactId>
+ <artifactId>cdl-jbossesb</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Overlord::CDL::Runtime::JBossESB</name>
Modified: cdl/trunk/runtime/jbossesb-assembly/pom.xml
===================================================================
--- cdl/trunk/runtime/jbossesb-assembly/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/runtime/jbossesb-assembly/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb-assembly</artifactId>
+ <artifactId>cdl-jbossesb-assembly</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jboss-esb</packaging>
<name>Overlord::CDL::Runtime::JBossESB-Assembly</name>
@@ -24,7 +24,7 @@
<dependencies>
<dependency>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb</artifactId>
+ <artifactId>cdl-jbossesb</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
@@ -87,7 +87,7 @@
</executions>
</plugin>
- <plugin>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-packaging-maven-plugin</artifactId>
<version>2.0-20080130.110241-9</version>
Modified: cdl/trunk/samples/jbossesb/brokerage/broker/pom.xml
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/broker/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/samples/jbossesb/brokerage/broker/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -24,8 +24,8 @@
</dependency>
<dependency>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <artifactId>cdl-jbossesb</artifactId>
+ <version>${cdl.jbossesb.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
Modified: cdl/trunk/samples/jbossesb/brokerage/supplier/pom.xml
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/supplier/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/samples/jbossesb/brokerage/supplier/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -24,8 +24,8 @@
</dependency>
<dependency>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <artifactId>cdl-jbossesb</artifactId>
+ <version>${cdl.jbossesb.version}</version>
<scope>provided</scope>
</dependency>
Modified: cdl/trunk/samples/jbossesb/common/creditAgency/pom.xml
===================================================================
--- cdl/trunk/samples/jbossesb/common/creditAgency/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/samples/jbossesb/common/creditAgency/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -24,8 +24,8 @@
</dependency>
<dependency>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <artifactId>cdl-jbossesb</artifactId>
+ <version>${cdl.jbossesb.version}</version>
<scope>provided</scope>
</dependency>
Modified: cdl/trunk/samples/jbossesb/purchasing/store/pom.xml
===================================================================
--- cdl/trunk/samples/jbossesb/purchasing/store/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/samples/jbossesb/purchasing/store/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -24,8 +24,8 @@
</dependency>
<dependency>
<groupId>org.jboss.soa.overlord.cdl.runtime</groupId>
- <artifactId>jbossesb</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <artifactId>cdl-jbossesb</artifactId>
+ <version>${cdl.jbossesb.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
Modified: cdl/trunk/samples/pom.xml
===================================================================
--- cdl/trunk/samples/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
+++ cdl/trunk/samples/pom.xml 2008-09-28 17:38:27 UTC (rev 351)
@@ -17,6 +17,7 @@
<properties>
<deploy.dir>/var/local/jboss/server/default/deploy</deploy.dir>
+ <cdl.jbossesb.version>1.0-SNAPSHOT</cdl.jbossesb.version>
</properties>
15 years, 7 months
Overlord SVN: r350 - in cdl/trunk/docs/docbook: userguide and 3 other directories.
by overlord-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2008-09-28 11:15:10 -0400 (Sun, 28 Sep 2008)
New Revision: 350
Added:
cdl/trunk/docs/docbook/userguide/
cdl/trunk/docs/docbook/userguide/pom.xml
cdl/trunk/docs/docbook/userguide/src/
cdl/trunk/docs/docbook/userguide/src/main/
cdl/trunk/docs/docbook/userguide/src/main/images/
cdl/trunk/docs/docbook/userguide/src/main/master.xml
cdl/trunk/docs/docbook/userguide/src/main/module/
cdl/trunk/docs/docbook/userguide/src/main/module/author_group.xml
cdl/trunk/docs/docbook/userguide/src/main/module/getting_started.xml
cdl/trunk/docs/docbook/userguide/src/main/module/template.xml
Removed:
cdl/trunk/docs/docbook/images/
cdl/trunk/docs/docbook/master.xml
cdl/trunk/docs/docbook/module/
cdl/trunk/docs/docbook/src/
Modified:
cdl/trunk/docs/docbook/pom.xml
Log:
* Restructure the docbook module, so that it can be extend easily for producing multiple books.
Deleted: cdl/trunk/docs/docbook/master.xml
===================================================================
--- cdl/trunk/docs/docbook/master.xml 2008-09-27 12:26:19 UTC (rev 349)
+++ cdl/trunk/docs/docbook/master.xml 2008-09-28 15:15:10 UTC (rev 350)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
-<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
-]>
-
-<book lang="en">
- <bookinfo>
- <title>JBoss Overlord CDL 1.0</title>
- <subtitle>User Guide</subtitle>
- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/author_group.xml"/>
- </bookinfo>
-
- <toc/>
- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/getting_started.xml"/>
-
-</book>
Modified: cdl/trunk/docs/docbook/pom.xml
===================================================================
--- cdl/trunk/docs/docbook/pom.xml 2008-09-27 12:26:19 UTC (rev 349)
+++ cdl/trunk/docs/docbook/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
@@ -5,80 +5,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.soa.overlord.cdl</groupId>
- <artifactId>userguide</artifactId>
+ <artifactId>docs</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
- <name>Overlord::CDL::UserGuide</name>
+ <name>Overlord::CDL::Docs</name>
+
+ <modules>
+ <module>userguide</module>
+ </modules>
- <build>
- <plugins>
- <plugin>
- <groupId>org.jboss.maven.plugins</groupId>
- <artifactId>maven-jdocbook-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-docbook</id>
- <phase>package</phase>
- <goals>
- <goal>resources</goal>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jbossorg-docbook-xslt</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jbossorg-jdocbook-style</artifactId>
- <version>1.1.0</version>
- <type>jdocbook-style</type>
- </dependency>
- </dependencies>
- <configuration>
- <sourceDocumentName>master.xml</sourceDocumentName>
- <sourceDirectory>${basedir}</sourceDirectory>
- <imageResource>
- <directory>${basedir}</directory>
- <includes>
- <include>images/**/*</include>
- </includes>
- </imageResource>
- <formats>
- <format>
- <formatName>pdf</formatName>
- <stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
- <finalName>Overlord-CDL.pdf</finalName>
- </format>
- <format>
- <formatName>html</formatName>
- <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
- <format>
- <formatName>html_single</formatName>
- <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
- <format>
- <formatName>eclipse</formatName>
- <stylesheetResource>classpath:/xslt/org/jboss/eclipse.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
- </formats>
- <options>
- <xincludeSupported>true</xincludeSupported>
- <xmlTransformerType>saxon</xmlTransformerType>
- <docbookVersion>1.72.0</docbookVersion>
- </options>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
<repositories>
<repository>
<snapshots>
Added: cdl/trunk/docs/docbook/userguide/pom.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/pom.xml (rev 0)
+++ cdl/trunk/docs/docbook/userguide/pom.xml 2008-09-28 15:15:10 UTC (rev 350)
@@ -0,0 +1,82 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.soa.overlord.cdl.docs</groupId>
+ <artifactId>userguide</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jdocbook</packaging>
+ <name>Overlord::CDL::Docs::userguide</name>
+
+ <parent>
+ <groupId>org.jboss.soa.overlord.cdl</groupId>
+ <artifactId>docs</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.1.2</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-docbook</id>
+ <phase>package</phase>
+ <goals>
+ <goal>resources</goal>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+ <sourceDirectory>${basedir}/src/main</sourceDirectory>
+ <imageResource>
+ <directory>${basedir}/src/main</directory>
+ <includes>
+ <include>images/**/*</include>
+ </includes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
+ <finalName>UserGuide.pdf</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <docbookVersion>1.72.0</docbookVersion>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
Added: cdl/trunk/docs/docbook/userguide/src/main/master.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/src/main/master.xml (rev 0)
+++ cdl/trunk/docs/docbook/userguide/src/main/master.xml 2008-09-28 15:15:10 UTC (rev 350)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
+]>
+
+<book lang="en">
+ <bookinfo>
+ <title>JBoss Overlord CDL 1.0</title>
+ <subtitle>User Guide</subtitle>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/author_group.xml"/>
+ </bookinfo>
+
+ <toc/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module/getting_started.xml"/>
+
+</book>
Added: cdl/trunk/docs/docbook/userguide/src/main/module/author_group.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/src/main/module/author_group.xml (rev 0)
+++ cdl/trunk/docs/docbook/userguide/src/main/module/author_group.xml 2008-09-28 15:15:10 UTC (rev 350)
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<authorgroup>
+ <corpauthor>Gary Brown</corpauthor>
+</authorgroup>
Added: cdl/trunk/docs/docbook/userguide/src/main/module/getting_started.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/src/main/module/getting_started.xml (rev 0)
+++ cdl/trunk/docs/docbook/userguide/src/main/module/getting_started.xml 2008-09-28 15:15:10 UTC (rev 350)
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="gettingstarted">
+ <title>Getting Started</title>
+ <section>
+ <title>SOA Governance with CDL </title>
+ <section>
+ <title>Overview</title>
+ <para>
+ The CDL component of the Overlord SOA governance project aims to leverage the concept of a choreography (or conversation)
+ description to provide design-time and run-time governance of an SOA.
+ </para>
+ <para>
+ A Choreography provides the means to describe the service interactions between multiple parties from a global (or service neutral) perspective.
+ This means that it is possible for an organisation to define how an end-to-end business process should function, regardless of whether orchestrated
+ or peer-to-peer service collaboration will be used.
+ </para>
+ <para>
+ Although in simple situations, a BPEL process description can provide a description of the interactions between multiple services, this only works where a
+ single orchestrating process is in control. The benefit of the choreography description is that it can be used to provide a global view of a process across multiple
+ orchestrated service domains.
+ </para>
+ <para>
+ This document will outline how the Choreography Description is being used as part of Project Overlord to provide SOA governance capabilities
+ for each phase of the SOA lifecycle.
+ </para>
+ <para>
+ When a validated design has been approved by the users, it can be used to generate an initial skeleton of the implementation for each service.
+ The current version of Overlord enables a skeleton implementation to be generated as a JBossESB service configuration file,
+ using 'conversation aware' ESB actions. For more information on these, please see the “Conversational ESB User Guide”.
+ </para>
+ </section>
+
+ <section>
+ <title> SOA Lifecycle Governance </title>
+
+ <section>
+ <title>Design Time Governance</title>
+ <para>
+ Design-time governance is concerned with ensuring that the resulting system correctly implements requirements (whether functional or non-functional).
+ A choreography description can be used to ensure that the implemented system meets the behavioural requirements.
+ </para>
+ <para>
+ The behavioural requirements can be captured as a collection of scenarios (e.g. sequence diagrams) with associated example messages.
+ This enables an unambiguous representation of the business requirements to be stored in a machine processable form, which can subsequently
+ be used to validate other phases of the SOA lifecycle.
+ </para>
+ <para>
+ Once the choreography description for the SOA has been defined, it can be validated against the scenarios,
+ to ensure that the choreography correctly handles all of the business requirements.
+ </para>
+ <para>
+ Once the service enters the implementation phase, it is important to ensure that it continues to adhere to the design
+ and therefore meets the business requirements. Currently this is achieved through the use of techniques such as continuous testing.
+ However this is only as reliable as the quality of the unit tests that have been written.
+ </para>
+ <para>
+ When a 'structured' implementation language has been used, such as WS-BPEL, jPDL or the new 'conversation aware' ESB actions,
+ it will be possible to infer the behaviour of the service being implemented, to compare it against the choreography description.
+ Currently this has been implemented for the “conversation aware” ESB actions, and is demonstrated using the samples in this Overlord-CDL distribution.
+ </para>
+ <para>
+ Detecting incorrectly implemented behaviour at the earliest possible time saves on downstream costs associated with finding and fixing errors.
+ By using static validation against the original design, it ensures that the implemented service will deliver its expected behaviour first time.
+ This is important in building large scale SOAs where different services may be implemented in different locations.
+ </para>
+ <para>
+ There are two other areas where a choreography description can be used as part of design-time governance,
+ that are not currently implemented in Overlord:
+ </para>
+ <itemizedlist>
+ <listitem>
+ Service lookup – the choreography description can be used to determine if a service already exists in the Service Repository that meets the appropriate behavioural requirements.
+ </listitem>
+ <listitem>
+ Service unit testing - this can be achieved using the scenarios originally specified to document the behavioural requirements.
+ Rather than develop an independent source of test data, the scenarios can be used to validate the sequence of messages sent to,
+ and received from, a service, as well as validating the contents of the messages returned from the service under test.
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Runtime Governance</title>
+ <para>
+ Runtime governance ensures that the SOA executes as expected according to predefined policies. In this context, a choreography description can be used in two ways.
+ </para>
+
+ <section>
+ <title> Service validator</title>
+ <para>
+ The choreography description represents the interactions between multiple services to deliver a business goal.
+ To validate the behaviour of each individual service, within the choreography description, the behaviour of each service can be derived from the choreography.
+ </para>
+ <para>
+ The derived behaviour (or “endpoint projection”) of a service can be used within a 'service validator' to monitor the inbound and outbound messages for the service,
+ to ensure they conform to the expected behaviour.
+ If an invalid message is detected, it would be possible to block it, to prevent it from causing subsequent problems in downstream systems.
+ The error can also be reported to a central management capability.
+ </para>
+ <para>
+ The CDL component of Overlord provides the ability to configure service validators to monitor the behaviour of individual services.
+ An enhanced version of the JBossESB trailblazer example has been included, with the appropriate validator configuration, to demonstrate this mechanism.
+ </para>
+ </section>
+
+ <section>
+ <title>Process correlation</title>
+ <para>
+ Validating each service locally can enable errors to be detected quickly,
+ and the effects of the error prevented from contaminating other systems by blocking the erroneous messages.
+ </para>
+ <para>
+ However local service specific validation may not be adequate to identify errors that would affect the end-to-end business process.
+ Therefore the message activity at each service validator can be reported to a central 'process correlation engine' which can reconstitute a global view of the business transaction,
+ and determine if it matches the expected behaviour as defined in the choreography description.
+ </para>
+ <para>
+ The benefit of a correlated global view of the distributed business transaction is that it can be further analysed to ensure other governance polices have been followed – e.g. SLAs.
+ </para>
+ <para>
+ The pi4soa tool suite includes a simple GUI based monitoring tool to display the information obtained from correlating message events associated with individual services.
+ The trailblazer example has been written to cause out of sequence messages under certain circumstances. See the “Samples Guide” for more information on how to run this example.
+ </para>
+ </section>
+ </section>
+ </section>
+
+ <section>
+ <title> First Steps </title>
+ <para>The first step will be to follow the instructions in the next chapter to install Overlord. </para>
+ <para> Once installed, the next step should be to try out the examples in the samples folder. The examples consistent of:</para>
+ <itemizedlist>
+ <listitem>
+ Service Validation related examples
+ <para>
+ The samples folder contains an enhanced version of the trailblazer example from the JBossESB, with the addition of a File Based Bank, and message content including a conversation id to enable the messages to be correlated with a specific session.
+ </para>
+ </listitem>
+ <listitem>
+ Conversation aware ESB actions, with conformance checking against Choreography
+ <para>
+ Two examples have been included, one simple example (purchasing) and the other more advanced (brokerage). Both relate to the business process of purchasing items. The second example introduces the concept of a broker to act on behalf of the customer, interacting with multiple potential suppliers.
+ </para>
+ <para>
+ These examples show how a service implementation (built using “conversation aware ESB actions” in this case), can be continuously checked for conformance against a choreography description.
+ </para>
+ <para>
+ The final step should be to review the other documents in the docs folder to understand more about each capability, and then try using the techniques on your own project.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ </section>
+
+ <section>
+ <title>Installation</title>
+
+ <section>
+ <title> Overview </title>
+ <para>
+ This section describes the installation procedure for the Overlord CDL based governance capabilities. These capabilities are:
+ </para>
+ <itemizedlist>
+ <listitem> Conversation aware ESB Actions with conformance checking against a Choreography Description </listitem>
+ <listitem> ESB Service validation against a Choreography Description </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Prerequisites</title>
+ <orderedlist>
+ <listitem>JBossAS (version 4.2.3.GA or higher), available from http://www.jboss.org/jbossas</listitem>
+ <listitem>JBossESB (version 4.4.GA or higher), available from http://www.jboss.org/jbossesb</listitem>
+ <listitem>Overlord CDL (version 1.0.SNAPSHOT or higher) </listitem>
+ <listitem>
+ pi4soa (version 2.0.0 or higher), available from http://www.pi4soa.org
+ <note>
+ <para>
+ It is recommended that a pre-packaged version is used, which includes all of the necessary Eclipse related plugins.
+ However the plugins can be installed separately into an existing Eclipse environment by following the instructions on the www.pi4soa.org wiki.
+ </para>
+ </note>
+ </listitem>
+ <listitem>
+ Ant, available from http://ant.apache.org/
+ </listitem>
+ </orderedlist>
+ </section>
+
+ <section>
+ <title>Installation Instructions</title>
+ <orderedlist>
+ <listitem>
+ Install JBossAS
+ <para> Unpack the JBossAS installation into the required location. </para>
+ </listitem>
+ <listitem>
+ Install JBossESB
+ <para> Unpack the JBossESB installation into a location alongside the JBossAS installation.
+ Then follow the instructions in the JBossESB installation (install/readme.txt), to deploy JBossESB into the JBossAS environment.
+ </para>
+ </listitem>
+
+ </orderedlist>
+ </section>
+
+</section>
+
+</chapter>
Added: cdl/trunk/docs/docbook/userguide/src/main/module/template.xml
===================================================================
--- cdl/trunk/docs/docbook/userguide/src/main/module/template.xml (rev 0)
+++ cdl/trunk/docs/docbook/userguide/src/main/module/template.xml 2008-09-28 15:15:10 UTC (rev 350)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+<chapter id="chapter-id">
+ <title>Chapter title</title>
+ <para>To be written...</para>
+</chapter>
15 years, 7 months
Overlord SVN: r349 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-09-27 08:26:19 -0400 (Sat, 27 Sep 2008)
New Revision: 349
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/LanguageToConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java
Log:
Updated ModelChangeRule interface to check if referenced model object is appropriate for insertion.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -41,15 +41,20 @@
* @param context The context
* @param model The model
* @param mobj The model object being inserted
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj,
+ ModelObject ref) {
boolean ret=false;
if (mobj instanceof ConversationInteraction &&
- context.getParent() instanceof ESBService &&
+ (context.getParent() instanceof ESBService ||
+ (ref != null && ref.getSource().getObject()
+ instanceof AbstractESBAction &&
+ ((AbstractESBAction)ref.getSource().getObject()).getService() != null)) &&
model instanceof ESBLanguageModel) {
ret = true;
}
@@ -329,7 +334,7 @@
endService.addAction(action, endPos);
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action &&
+ if (endService.getFirstSessionBasedAction() == action &&
interaction.getEnclosingDefinition() instanceof Conversation) {
action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
((Conversation)interaction.getEnclosingDefinition())));
@@ -365,14 +370,14 @@
}
// Check if existing actions need to be moved
- if (pos != -1) {
+ if (pos != -1 && service != endService) {
for (int i=pos+1; i < service.getActions().size();) {
- ESBService extraService=(ESBService)context.getParent();
+ //ESBService extraService=(ESBService)context.getParent();
ESBAction act=service.getActions().get(i);
service.getActions().remove(i);
- extraService.addAction(act, -1);
+ endService.addAction(act, -1);
}
}
@@ -391,8 +396,8 @@
new java.util.Vector<MessageSignature>();
mtypes.add(interaction.getMessageSignature());
- mra.addRoute(((ESBService)context.getParent()).getCategory(),
- ((ESBService)context.getParent()).getName(),
+ mra.addRoute(endService.getCategory(),
+ endService.getName(),
service.isRoot(), mtypes);
}
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -41,11 +41,12 @@
* @param context The context
* @param model The model
* @param mobj The model object causing the change
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj, ModelObject ref) {
boolean ret=false;
if (mobj instanceof Conversation &&
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/IfModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -43,11 +43,12 @@
* @param context The context
* @param model The model
* @param mobj The model object being inserted
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj, ModelObject ref) {
boolean ret=false;
if (mobj instanceof If &&
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/LanguageToConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/LanguageToConversationModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/LanguageToConversationModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -39,11 +39,12 @@
* @param context The context
* @param model The model
* @param mobj The model object being inserted
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj, ModelObject ref) {
boolean ret=false;
if (mobj instanceof ConversationModel &&
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ParallelModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -42,11 +42,12 @@
* @param context The context
* @param model The model
* @param mobj The model object being inserted
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj, ModelObject ref) {
boolean ret=false;
if (mobj instanceof Parallel &&
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/RunModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -42,11 +42,12 @@
* @param context The context
* @param model The model
* @param mobj The model object being inserted
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj, ModelObject ref) {
boolean ret=false;
if (mobj instanceof Run &&
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/SpawnModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -41,11 +41,12 @@
* @param context The context
* @param model The model
* @param mobj The model object being inserted
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj, ModelObject ref) {
boolean ret=false;
if (mobj instanceof Spawn &&
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhenModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -42,11 +42,12 @@
* @param context The context
* @param model The model
* @param mobj The model object being inserted
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj, ModelObject ref) {
boolean ret=false;
if (mobj instanceof When &&
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/WhileModelChangeRule.java 2008-09-27 12:26:19 UTC (rev 349)
@@ -42,11 +42,12 @@
* @param context The context
* @param model The model
* @param mobj The model object being inserted
+ * @param ref The optional reference model object
* @return Whether the rule supports the supplied information
*/
@Override
public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
+ Model model, ModelObject mobj, ModelObject ref) {
boolean ret=false;
if (mobj instanceof While &&
15 years, 7 months
Overlord SVN: r348 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src: test/org/jboss/tools/overlord/cdl/jbossesb/model/change and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-09-26 11:50:54 -0400 (Fri, 26 Sep 2008)
New Revision: 348
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
Log:
Further update + test to cater for 'create session' action being at the beginning of an action pipeline.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-26 14:56:27 UTC (rev 347)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-26 15:50:54 UTC (rev 348)
@@ -291,7 +291,8 @@
// descriptor - i.e. if insert at end, but current service
// already has service based actions, or reference object
// provided, but is not first position
- if ((ref == null && service.isSessionBased()) || pos > 0) {
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
// Already has activities, so need to separate
// into another service descriptor
@@ -420,7 +421,22 @@
interaction.getMessageSignature(), ids, locators);
}
}
+
+ protected boolean shouldScheduleNewService(ESBService service,
+ int pos) {
+ boolean ret=false;
+ for (int i=0; ret == false && i < pos; i++) {
+ ESBAction action=service.getActions().get(i);
+
+ if (action.isSessionBased() && !action.isCreateSession()) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
/**
* This method determines whether the rule is appropriate
* for the supplied type of model, parent (in the context)
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2008-09-26 14:56:27 UTC (rev 347)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2008-09-26 15:50:54 UTC (rev 348)
@@ -108,6 +108,94 @@
}
}
+ public void testInsertFirstReceiveAfterCreateSessionAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add 'create session' action
+ TestESBAction act=new TestESBAction();
+ act.setCreateSession(true);
+ service.addAction(act, -1);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setToRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof TestESBAction) == false) {
+ fail("Action was not TestESBAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(1);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 1) {
+ fail("One route expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
public void testInsertSecondReceiveAction() {
ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
15 years, 7 months
Overlord SVN: r347 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-09-26 10:56:27 -0400 (Fri, 26 Sep 2008)
New Revision: 347
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
Log:
Additional test to insert a receive between two sends.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2008-09-26 14:15:53 UTC (rev 346)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/test/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2008-09-26 14:56:27 UTC (rev 347)
@@ -260,7 +260,7 @@
}
- public void testInsertThirdMiddleReceiveAction() {
+ public void testInsertMiddleReceiveBetweenTwoReceives() {
ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
TestESBLanguageModel model=new TestESBLanguageModel();
@@ -509,7 +509,7 @@
}
}
- public void testInsertThirdMiddleSendAction() {
+ public void testInsertMiddleSendBetweenTwoReceives() {
ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
TestESBLanguageModel model=new TestESBLanguageModel();
@@ -762,6 +762,211 @@
}
}
+ public void testInsertMiddleReceiveBetweenTwoSends() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setFromRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setFromRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
+ fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction send2=(SendMessageAction)
+ service.getActions().get(1);
+
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (send2.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+send2.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ send2.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // Now second service identified, add new receive
+ // action to ensure that third service inserted in the
+ // middle
+ ConversationInteraction mobj3=new ConversationInteraction();
+ mobj3.setToRole(role);
+ conv.getBlock().getContents().add(mobj3);
+
+ MessageSignature msig3=new MessageSignature();
+ mobj3.setMessageSignature(msig3);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setNamespace("ns");
+ ref3.setLocalpart("lp3");
+
+ msig3.getTypes().add(ref3);
+
+ // Insert into position 1, which should be after first
+ // send
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+ fail("Failed to insert 3");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Now Expecting 2 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+ }
+
+ if ((newService.getActions().get(1) instanceof SendMessageAction) == false) {
+ fail("Action 2 was not SendMessageAction: "+newService.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ ReceiveMessageAction recv3=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+ String mtype3=InteractionUtil.getTypeString(ref3);
+
+ if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
+ fail("Message type '"+recv3.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype3);
+ }
+ }
+
public void testInsertReceiveRequestAction() {
String fromRoleName="role1";
String toRoleName="role2";
15 years, 7 months
Overlord SVN: r346 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-09-26 10:15:53 -0400 (Fri, 26 Sep 2008)
New Revision: 346
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
Log:
Fix insertion of receive interaction in the middle of two other receives.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-25 18:39:40 UTC (rev 345)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-26 14:15:53 UTC (rev 346)
@@ -263,13 +263,36 @@
ESBLanguageModel esbModel, ConversationInteraction interaction,
ModelObject ref) {
ESBService service=getESBService(context, ref);
+ ESBService endService=service;
- // TODO: Create a new service to receive the
- // message and add a schedule service to link
- // to this new service - issue, how do we
- // deal with request/response
- if (service.isCreateSession() == false &&
- service.isSessionBased()) {
+ int pos=-1;
+ int endPos=-1;
+ boolean f_subsequentInitiator=false;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
+ pos = service.getActions().indexOf((ESBAction)
+ ref.getSource().getObject());
+
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
+ }
+ }
+ }
+
+ endPos = pos;
+
+ // Check if receive needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if ((ref == null && service.isSessionBased()) || pos > 0) {
+
// Already has activities, so need to separate
// into another service descriptor
ESBService recvService=esbModel.createService(
@@ -286,40 +309,72 @@
schedule.setDestination(recvService.getCategory(),
recvService.getName(), false);
-// service.addAction(schedule, -1);
- int pos=-1;
-
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
- pos = service.getActions().indexOf((ESBAction)
- ref.getSource().getObject());
- }
-
service.addAction(schedule, pos);
context.setParent(recvService);
+
+ endService = recvService;
+ endPos = 0;
}
ReceiveMessageAction action=
- new ReceiveMessageAction((ESBService)context.getParent());
-
+ new ReceiveMessageAction(endService);
+
if (interaction.getMessageSignature().getOperation() != null) {
action.setOperation(interaction.getMessageSignature().getOperation());
}
setMessageType(action, interaction);
+
+ endService.addAction(action, endPos);
- // TODO: Decide how to determine position, in situations
- // where new service no created
- ((ESBService)context.getParent()).addAction(action, -1);
-
if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action &&
interaction.getEnclosingDefinition() instanceof Conversation) {
action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
((Conversation)interaction.getEnclosingDefinition())));
}
+ // Check if subsequent initiator found, requiring
+ // a new service
+ if (f_subsequentInitiator) {
+
+ ESBService extraService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(endService.getCategory(),
+ endService.getName()));
+
+ esbModel.addService(extraService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(endService);
+
+ schedule.setDestination(extraService.getCategory(),
+ extraService.getName(), false);
+
+ endService.addAction(schedule, endPos+1);
+
+ // Move pointer on, as now additional 'schedule' action
+ pos++;
+
+ context.setParent(extraService);
+
+ endService = extraService;
+ endPos = -1;
+ }
+
+ // Check if existing actions need to be moved
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBService extraService=(ESBService)context.getParent();
+
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ extraService.addAction(act, -1);
+ }
+ }
+
// If not a response, then add to the gateway
if (interaction.getReplyToLabel() == null) {
ESBService gwService=esbModel.getGatewayService();
15 years, 7 months