diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-24 22:34:52 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-24 22:34:52 +0000 |
commit | 27fa5a2336ac250059a5440b5676c757bab68ae2 (patch) | |
tree | 249d53a80b03c48159eb8d7215d608a7214e0c03 /sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java | |
parent | cef9c8bdbc68160541685456df3ee8a09b38f0a3 (diff) |
Populate intents and policySets from sca:reference and sca:service elements
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@988747 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java')
-rw-r--r-- | sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java | 37 |
1 files changed, 37 insertions, 0 deletions
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; |