diff options
Diffstat (limited to 'java/sca/modules/implementation-spring')
4 files changed, 36 insertions, 71 deletions
diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java index 720db77e35..3aa257686d 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java @@ -20,29 +20,14 @@ package org.apache.tuscany.sca.implementation.spring.introspect; import java.util.List; -import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.implementation.java.IntrospectionException; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; -import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor; -import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor; import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; /** * Provides introspection functions for Spring beans @@ -62,32 +47,11 @@ public class SpringBeanIntrospector { * @param javaFactory The Java Interface Factory to use * @param policyFactory The Policy Factory to use. */ - public SpringBeanIntrospector(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory, - PolicyFactory policyFactory, + public SpringBeanIntrospector(ExtensionPointRegistry registry, List<SpringConstructorArgElement> conArgs) { - javaImplementationFactory = new DefaultJavaImplementationFactory(); - - // Create the list of class visitors - BaseJavaClassVisitor[] extensions = - new BaseJavaClassVisitor[] { - new ConstructorProcessor(assemblyFactory), - new ComponentNameProcessor(assemblyFactory), - new ContextProcessor(assemblyFactory), - new DestroyProcessor(assemblyFactory), - new EagerInitProcessor(assemblyFactory), - new InitProcessor(assemblyFactory), - new PropertyProcessor(assemblyFactory), - new ReferenceProcessor(assemblyFactory, javaFactory), - new ResourceProcessor(assemblyFactory), - new ServiceProcessor(assemblyFactory, javaFactory), - new SpringBeanPojoProcessor(assemblyFactory, javaFactory, conArgs), - new PolicyProcessor(assemblyFactory, policyFactory)}; - for (JavaClassVisitor extension : extensions) { - javaImplementationFactory.addClassVisitor(extension); - } - + FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); + javaImplementationFactory = factories.getFactory(JavaImplementationFactory.class); } // end constructor /** diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java index bef2d3665d..3a8eec99fa 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java @@ -43,6 +43,7 @@ import javax.jws.WebService; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Contract; import org.apache.tuscany.sca.assembly.Multiplicity; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.implementation.java.IntrospectionException; import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl; import org.apache.tuscany.sca.implementation.java.JavaElementImpl; @@ -80,14 +81,17 @@ import org.oasisopen.sca.annotation.Remotable; * @version $Rev$ $Date$ */ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor { - private JavaInterfaceFactory javaFactory; private List<SpringConstructorArgElement> conArgs; public SpringBeanPojoProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory, List<SpringConstructorArgElement> conArgs) { super(assemblyFactory); - this.javaFactory = javaFactory; + this.javaInterfaceFactory = javaFactory; this.conArgs = conArgs; } + + public SpringBeanPojoProcessor(ExtensionPointRegistry registry) { + super(registry); + } @Override public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException { @@ -582,13 +586,13 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor { throws IntrospectionException { org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference(); reference.setName(name); - JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); + JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); reference.setInterfaceContract(interfaceContract); try { - JavaInterface callInterface = javaFactory.createJavaInterface(paramType); + JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(paramType); reference.getInterfaceContract().setInterface(callInterface); if (callInterface.getCallbackClass() != null) { - JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass()); + JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass()); reference.getInterfaceContract().setCallbackInterface(callbackInterface); } reference.setMultiplicity(Multiplicity.ZERO_ONE); @@ -609,13 +613,13 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor { org.apache.tuscany.sca.assembly.Service service = assemblyFactory.createService(); service.setName(interfaze.getSimpleName()); - JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); + JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); service.setInterfaceContract(interfaceContract); - JavaInterface callInterface = javaFactory.createJavaInterface(interfaze); + JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze); service.getInterfaceContract().setInterface(callInterface); if (callInterface.getCallbackClass() != null) { - JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass()); + JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass()); service.getInterfaceContract().setCallbackInterface(callbackInterface); } @@ -631,7 +635,7 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor { Class<?> callbackClass = callback.value(); JavaInterface javaInterface; try { - javaInterface = javaFactory.createJavaInterface(callbackClass); + javaInterface = javaInterfaceFactory.createJavaInterface(callbackClass); contract.getInterfaceContract().setCallbackInterface(javaInterface); } catch (InvalidInterfaceException e) { throw new InvalidServiceTypeException("Invalid callback interface "+callbackClass, interfaze); diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java index 9195b6c9cc..bd3134c5f2 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java @@ -59,6 +59,7 @@ import org.apache.tuscany.sca.contribution.processor.ContributionResolveExceptio import org.apache.tuscany.sca.contribution.processor.ProcessorContext; 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.implementation.java.JavaConstructorImpl; import org.apache.tuscany.sca.implementation.java.JavaElementImpl; @@ -89,7 +90,7 @@ import org.apache.tuscany.sca.policy.PolicyFactory; * @version $Rev$ $Date$ */ public class SpringXMLComponentTypeLoader { - + private ExtensionPointRegistry registry; private XMLInputFactory xmlInputFactory; private ContributionFactory contributionFactory; private AssemblyFactory assemblyFactory; @@ -99,15 +100,14 @@ public class SpringXMLComponentTypeLoader { private Monitor monitor; private SpringBeanIntrospector beanIntrospector; - public SpringXMLComponentTypeLoader(FactoryExtensionPoint factories, - AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory, - PolicyFactory policyFactory, + public SpringXMLComponentTypeLoader(ExtensionPointRegistry registry, Monitor monitor) { super(); - this.assemblyFactory = assemblyFactory; - this.javaFactory = javaFactory; - this.policyFactory = policyFactory; + this.registry = registry; + FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); + this.assemblyFactory = factories.getFactory(AssemblyFactory.class); + this.javaFactory = factories.getFactory(JavaInterfaceFactory.class); + this.policyFactory = factories.getFactory(PolicyFactory.class); this.policyProcessor = new PolicySubjectProcessor(policyFactory); this.contributionFactory = factories.getFactory(ContributionFactory.class); this.xmlInputFactory = factories.getFactory(XMLInputFactory.class); @@ -653,7 +653,7 @@ public class SpringXMLComponentTypeLoader { Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context); // Introspect the bean beanIntrospector = - new SpringBeanIntrospector(assemblyFactory, javaFactory, policyFactory, beanElement.getCustructorArgs()); + new SpringBeanIntrospector(registry, beanElement.getCustructorArgs()); ComponentType beanComponentType = assemblyFactory.createComponentType(); javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType); // Set the service name as bean name @@ -680,7 +680,7 @@ public class SpringXMLComponentTypeLoader { Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context); // Introspect the bean beanIntrospector = - new SpringBeanIntrospector(assemblyFactory, javaFactory, policyFactory, beanElement.getCustructorArgs()); + new SpringBeanIntrospector(registry, beanElement.getCustructorArgs()); ComponentType beanComponentType = assemblyFactory.createComponentType(); javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType); Map<String, JavaElementImpl> propertyMap = javaImplementation.getPropertyMembers(); diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java index 5d896ca726..0cd85d1e33 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java @@ -36,14 +36,13 @@ import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; import org.apache.tuscany.sca.contribution.processor.ProcessorContext; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; 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.implementation.spring.SpringImplementation; import org.apache.tuscany.sca.implementation.spring.introspect.SpringXMLComponentTypeLoader; -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; /** * SpringArtifactProcessor is responsible for processing the XML of an <implementation.spring.../> @@ -58,20 +57,18 @@ public class SpringImplementationProcessor implements StAXArtifactProcessor<Spri private static final QName IMPLEMENTATION_SPRING_QNAME = new QName(Constants.SCA11_NS, IMPLEMENTATION_SPRING); private static final String MSG_LOCATION_MISSING = "Reading implementation.spring - location attribute missing"; + private ExtensionPointRegistry registry; private AssemblyFactory assemblyFactory; - private JavaInterfaceFactory javaFactory; - private PolicyFactory policyFactory; private PolicySubjectProcessor policyProcessor; private FactoryExtensionPoint factories; - public SpringImplementationProcessor(FactoryExtensionPoint modelFactories) { - this.factories = modelFactories; - this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - this.policyFactory = modelFactories.getFactory(PolicyFactory.class); - this.policyProcessor = new PolicySubjectProcessor(policyFactory); + public SpringImplementationProcessor(ExtensionPointRegistry registry) { + this.registry = registry; + this.factories = registry.getExtensionPoint(FactoryExtensionPoint.class); + this.assemblyFactory = factories.getFactory(AssemblyFactory.class); + this.policyProcessor = new PolicySubjectProcessor(registry); } /** @@ -196,7 +193,7 @@ public class SpringImplementationProcessor implements StAXArtifactProcessor<Spri Monitor monitor = context.getMonitor(); /* Load the Spring component type by reading the Spring application context */ SpringXMLComponentTypeLoader springLoader = - new SpringXMLComponentTypeLoader(factories, assemblyFactory, javaFactory, policyFactory, monitor); + new SpringXMLComponentTypeLoader(registry, monitor); try { // Load the Spring Implementation information from its application context file... springLoader.load(springImplementation, resolver, context); |