diff options
Diffstat (limited to 'sca-java-2.x/trunk')
6 files changed, 40 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF index d7cb4484ea..e61a52374e 100644 --- a/sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF @@ -22,6 +22,7 @@ Bundle-Description: Apache Tuscany SCA Java Interface Model Import-Package: javax.xml.namespace,
javax.xml.stream,
org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java index 5faa8dfa03..f3ced5c3e5 100644 --- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java @@ -32,6 +32,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; +import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor; import org.apache.tuscany.sca.contribution.processor.ContributionReadException; import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; @@ -39,6 +40,7 @@ import org.apache.tuscany.sca.contribution.processor.ProcessorContext; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ClassReference; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; @@ -47,6 +49,7 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.apache.tuscany.sca.policy.PolicyFactory; import org.oasisopen.sca.annotation.AllowsPassByReference; import org.oasisopen.sca.annotation.Callback; import org.oasisopen.sca.annotation.ComponentName; @@ -68,10 +71,17 @@ import org.oasisopen.sca.annotation.Service; */ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfaceContract>, JavaConstants { private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912"; - private JavaInterfaceFactory javaFactory; + private JavaInterfaceFactory javaFactory; + private ExtensionPointRegistry extensionPoints; + private PolicyFactory policyFactory; + private PolicySubjectProcessor policyProcessor; - public JavaInterfaceProcessor(FactoryExtensionPoint modelFactories) { + public JavaInterfaceProcessor(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; + FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); + this.policyFactory = modelFactories.getFactory(PolicyFactory.class); + this.policyProcessor = new PolicySubjectProcessor(policyFactory); this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); } @@ -142,8 +152,10 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa if (remotable != null) { javaInterfaceContract.getInterface().setRemotable(Boolean.parseBoolean(remotable)); } - + // Read intents and policy sets + policyProcessor.readPolicies(javaInterfaceContract.getInterface(), reader); + // Skip to end element while (reader.hasNext()) { if (reader.next() == END_ELEMENT && INTERFACE_JAVA_QNAME.equals(reader.getName())) { @@ -168,6 +180,8 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa writer.writeAttribute(CALLBACK_INTERFACE, javaCallbackInterface.getName()); } + policyProcessor.writePolicyAttributes(javaInterface, writer); + writer.writeEndElement(); } diff --git a/sca-java-2.x/trunk/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite b/sca-java-2.x/trunk/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite index 927847c1c9..e5455dc970 100644 --- a/sca-java-2.x/trunk/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite +++ b/sca-java-2.x/trunk/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite @@ -23,7 +23,7 @@ name="Calculator"> <service name="CalculatorService" promote="CalculatorServiceComponent"> - <interface.java interface="calculator.CalculatorService"/> + <interface.java interface="calculator.CalculatorService" requires="calc:intent1" policySets="calc:policySet1" /> </service> <component name="CalculatorServiceComponent"> diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/interface-wsdl/META-INF/MANIFEST.MF index bd2392b1d4..75ad6812be 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/interface-wsdl/META-INF/MANIFEST.MF @@ -21,6 +21,7 @@ Import-Package: javax.wsdl, javax.xml.namespace,
javax.xml.stream,
org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
org.apache.tuscany.sca.common.java.io;version="2.0.0",
org.apache.tuscany.sca.common.xml;version="2.0.0",
org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java index 8c4a986525..f1dd8bfdda 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java @@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; +import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor; import org.apache.tuscany.sca.contribution.processor.ContributionReadException; import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; @@ -38,6 +39,7 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; @@ -46,6 +48,7 @@ import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.apache.tuscany.sca.policy.PolicyFactory; /** * Handles a <interface.wsdl ... /> element in a SCDL file @@ -54,8 +57,9 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfaceContract>, WSDLConstants { private WSDLFactory wsdlFactory; - private InterfaceContractMapper interfaceContractMapper; + private PolicyFactory policyFactory; + private PolicySubjectProcessor policyProcessor; public WSDLInterfaceProcessor(ExtensionPointRegistry registry) { FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); @@ -63,6 +67,9 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(InterfaceContractMapper.class); this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class); + + this.policyFactory = modelFactories.getFactory(PolicyFactory.class); + this.policyProcessor = new PolicySubjectProcessor(policyFactory); } /** * Report a warning. @@ -195,6 +202,9 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa ((WSDLInterface)wsdlInterfaceContract.getInterface()).getName().toString(), remotable); } + + // Read intents and policy sets + policyProcessor.readPolicies(wsdlInterfaceContract.getInterface(), reader); // Skip to end element while (reader.hasNext()) { @@ -229,6 +239,8 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsdlInterfaceContract.getLocation()); } + policyProcessor.writePolicyAttributes(wsdlInterface, writer); + writer.writeEndElement(); } @@ -259,9 +271,12 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa // WSDLInterface to the resolver try { wsdlDefinition.setDefinition(portType.getDefinition()); - wsdlInterface = wsdlFactory.createWSDLInterface(portType.getElement(), wsdlDefinition, resolver, monitor); - wsdlInterface.setWsdlDefinition(wsdlDefinition); - resolver.addModel(wsdlInterface, context); + WSDLInterface newWSDLInterface = wsdlFactory.createWSDLInterface(portType.getElement(), wsdlDefinition, resolver, monitor); + newWSDLInterface.setWsdlDefinition(wsdlDefinition); + newWSDLInterface.getRequiredIntents().addAll(wsdlInterface.getRequiredIntents()); + newWSDLInterface.getPolicySets().addAll(wsdlInterface.getPolicySets()); + resolver.addModel(newWSDLInterface, context); + wsdlInterface = newWSDLInterface; } catch (InvalidInterfaceException e) { ContributionResolveException ce = new ContributionResolveException("Invalid interface when resolving " + portType.toString(), e); diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite index a71e0a55f8..9d714e8169 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite @@ -25,7 +25,7 @@ <service name="CalculatorService" promote="CalculatorServiceComponent"> <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)" - wsdli:wsdlLocation="http://tempuri.org"/> + wsdli:wsdlLocation="http://tempuri.org" requires="calc:intent1" policySets="calc:policySet1"/> </service> <component name="CalculatorServiceComponent"> |