[savara-commits] savara SVN: r453 - in trunk/tools/plugins: org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Nov 2 13:28:30 EDT 2010
Author: objectiser
Date: 2010-11-02 13:28:30 -0400 (Tue, 02 Nov 2010)
New Revision: 453
Modified:
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
Log:
SAVARA-143 - should now generate BPEL/WSDL correctly for participants with multiple role types.
Modified: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java 2010-11-02 17:27:36 UTC (rev 452)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java 2010-11-02 17:28:30 UTC (rev 453)
@@ -27,10 +27,12 @@
import org.scribble.expression.xpath.model.XPathExpression;
import org.pi4soa.cdl.util.*;
import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.NameSpaceUtil;
import org.pi4soa.common.xml.XMLUtils;
public class ConversationInteractionConverterRuleImpl implements ConverterRule {
+ private static final String INTERFACE_NAME = "interfaceName";
private static final String FAULT_NAME = "faultName";
private static final String MESSAGE_TYPE_LOCALPART = "messageTypeLocalPart";
private static final String MESSAGE_TYPE_NAMESPACE = "messageTypeNameSpace";
@@ -355,6 +357,13 @@
cb.getContents().add(interaction);
+ // Set interface name
+ if (cdl.getToRoleType() != null) {
+ // TODO: Deal with interfaces that have multiple behaviours
+ interaction.getAnnotations().put(INTERFACE_NAME,
+ getInterfaceName(cdl));
+ }
+
if (details.getAction() == ExchangeActionType.REQUEST) {
interaction.setFromRole(fromRole);
interaction.setToRole(toRole);
@@ -621,5 +630,33 @@
return(ret);
}
+ /**
+ * This method returns the interface name associated with the
+ * supplied role type.
+ *
+ * @param interaction The interaction
+ * @return The interface name
+ */
+ protected String getInterfaceName(org.pi4soa.cdl.Interaction interaction) {
+ String ret=null;
+
+ if (interaction != null) {
+ String intfName=InteractionUtil.getInterface(interaction);
+
+ if (NamesUtil.isSet(intfName) == false) {
+ // If no name set, then use the 'to' role type name
+ // Similar to logic used in org.pi4soa.service.behavior.projection.DefaultServiceTypeResolver
+ intfName = interaction.getToRoleType().getName();
+ }
+
+ String ns=CDLTypeUtil.getNamespace(intfName, interaction, true);
+ String lp=XMLUtils.getLocalname(intfName);
+
+ ret = NameSpaceUtil.getFullyQualifiedName(ns, lp);
+ }
+
+ return(ret);
+ }
+
private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
}
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2010-11-02 17:27:36 UTC (rev 452)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2010-11-02 17:28:30 UTC (rev 453)
@@ -561,10 +561,17 @@
if (useRole != null &&
useRole.getAnnotations().containsKey(Contract.class.getName())) {
Contract contract=(Contract)useRole.getAnnotations().get(Contract.class.getName());
-
- if (contract.getInterfaces().size() > 0) {
- Interface intf=contract.getInterfaces().iterator().next();
+ Interface intf=null;
+
+ if (pl.getMyRole() != null) {
+ intf = contract.getInterface(pl.getMyRole());
+ }
+ if (intf == null && contract.getInterfaces().size() > 0) {
+ intf = contract.getInterfaces().iterator().next();
+ }
+
+ if (intf != null) {
String prefix=null;
String portType=intf.getName();
@@ -588,10 +595,17 @@
if (role.getAnnotations().containsKey(Contract.class.getName())) {
Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
-
- if (contract.getInterfaces().size() > 0) {
- Interface intf=contract.getInterfaces().iterator().next();
+ Interface intf=null;
+
+ if (pl.getMyRole() != null) {
+ intf = contract.getInterface(pl.getMyRole());
+ }
+ if (intf == null && contract.getInterfaces().size() > 0) {
+ intf = contract.getInterfaces().iterator().next();
+ }
+
+ if (intf != null) {
String prefix=null;
String portType=intf.getName();
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2010-11-02 17:27:36 UTC (rev 452)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2010-11-02 17:28:30 UTC (rev 453)
@@ -36,6 +36,8 @@
@RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
public class ConversationInteractionModelChangeRule extends AbstractBPELModelChangeRule {
+ private static final String INTERFACE_NAME = "interfaceName";
+
/**
* This method determines whether the rule is appropriate
* for the supplied type of model, parent (in the context) and inserted
@@ -133,9 +135,19 @@
if (roleType != null) {
contract = ModelChangeUtils.getContract(context, roleType.getName());
- // Assume that contract only has one interface for now
- if (contract != null && contract.getInterfaces().size() > 0) {
- intf = contract.getInterfaces().iterator().next();
+ if (contract != null) {
+ if (interaction.getAnnotations().containsKey(INTERFACE_NAME)) {
+ String intfName=(String)interaction.getAnnotations().get(INTERFACE_NAME);
+ intf = contract.getInterface(intfName);
+
+ if (intf == null) {
+ // Try localpart
+ javax.xml.namespace.QName qname=javax.xml.namespace.QName.valueOf(intfName);
+ intf = contract.getInterface(qname.getLocalPart());
+ }
+ } else if (contract.getInterfaces().size() > 0) {
+ intf = contract.getInterfaces().iterator().next();
+ }
}
}
@@ -249,10 +261,19 @@
} else if (InteractionPatterns.isInteractionPickPathTrigger(interaction) == false) {
act = new Receive(bpelModel);
+
+ String intfName=(String)interaction.getAnnotations().get("interfaceName");
+
+ if (intfName != null && intfName.trim().length() > 0) {
+ javax.xml.namespace.QName qname=javax.xml.namespace.QName.valueOf(intfName);
+ intfName = qname.getLocalPart();
+ } else {
+ intfName = role.getName();
+ }
if (InteractionUtil.isRequest(interaction)) {
- pl.setMyRole(role.getName()+"Service");
+ pl.setMyRole(intfName); //role.getName()+"Service");
//pl.setPartnerRole(interaction.getToRole().getName());
pl.setName(interaction.getFromRole().getName()+"To"+role.getName());
@@ -266,7 +287,7 @@
//portType = role.getName()+"PT";
} else {
- pl.setMyRole(role.getName()+"Requester");
+ pl.setMyRole(intfName); //role.getName()+"Requester");
pl.setPartnerRole(interaction.getFromRole().getName()+"Service");
pl.setName(role.getName()+"To"+interaction.getFromRole().getName());
More information about the savara-commits
mailing list