diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-spring')
3 files changed, 66 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java index 74cd3f4290..f06f05a46a 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java +++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java @@ -21,6 +21,8 @@ package org.apache.tuscany.sca.implementation.spring; import java.util.ArrayList; import java.util.List; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicySet; @@ -39,6 +41,9 @@ public class SpringSCAReferenceElement { private List<Intent> intents = new ArrayList<Intent>(); private List<PolicySet> policySets = new ArrayList<PolicySet>(); + private List<QName> intentNames = new ArrayList<QName>(); + private List<QName> policySetNames = new ArrayList<QName>(); + public SpringSCAReferenceElement() { } @@ -80,12 +85,21 @@ public class SpringSCAReferenceElement { return policySets; } + public List<QName> getIntentNames() { + return intentNames; + } + + public List<QName> getPolicySetNames() { + return policySetNames; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("SpringSCAReferenceElement [name=").append(name).append(", type=").append(type) .append(", defaultBean=").append(defaultBean).append(", intents=").append(intents).append(", policySets=") - .append(policySets).append("]"); + .append(policySets).append(", intentNames=").append(intentNames).append(", policySetNames=") + .append(policySetNames).append("]"); return builder.toString(); } diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java index 181bd7a787..38c124c3b4 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java +++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java @@ -21,6 +21,8 @@ package org.apache.tuscany.sca.implementation.spring; import java.util.ArrayList; import java.util.List; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicySet; @@ -38,6 +40,8 @@ public class SpringSCAServiceElement { private String target; private List<Intent> intents = new ArrayList<Intent>(); private List<PolicySet> policySets = new ArrayList<PolicySet>(); + private List<QName> intentNames = new ArrayList<QName>(); + private List<QName> policySetNames = new ArrayList<QName>(); public SpringSCAServiceElement() { @@ -80,12 +84,21 @@ public class SpringSCAServiceElement { return policySets; } + public List<QName> getIntentNames() { + return intentNames; + } + + public List<QName> getPolicySetNames() { + return policySetNames; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("SpringSCAServiceElement [name=").append(name).append(", type=").append(type) .append(", target=").append(target).append(", intents=").append(intents).append(", policySets=") - .append(policySets).append("]"); + .append(policySets).append(", intentNames=").append(intentNames).append(", policySetNames=") + .append(policySetNames).append("]"); return builder.toString(); } diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java index 9d360ebc2b..cca7586734 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java +++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java @@ -41,6 +41,8 @@ import java.util.jar.Manifest; import java.util.logging.Level; import java.util.logging.Logger; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.Multiplicity; @@ -76,6 +78,9 @@ import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper; 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.Intent; +import org.apache.tuscany.sca.policy.PolicyFactory; +import org.apache.tuscany.sca.policy.PolicySet; /** * Introspects a Spring XML application-context configuration file to create <implementation-spring../> @@ -89,6 +94,7 @@ public class SpringXMLComponentTypeLoader { private ExtensionPointRegistry registry; private ContributionFactory contributionFactory; private AssemblyFactory assemblyFactory; + private PolicyFactory policyFactory; private JavaInterfaceFactory javaFactory; private SpringBeanIntrospector beanIntrospector; @@ -99,6 +105,7 @@ public class SpringXMLComponentTypeLoader { this.registry = registry; FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); this.assemblyFactory = factories.getFactory(AssemblyFactory.class); + this.policyFactory = factories.getFactory(PolicyFactory.class); this.javaFactory = factories.getFactory(JavaInterfaceFactory.class); this.contributionFactory = factories.getFactory(ContributionFactory.class); this.xmlBeanDefinitionLoader = @@ -219,6 +226,7 @@ public class SpringXMLComponentTypeLoader { appCxtProperties, appCxtBeans, context); + populatePolicies(appCxtServices, appCxtReferences); } // Validate the beans from individual application context for uniqueness validateBeans(appCxtBeans, appCxtServices, appCxtReferences, appCxtProperties, context.getMonitor()); @@ -239,6 +247,35 @@ public class SpringXMLComponentTypeLoader { return; } // end method loadFromXML + public void populatePolicies(List<SpringSCAServiceElement> appCxtServices, + List<SpringSCAReferenceElement> appCxtReferences) { + for (SpringSCAReferenceElement e : appCxtReferences) { + for (QName qn : e.getIntentNames()) { + Intent intent = policyFactory.createIntent(); + intent.setName(qn); + e.getRequiredIntents().add(intent); + } + for (QName qn : e.getPolicySetNames()) { + PolicySet ps = policyFactory.createPolicySet(); + ps.setName(qn); + e.getPolicySets().add(ps); + } + } + + for (SpringSCAServiceElement e : appCxtServices) { + for (QName qn : e.getIntentNames()) { + Intent intent = policyFactory.createIntent(); + intent.setName(qn); + e.getRequiredIntents().add(intent); + } + for (QName qn : e.getPolicySetNames()) { + PolicySet ps = policyFactory.createPolicySet(); + ps.setName(qn); + e.getPolicySets().add(ps); + } + } + } + private URL resolveLocation(ModelResolver resolver, String contextPath, ProcessorContext context) throws MalformedURLException, ContributionReadException { URL resource = null; |