diff options
Diffstat (limited to 'branches/sca-equinox/modules')
12 files changed, 64 insertions, 83 deletions
diff --git a/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java b/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java index f7ed5058c5..23ba985ebb 100644 --- a/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java +++ b/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java @@ -18,15 +18,9 @@ */ package org.apache.tuscany.sca.binding.ws.wsdlgen; -import java.util.List; -import java.util.Map; - -import javax.wsdl.Definition; -import javax.wsdl.Operation; -import javax.wsdl.PortType; - import junit.framework.TestCase; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor; import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint; @@ -50,7 +44,7 @@ import org.osoa.sca.annotations.Remotable; public class BindingWSDLGeneratorTestCase extends TestCase { public void testCreateWSDLInterfaceContract() throws InvalidInterfaceException { - DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(); + DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class); XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class); DefaultJavaInterfaceFactory factory = new DefaultJavaInterfaceFactory(); diff --git a/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java b/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java index c51ab8af99..1b08255e46 100644 --- a/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java +++ b/branches/sca-equinox/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java @@ -24,6 +24,7 @@ import java.io.StringWriter; import javax.wsdl.Definition; import javax.wsdl.xml.WSDLWriter; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor; import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint; @@ -50,7 +51,7 @@ public class Interface2WSDLGeneratorTestCase { JAXWSFaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings, null); new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface); new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface); - DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(); + DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); WSDLDefinition wsdlDefinition = new DefaultWSDLFactory(modelFactories).createWSDLDefinition(); DefaultXSDFactory factory = new DefaultXSDFactory(); Interface2WSDLGenerator generator = new Interface2WSDLGenerator(false, new XSDModelResolver(null, null), dataBindings, factory, null); diff --git a/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java index 5c6080d699..e4082b3b85 100644 --- a/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java +++ b/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java @@ -24,6 +24,7 @@ import static junit.framework.Assert.assertTrue; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.ContributionFactory; import org.apache.tuscany.sca.contribution.DefaultContributionFactory; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.junit.Before; @@ -45,7 +46,7 @@ public class ExtensibleModelResolverTestCase { ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(); resolvers.addResolver(Model.class, TestModelResolver.class); - FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(); + FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); resolver = new ExtensibleModelResolver(null, resolvers, factories, null); diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java index 6b9eaeab8d..9258a837d8 100644 --- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java +++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java @@ -44,10 +44,13 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -66,6 +69,15 @@ public class DefaultValidatingXMLInputFactory extends ValidatingXMLInputFactory private boolean hasSchemas; private Schema aggregatedSchema; + public DefaultValidatingXMLInputFactory(ExtensionPointRegistry registry) { + FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class); + XMLInputFactory factory = factoryExtensionPoint.getFactory(XMLInputFactory.class); + this.inputFactory = factory; + this.schemas = registry.getExtensionPoint(ValidationSchemaExtensionPoint.class); + this.monitor = + registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class).createMonitor(); + } + /** * Constructs a new XMLInputFactory. * diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java index da249a09e4..c0eef5a7a8 100644 --- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java +++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java @@ -27,16 +27,4 @@ import javax.xml.stream.XMLInputFactory; * @version $Rev$ $Date$ */ public abstract class ValidatingXMLInputFactory extends XMLInputFactory { - - /** - * Create a new default validating XML input factory. - * @return - */ - public static ValidatingXMLInputFactory newInstance() { - return new DefaultValidatingXMLInputFactory( - XMLInputFactory.newInstance(), - new DefaultValidationSchemaExtensionPoint(), - null); - } - } diff --git a/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java index 5c6080d699..e4082b3b85 100644 --- a/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java +++ b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java @@ -24,6 +24,7 @@ import static junit.framework.Assert.assertTrue; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.ContributionFactory; import org.apache.tuscany.sca.contribution.DefaultContributionFactory; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.junit.Before; @@ -45,7 +46,7 @@ public class ExtensibleModelResolverTestCase { ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(); resolvers.addResolver(Model.class, TestModelResolver.class); - FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(); + FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); resolver = new ExtensibleModelResolver(null, resolvers, factories, null); diff --git a/branches/sca-equinox/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java b/branches/sca-equinox/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java index 3b109f3137..26c0f3ecb6 100644 --- a/branches/sca-equinox/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java +++ b/branches/sca-equinox/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java @@ -28,6 +28,7 @@ import junit.framework.TestCase; import org.apache.tuscany.sca.contribution.resolver.ClassReference; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; import com.example.ipo.sdo.SdoFactory; @@ -69,7 +70,7 @@ public class ImportSDOProcessorTestCase extends TestCase { @Override protected void setUp() throws Exception { - loader = new ImportSDOProcessor(new DefaultFactoryExtensionPoint(), null); + loader = new ImportSDOProcessor(new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()), null); xmlFactory = XMLInputFactory.newInstance(); } diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java index 1d0da12f91..c1221aad7a 100644 --- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java +++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java @@ -33,13 +33,14 @@ import org.apache.tuscany.sca.extensibility.ServiceDiscovery; * @version $Rev$ $Date$ */ public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint { - + private ExtensionPointRegistry extensionPointRegistry; private HashMap<Class<?>, Object> factories = new HashMap<Class<?>, Object>(); /** * Constructs a new DefaultModelFactoryExtensionPoint. */ - public DefaultFactoryExtensionPoint() { + public DefaultFactoryExtensionPoint(ExtensionPointRegistry extensionPointRegistry) { + this.extensionPointRegistry = extensionPointRegistry; } /** @@ -88,43 +89,35 @@ public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint { public <T> T getFactory(Class<T> factoryInterface) { Object factory = factories.get(factoryInterface); if (factory == null) { - - if (factoryInterface.isInterface()) { - - // Dynamically load a factory class declared under META-INF/services - try { - ServiceDeclaration factoryDeclaration = ServiceDiscovery.getInstance().getFirstServiceDeclaration(factoryInterface.getName()); - if (factoryDeclaration != null) { - Class<?> factoryClass = factoryDeclaration.loadClass(); - + + // Dynamically load a factory class declared under META-INF/services + try { + ServiceDeclaration factoryDeclaration = + ServiceDiscovery.getInstance().getFirstServiceDeclaration(factoryInterface.getName()); + if (factoryDeclaration != null) { + Class<?> factoryClass = factoryDeclaration.loadClass(); + + try { + // Default empty constructor + Constructor<?> constructor = factoryClass.getConstructor(); + factory = constructor.newInstance(); + } catch (NoSuchMethodException e) { try { - // Default empty constructor - Constructor<?> constructor = factoryClass.getConstructor(); - factory = constructor.newInstance(); - } catch (NoSuchMethodException e) { - // Constructor taking the model factory extension point Constructor<?> constructor = factoryClass.getConstructor(FactoryExtensionPoint.class); factory = constructor.newInstance(this); + } catch (NoSuchMethodException e1) { + // Constructor taking the extension point registry + Constructor<?> constructor = factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(extensionPointRegistry); } - - // Cache the loaded factory - addFactory(factory); } - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } else { - // Call the newInstance static method on the factory abstract class - try { - factory = ServiceDiscovery.getInstance().newFactoryClassInstance(factoryInterface.getName()); - } catch (Exception e) { - throw new IllegalArgumentException(e); + // Cache the loaded factory + addFactory(factory); } - - // Cache the factory - addFactory(factory); + } catch (Exception e) { + throw new IllegalArgumentException(e); } } return factoryInterface.cast(factory); diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java index 0f408600aa..7d9dc0e9ef 100644 --- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java +++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java @@ -24,8 +24,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.URL; import java.net.URLConnection; import java.security.AccessController; @@ -45,7 +43,7 @@ import java.util.logging.Logger; /** * A ServiceDiscoverer that find META-INF/services/... using the Context ClassLoader. * - * @version $Rev: $ $Date: $ + * @version $Rev$ $Date$ */ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer { private static final Logger logger = Logger.getLogger(ContextClassLoaderServiceDiscoverer.class.getName()); @@ -243,11 +241,4 @@ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer { } - public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException { - Class<?> factoryClass = Class.forName(name, false, classLoaderReference.get()); - Method newInstanceMethod = factoryClass.getMethod("newInstance"); - Object factory = newInstanceMethod.invoke(null); - return factory; - } - } diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java index 679e3d1f57..f89a25d199 100644 --- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java +++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java @@ -47,16 +47,4 @@ public interface ServiceDiscoverer { */ public ServiceDeclaration getFirstServiceDeclaration(String name) throws IOException; - /** - * Create a new instance of a factory service class. - * - * @param name - * @return service implementation class - * @throws SecurityException - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - */ - public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException; - } diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java index 552691ab6b..e78cb136d3 100644 --- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java +++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java @@ -20,7 +20,6 @@ package org.apache.tuscany.sca.extensibility; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Set; @@ -84,9 +83,17 @@ public class ServiceDiscovery implements ServiceDiscoverer { return service; } - public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException { - Object factory = getServiceDiscoverer().newFactoryClassInstance(name); - return factory; + public Object newFactoryClassInstance(String name) { + try { + ServiceDeclaration declaration = getFirstServiceDeclaration(name); + if (declaration == null) { + return null; + } + Class<?> factoryClass = declaration.loadClass(); + return factoryClass.newInstance(); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } } } diff --git a/branches/sca-equinox/modules/thirdparty-library/pom.xml b/branches/sca-equinox/modules/thirdparty-library/pom.xml index 166850ddcb..09c3eb2822 100644 --- a/branches/sca-equinox/modules/thirdparty-library/pom.xml +++ b/branches/sca-equinox/modules/thirdparty-library/pom.xml @@ -87,8 +87,12 @@ <id>build-thirdparty-distro</id> <phase>generate-resources</phase> <goals> - <goal>build-thirdparty-distro</goal> + <goal>generate-modules</goal> </goals> + <configuration> + <generateTargetPlatform>true</generateTargetPlatform> + <generatePlugin>true</generatePlugin> + </configuration> </execution> <!-- |