diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-13 07:34:35 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-13 07:34:35 +0000 |
commit | c953debbe7d1e8785c4c401c1314d9b176281e95 (patch) | |
tree | 750ab88cb6ca4aca96aef3aa0a754e899d6fdcf8 /branches/sca-java-1.x/modules/contribution/src | |
parent | 4c39d8c12de316d28abe711557c60ef000014e62 (diff) |
Fix for TUSCANT-2763 & TUSCANY-2764
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@734063 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/contribution/src')
3 files changed, 46 insertions, 29 deletions
diff --git a/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java index 045c201638..8a30129343 100644 --- a/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java +++ b/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java @@ -67,9 +67,11 @@ public class DefaultURLArtifactProcessorExtensionPoint XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); UtilityExtensionPoint utilities = this.extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - if (monitorFactory != null) - this.monitor = monitorFactory.createMonitor(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + if (monitorFactory != null) { + this.monitor = monitorFactory.createMonitor(); + } + StAXArtifactProcessorExtensionPoint staxProcessors = + extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, this.monitor); } @@ -203,8 +205,8 @@ public class DefaultURLArtifactProcessorExtensionPoint Constructor<URLArtifactProcessor> constructor = processorClass.getConstructor(ModelFactoryExtensionPoint.class, StAXArtifactProcessor.class, Monitor.class); processor = constructor.newInstance(modelFactories, staxProcessor, monitor); } catch (NoSuchMethodException e2) { - Constructor<URLArtifactProcessor> constructor = processorClass.getConstructor(ExtensionPointRegistry.class, StAXArtifactProcessor.class, Monitor.class); - processor = constructor.newInstance(extensionPoints, staxProcessor, monitor); + Constructor<URLArtifactProcessor> constructor = processorClass.getConstructor(ExtensionPointRegistry.class, Monitor.class); + processor = constructor.newInstance(extensionPoints, monitor); } } } catch (Exception e) { diff --git a/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java b/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java index 77570aa13d..5c3242e6b3 100644 --- a/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java +++ b/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.extensibility.ServiceDeclaration; import org.apache.tuscany.sca.extensibility.ServiceDiscovery; @@ -33,14 +34,16 @@ import org.apache.tuscany.sca.extensibility.ServiceDiscovery; * @version $Rev$ $Date$ */ public class DefaultModelResolverExtensionPoint implements ModelResolverExtensionPoint { - + private final ExtensionPointRegistry registry; private final Map<Class<?>, Class<? extends ModelResolver>> resolvers = new HashMap<Class<?>, Class<? extends ModelResolver>>(); private Map<String, ServiceDeclaration> loadedResolvers; /** * Constructs a new DefaultModelResolverExtensionPoint. + * @param registry The ExtensionPointRegistry */ - public DefaultModelResolverExtensionPoint() { + public DefaultModelResolverExtensionPoint(ExtensionPointRegistry registry) { + this.registry = registry; } public void addResolver(Class<?> modelType, Class<? extends ModelResolver> resolver) { diff --git a/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java b/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java index de54d54f94..04352fd242 100644 --- a/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java +++ b/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java @@ -23,9 +23,9 @@ import java.lang.reflect.Constructor; import java.util.HashMap; import java.util.Map; -import org.apache.tuscany.sca.assembly.Base; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; /** * An implementation of an extensible model resolver which delegates to the @@ -34,6 +34,7 @@ import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; * @version $Rev$ $Date$ */ public class ExtensibleModelResolver implements ModelResolver { + private ExtensionPointRegistry extensionPoints; private final ModelResolverExtensionPoint resolverExtensions; private final ModelFactoryExtensionPoint modelFactories; private final Contribution contribution; @@ -47,16 +48,18 @@ public class ExtensibleModelResolver implements ModelResolver { * Constructs an extensible model resolver * * @param contribution + * @param extensionPoints TODO * @param resolverExtensions * @param modelFactories * @param defaultResolver */ @Deprecated public ExtensibleModelResolver(Contribution contribution, + ExtensionPointRegistry extensionPoints, ModelResolverExtensionPoint resolverExtensions, - ModelFactoryExtensionPoint modelFactories, - ModelResolver defaultResolver) { + ModelFactoryExtensionPoint modelFactories, ModelResolver defaultResolver) { this.contribution = contribution; + this.extensionPoints = extensionPoints; this.resolverExtensions = resolverExtensions; this.modelFactories = modelFactories; //FIXME Remove this default resolver, this is currently used to resolve policy declarations @@ -64,20 +67,16 @@ public class ExtensibleModelResolver implements ModelResolver { // defaultResolver hack. this.defaultResolver = defaultResolver; } - + /** - * Constructs an extensible model resolver - * - * @param resolverExtensions * @param contribution - * @param modelFactories + * @param extensionPoints */ - public ExtensibleModelResolver(Contribution contribution, - ModelResolverExtensionPoint resolverExtensions, - ModelFactoryExtensionPoint modelFactories) { + public ExtensibleModelResolver(Contribution contribution, ExtensionPointRegistry extensionPoints) { this.contribution = contribution; - this.resolverExtensions = resolverExtensions; - this.modelFactories = modelFactories; + this.extensionPoints = extensionPoints; + this.resolverExtensions = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); + this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); } /** @@ -116,15 +115,28 @@ public class ExtensibleModelResolver implements ModelResolver { return resolverInstance; } try { - Constructor<? extends ModelResolver> constructor = - resolverClass - .getConstructor(new Class[] {Contribution.class, ModelFactoryExtensionPoint.class}); - if (constructor != null) { - - resolverInstance = constructor.newInstance(contribution, modelFactories); - resolversByImplementationClass.put(resolverClass, resolverInstance); - resolversByModelType.put(c, resolverInstance); - return resolverInstance; + try { + Constructor<? extends ModelResolver> constructor = + resolverClass.getConstructor(new Class[] {Contribution.class, + ModelFactoryExtensionPoint.class}); + if (constructor != null) { + + resolverInstance = constructor.newInstance(contribution, modelFactories); + resolversByImplementationClass.put(resolverClass, resolverInstance); + resolversByModelType.put(c, resolverInstance); + return resolverInstance; + } + } catch (NoSuchMethodException e) { + Constructor<? extends ModelResolver> constructor = + resolverClass.getConstructor(new Class[] {Contribution.class, + ExtensionPointRegistry.class}); + if (constructor != null) { + + resolverInstance = constructor.newInstance(contribution, extensionPoints); + resolversByImplementationClass.put(resolverClass, resolverInstance); + resolversByModelType.put(c, resolverInstance); + return resolverInstance; + } } } catch (Exception e) { throw new IllegalStateException(e); |