diff options
Diffstat (limited to '')
30 files changed, 257 insertions, 98 deletions
diff --git a/branches/sca-java-1.x/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java b/branches/sca-java-1.x/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java index 6d829033a3..d4996c7418 100644 --- a/branches/sca-java-1.x/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java +++ b/branches/sca-java-1.x/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java @@ -37,7 +37,6 @@ import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
import org.apache.tuscany.sca.assembly.xml.Constants;
-import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
@@ -63,6 +62,7 @@ import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl;
public class CustomCompositeBuilder {
+ private ExtensionPointRegistry extensionPoints;
private URLArtifactProcessor<Contribution> contributionProcessor;
private ModelResolverExtensionPoint modelResolvers;
private ModelFactoryExtensionPoint modelFactories;
@@ -85,7 +85,7 @@ public class CustomCompositeBuilder { private void init() {
// Create extension point registry
- ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ extensionPoints = new DefaultExtensionPointRegistry();
// Create a monitor
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
@@ -137,7 +137,7 @@ public class CustomCompositeBuilder { // Create workspace model
workspace = workspaceFactory.createWorkspace();
- workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories));
+ workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints));
// Read the test contribution
URI artifactURI = URI.create(sourceURI);
diff --git a/branches/sca-java-1.x/itest/validation/src/test/java/domain/CustomCompositeBuilder.java b/branches/sca-java-1.x/itest/validation/src/test/java/domain/CustomCompositeBuilder.java index 65814470a4..7f3199d472 100644 --- a/branches/sca-java-1.x/itest/validation/src/test/java/domain/CustomCompositeBuilder.java +++ b/branches/sca-java-1.x/itest/validation/src/test/java/domain/CustomCompositeBuilder.java @@ -47,7 +47,6 @@ import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint; import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.ModuleActivator; @@ -66,8 +65,8 @@ import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl; public class CustomCompositeBuilder { + private ExtensionPointRegistry extensionPoints; private URLArtifactProcessor<Contribution> contributionProcessor; - private ModelResolverExtensionPoint modelResolvers; private ModelFactoryExtensionPoint modelFactories; private WorkspaceFactory workspaceFactory; private AssemblyFactory assemblyFactory; @@ -98,7 +97,7 @@ public class CustomCompositeBuilder { private void init() { // Create extension point registry - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + extensionPoints = new DefaultExtensionPointRegistry(); // Create a monitor UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); @@ -136,9 +135,6 @@ public class CustomCompositeBuilder { URLArtifactProcessorExtensionPoint docProcessorExtensions = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class); - // Get the model resolvers - modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); - // Create a contribution dependency builder contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor); @@ -157,7 +153,7 @@ public class CustomCompositeBuilder { // Create workspace model workspace = workspaceFactory.createWorkspace(); - workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); // Read the sample store contribution URI artifactURI = URI.create(sourceURI); @@ -218,7 +214,7 @@ public class CustomCompositeBuilder { // Create workspace model workspace = workspaceFactory.createWorkspace(); - workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); // Read the sample store contribution URI artifactURI = URI.create(sourceURI); diff --git a/branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java b/branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java index 7b8b12ca9d..6471042fed 100644 --- a/branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java +++ b/branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java @@ -55,13 +55,14 @@ import org.apache.tuscany.sca.contribution.service.ContributionService; import org.apache.tuscany.sca.contribution.service.ExtensibleContributionListener; import org.apache.tuscany.sca.contribution.service.util.IOHelper; import org.apache.tuscany.sca.contribution.xml.ContributionMetadataDocumentProcessor; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.PolicySet; 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.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; /** * Service interface that manages artifacts contributed to a Tuscany runtime. @@ -69,6 +70,7 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; * @version $Rev$ $Date$ */ public class ContributionServiceImpl implements ContributionService { + private ExtensionPointRegistry extensionPoints; /** * Repository where contributions are stored. Usually set by injection. @@ -145,8 +147,10 @@ public class ContributionServiceImpl implements ContributionService { ContributionFactory contributionFactory, XMLInputFactory xmlFactory, List<SCADefinitions> policyDefinitions, + ExtensionPointRegistry extensionPoints, Monitor monitor) { super(); + this.extensionPoints = extensionPoints; this.contributionRepository = repository; this.packageProcessor = packageProcessor; this.artifactProcessor = documentProcessor; @@ -341,7 +345,7 @@ public class ContributionServiceImpl implements ContributionService { if (modelResolver == null) { //FIXME Remove this domain resolver, visibility of policy declarations should be handled by // the contribution import/export mechanism instead of this domainResolver hack. - modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories, policyDefinitionsResolver); + modelResolver = new ExtensibleModelResolver(contribution, extensionPoints, modelResolvers, modelFactories, policyDefinitionsResolver); } //set contribution initial information diff --git a/branches/sca-java-1.x/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/branches/sca-java-1.x/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java index 01083cc6a6..f66b429d65 100644 --- a/branches/sca-java-1.x/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java +++ b/branches/sca-java-1.x/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java @@ -40,12 +40,12 @@ public class ExtensibleModelResolverTestCase extends TestCase { @Override protected void setUp() throws Exception { - ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(); + ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(null); resolvers.addResolver(Model.class, TestModelResolver.class); ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint(); - resolver = new ExtensibleModelResolver(null, resolvers, factories, null); + resolver = new ExtensibleModelResolver(null, null, resolvers, factories, null); factory = new DefaultContributionFactory(); } diff --git a/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/ContributionClassLoaderProvider.java b/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/ContributionClassLoaderProvider.java new file mode 100644 index 0000000000..60e3944e26 --- /dev/null +++ b/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/ContributionClassLoaderProvider.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.contribution.java; + +import org.apache.tuscany.sca.contribution.Contribution; + +/** + * A pluggable utility to provide a classloader for a given contribution + */ +public interface ContributionClassLoaderProvider { + /** + * Get the classloader for the given contribution + * @param contribution + * @param parent + * @return + */ + ClassLoader getClassLoader(Contribution contribution, ClassLoader parent); +} diff --git a/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultContributionClassLoaderProvider.java b/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultContributionClassLoaderProvider.java new file mode 100644 index 0000000000..ee62040731 --- /dev/null +++ b/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultContributionClassLoaderProvider.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.contribution.java; + +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.java.impl.ContributionClassLoader; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; + +/** + * The default implementation of the ContributionClassLoaderProvider + */ +public class DefaultContributionClassLoaderProvider implements ContributionClassLoaderProvider { + + public DefaultContributionClassLoaderProvider(ExtensionPointRegistry registry) { + super(); + } + + public ClassLoader getClassLoader(Contribution contribution, ClassLoader parent) { + return new ContributionClassLoader(contribution, parent); + } + +} diff --git a/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassReferenceModelResolver.java b/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassReferenceModelResolver.java index 962512a745..1011f5d4a7 100644 --- a/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassReferenceModelResolver.java +++ b/branches/sca-java-1.x/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassReferenceModelResolver.java @@ -27,9 +27,12 @@ import java.util.HashMap; import java.util.Map;
import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.java.ContributionClassLoaderProvider;
+import org.apache.tuscany.sca.contribution.java.DefaultContributionClassLoaderProvider;
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.UtilityExtensionPoint;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
@@ -38,14 +41,16 @@ import org.apache.tuscany.sca.extensibility.ServiceDiscovery; * @version $Rev: 557916 $ $Date: 2007-07-20 01:04:40 -0700 (Fri, 20 Jul 2007) $
*/
public class ClassReferenceModelResolver implements ModelResolver {
- private Contribution contribution;
+ private final ExtensionPointRegistry registry;
+ private final Contribution contribution;
private WeakReference<ClassLoader> classLoader;
private Map<String, ClassReference> map = new HashMap<String, ClassReference>();
private ModelResolver osgiResolver;
- public ClassReferenceModelResolver(final Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
+ public ClassReferenceModelResolver(final Contribution contribution, ExtensionPointRegistry registry) {
this.contribution = contribution;
+ this.registry = registry;
if (this.contribution != null) {
// Allow privileged access to get ClassLoader. Requires RuntimePermission in security policy.
// ClassLoader cl = contribution.getClassLoader();
@@ -63,7 +68,18 @@ public class ClassReferenceModelResolver implements ModelResolver { // }
//});
ClassLoader contextClassLoader = ServiceDiscovery.getInstance().getServiceDiscoverer().getClass().getClassLoader();
- cl = new ContributionClassLoader(contribution, contextClassLoader);
+ ContributionClassLoaderProvider provider = null;
+ try {
+ provider =
+ registry.getExtensionPoint(UtilityExtensionPoint.class)
+ .getUtility(ContributionClassLoaderProvider.class);
+ } catch (Throwable e) {
+ // Ignore errors
+ }
+ if (provider == null) {
+ provider = new DefaultContributionClassLoaderProvider(registry);
+ }
+ cl = provider.getClassLoader(contribution, contextClassLoader);
contribution.setClassLoader(cl);
}
this.classLoader = new WeakReference<ClassLoader>(cl);
@@ -84,8 +100,8 @@ public class ClassReferenceModelResolver implements ModelResolver { Class.forName("org.apache.tuscany.sca.contribution.osgi.impl.OSGiClassReferenceModelResolver");
if (osgiResolverClass != null) {
Constructor constructor =
- osgiResolverClass.getConstructor(Contribution.class, ModelFactoryExtensionPoint.class);
- this.osgiResolver = (ModelResolver)constructor.newInstance(contribution, modelFactories);
+ osgiResolverClass.getConstructor(Contribution.class, ExtensionPointRegistry.class);
+ this.osgiResolver = (ModelResolver)constructor.newInstance(contribution, registry);
}
} catch (Throwable e) {
// Ignore error, non-OSGi classloading is used in this case
diff --git a/branches/sca-java-1.x/modules/contribution-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.ContributionClassLoaderProvider b/branches/sca-java-1.x/modules/contribution-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.ContributionClassLoaderProvider new file mode 100644 index 0000000000..a50d8e77a4 --- /dev/null +++ b/branches/sca-java-1.x/modules/contribution-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.ContributionClassLoaderProvider @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# org.apache.tuscany.sca.contribution.java.DefaultContributionClassLoaderProvider
\ No newline at end of file diff --git a/branches/sca-java-1.x/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ClassReferenceArtifactResolverTestCase.java b/branches/sca-java-1.x/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ClassReferenceArtifactResolverTestCase.java index 1405ad4bd5..52c8567f3f 100644 --- a/branches/sca-java-1.x/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ClassReferenceArtifactResolverTestCase.java +++ b/branches/sca-java-1.x/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ClassReferenceArtifactResolverTestCase.java @@ -43,7 +43,7 @@ public class ClassReferenceArtifactResolverTestCase extends TestCase { ModelResolverExtensionPoint resolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
resolvers.addResolver(ClassReference.class, ClassReferenceModelResolver.class);
ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
- resolver = new ExtensibleModelResolver(null, resolvers, modelFactories);
+ resolver = new ExtensibleModelResolver(null, extensionPoints);
}
/**
diff --git a/branches/sca-java-1.x/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java b/branches/sca-java-1.x/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java index 528a287328..39cdd6fcd3 100644 --- a/branches/sca-java-1.x/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java +++ b/branches/sca-java-1.x/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java @@ -24,9 +24,9 @@ import java.util.Map; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.Import; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; 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.osgi.runtime.OSGiRuntime; import org.osgi.framework.Bundle; @@ -42,7 +42,7 @@ public class OSGiClassReferenceModelResolver implements ModelResolver { private boolean initialized; private boolean useOSGi; - public OSGiClassReferenceModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) { + public OSGiClassReferenceModelResolver(Contribution contribution, ExtensionPointRegistry registry) { this.contribution = contribution; } 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); diff --git a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java index 09bb05cf87..b61553e640 100644 --- a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java +++ b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java @@ -115,6 +115,7 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se @Reference public LocalItemCollection cloudCollection; + private ExtensionPointRegistry extensionPoints; private ModelFactoryExtensionPoint modelFactories; private ModelResolverExtensionPoint modelResolvers; private AssemblyFactory assemblyFactory; @@ -135,7 +136,7 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se @Init public void initialize() throws ParserConfigurationException { - ExtensionPointRegistry extensionPoints = domainManagerConfiguration.getExtensionPoints(); + extensionPoints = domainManagerConfiguration.getExtensionPoints(); // Create a monitor UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); @@ -160,7 +161,7 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se // Create contribution processor modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); - contributionProcessor = new ContributionContentProcessor(modelFactories, modelResolvers, urlProcessor, staxProcessor, monitor); + contributionProcessor = new ContributionContentProcessor(extensionPoints, monitor); // Create contribution and composite builders DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); @@ -221,7 +222,7 @@ public class CompositeConfigurationServiceImpl extends HttpServlet implements Se // Populate the domain composite Workspace workspace = workspaceFactory.createWorkspace(); - workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); Map<String, Contribution> contributionMap = new HashMap<String, Contribution>(); for (Entry<String, Item> domainEntry: domainEntries) { diff --git a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java index 9e024d2d6b..c476d82e72 100644 --- a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java +++ b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java @@ -139,7 +139,7 @@ public class CompositeGeneratorServiceImpl extends HttpServlet implements Servle // Create contribution processor modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); - contributionProcessor = new ContributionContentProcessor(modelFactories, modelResolvers, urlProcessor, staxProcessor, monitor); + contributionProcessor = new ContributionContentProcessor(extensionPoints, monitor); } @Override diff --git a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java index e66a8b6684..1eb70cce77 100644 --- a/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java +++ b/branches/sca-java-1.x/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java @@ -142,7 +142,7 @@ public class DeployableCompositeCollectionImpl implements ItemCollection, LocalI // Create contribution processor modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); - contributionProcessor = new ContributionContentProcessor(modelFactories, modelResolvers, urlProcessor, staxProcessor, monitor); + contributionProcessor = new ContributionContentProcessor(extensionPoints, monitor); // Create contribution and composite builders contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor); diff --git a/branches/sca-java-1.x/modules/endpoint/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java b/branches/sca-java-1.x/modules/endpoint/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java index 5a2d9babf4..371f6e624d 100644 --- a/branches/sca-java-1.x/modules/endpoint/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java +++ b/branches/sca-java-1.x/modules/endpoint/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java @@ -44,7 +44,6 @@ import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.ModuleActivator; @@ -70,7 +69,6 @@ import org.junit.Test; public class EndpointTestCase { private static URLArtifactProcessor<Contribution> contributionProcessor; - private static ModelResolverExtensionPoint modelResolvers; private static ModelFactoryExtensionPoint modelFactories; private static AssemblyFactory assemblyFactory; private static XMLOutputFactory outputFactory; @@ -117,8 +115,7 @@ public class EndpointTestCase { contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class); // Get the model resolvers - modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); - modelResolver = new ExtensibleModelResolver(null, modelResolvers, modelFactories); + modelResolver = new ExtensibleModelResolver(null, extensionPoints); // Create a composite builder SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); diff --git a/branches/sca-java-1.x/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java b/branches/sca-java-1.x/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderServiceDiscoverer.java index 2e11234095..c9bed94692 100644 --- a/branches/sca-java-1.x/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java +++ b/branches/sca-java-1.x/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderServiceDiscoverer.java @@ -44,10 +44,10 @@ 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()); +public class ClassLoaderServiceDiscoverer implements ServiceDiscoverer { + private static final Logger logger = Logger.getLogger(ClassLoaderServiceDiscoverer.class.getName()); public class ServiceDeclarationImpl implements ServiceDeclaration { private URL url; @@ -107,11 +107,25 @@ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer { private WeakReference<ClassLoader> classLoaderReference; - public ContextClassLoaderServiceDiscoverer() { + /** + * Construct a service discoverer based on TCCL + */ + public ClassLoaderServiceDiscoverer() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); this.classLoaderReference = new WeakReference<ClassLoader>(classLoader); } + /** + * Construct a service discoverer using the given classloader + * @param classLoader + */ + public ClassLoaderServiceDiscoverer(ClassLoader classLoader) { + if (classLoader == null) { + classLoader = Thread.currentThread().getContextClassLoader(); + } + this.classLoaderReference = new WeakReference<ClassLoader>(classLoader); + } + private List<URL> getResources(final String name, final boolean firstOnly) throws IOException { try { return AccessController.doPrivileged(new PrivilegedExceptionAction<List<URL>>() { diff --git a/branches/sca-java-1.x/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/branches/sca-java-1.x/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java index ce41a44068..a95ab253ae 100644 --- a/branches/sca-java-1.x/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java +++ b/branches/sca-java-1.x/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java @@ -57,7 +57,7 @@ public class ServiceDiscovery { public ServiceDiscoverer getServiceDiscoverer() { if (discoverer == null) { - discoverer = new ContextClassLoaderServiceDiscoverer(); + discoverer = new ClassLoaderServiceDiscoverer(); } return discoverer; } diff --git a/branches/sca-java-1.x/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java b/branches/sca-java-1.x/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ClassLoaderServiceDiscovererTestCase.java index fd508402fc..92164eccc7 100644 --- a/branches/sca-java-1.x/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java +++ b/branches/sca-java-1.x/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ClassLoaderServiceDiscovererTestCase.java @@ -30,15 +30,15 @@ import org.junit.Test; /** * Test Case for ClasspathServiceDiscover */ -public class ContextClassLoaderServiceDiscovererTestCase { - private static ContextClassLoaderServiceDiscoverer discover; +public class ClassLoaderServiceDiscovererTestCase { + private static ClassLoaderServiceDiscoverer discover; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { - discover = new ContextClassLoaderServiceDiscoverer(); + discover = new ClassLoaderServiceDiscoverer(); } @Test diff --git a/branches/sca-java-1.x/modules/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java b/branches/sca-java-1.x/modules/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java index 738e5e6248..1111558c60 100644 --- a/branches/sca-java-1.x/modules/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java +++ b/branches/sca-java-1.x/modules/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java @@ -250,7 +250,7 @@ public class ReallySmallRuntimeBuilder { ContributionService contributionService = new ContributionServiceImpl(repository, packageProcessor, documentProcessor, staxProcessor, contributionListener, policyDefinitionResolver, modelResolvers, modelFactories, - assemblyFactory, contributionFactory, inputFactory, policyDefinitions, monitor); + assemblyFactory, contributionFactory, inputFactory, policyDefinitions, registry, monitor); return contributionService; } diff --git a/branches/sca-java-1.x/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java b/branches/sca-java-1.x/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java index 738e5e6248..1111558c60 100644 --- a/branches/sca-java-1.x/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java +++ b/branches/sca-java-1.x/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java @@ -250,7 +250,7 @@ public class ReallySmallRuntimeBuilder { ContributionService contributionService = new ContributionServiceImpl(repository, packageProcessor, documentProcessor, staxProcessor, contributionListener, policyDefinitionResolver, modelResolvers, modelFactories, - assemblyFactory, contributionFactory, inputFactory, policyDefinitions, monitor); + assemblyFactory, contributionFactory, inputFactory, policyDefinitions, registry, monitor); return contributionService; } diff --git a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java index f0228edb1f..b68d0cc175 100644 --- a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java +++ b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java @@ -58,7 +58,7 @@ public abstract class AbstractWSDLTestCase extends TestCase { ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class); Contribution contribution = contributionFactory.createContribution(); ModelResolverExtensionPoint modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); - resolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories); + resolver = new ExtensibleModelResolver(contribution, extensionPoints); contribution.setModelResolver(resolver); URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); diff --git a/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java b/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java index 6c93fa7800..fe05a93992 100644 --- a/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java +++ b/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java @@ -20,8 +20,6 @@ package org.apache.tuscany.sca.node.impl; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.List; import javax.xml.parsers.DocumentBuilderFactory; @@ -233,7 +231,7 @@ public class RuntimeBuilder { ContributionService contributionService = new ContributionServiceImpl(repository, packageProcessor, documentProcessor, staxProcessor, contributionListener, policyDefinitionResolver, modelResolvers, modelFactories, - assemblyFactory, contributionFactory, inputFactory, policyDefinitions, monitor); + assemblyFactory, contributionFactory, inputFactory, policyDefinitions, registry, monitor); return contributionService; } diff --git a/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java b/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java index d0f769c9d1..e3f0844e35 100644 --- a/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java +++ b/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java @@ -23,6 +23,9 @@ import java.net.URI; import java.net.URL; import java.util.List; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; + import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.Contribution; @@ -33,8 +36,10 @@ import org.apache.tuscany.sca.contribution.DefaultImport; import org.apache.tuscany.sca.contribution.Export; import org.apache.tuscany.sca.contribution.Import; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.resolver.ClassReference; @@ -58,6 +63,7 @@ import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner; * @version $Rev$ $Date$ */ public class ContributionContentProcessor implements URLArtifactProcessor<Contribution>{ + private ExtensionPointRegistry extensionPoints; private ContributionFactory contributionFactory; private ModelResolverExtensionPoint modelResolvers; private ModelFactoryExtensionPoint modelFactories; @@ -66,17 +72,24 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri private UtilityExtensionPoint utilities; private Monitor monitor = null; - public ContributionContentProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { + public ContributionContentProcessor(ExtensionPointRegistry extensionPoints, Monitor monitor) { + this.extensionPoints = extensionPoints; this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); this.modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); hackResolvers(modelResolvers); this.monitor = monitor; URLArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); this.artifactProcessor = new ExtensibleURLArtifactProcessor(artifactProcessors, this.monitor); - this.extensionProcessor = extensionProcessor; + + // Get and initialize artifact processors + StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); + XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); + this.extensionProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, monitor); this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); } + /* public ContributionContentProcessor(ModelFactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { this.modelFactories = modelFactories; @@ -87,6 +100,7 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); this.monitor = monitor; } + */ public String getArtifactType() { return ".contribution/content"; @@ -102,7 +116,7 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri Contribution contribution = contributionFactory.createContribution(); contribution.setURI(contributionURI.toString()); contribution.setLocation(contributionURL.toString()); - ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories); + ModelResolver modelResolver = new ExtensibleModelResolver(contribution, extensionPoints); contribution.setModelResolver(modelResolver); contribution.setUnresolved(true); diff --git a/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java b/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java index 6ef0fa753d..40e377604c 100644 --- a/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java +++ b/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java @@ -26,6 +26,9 @@ import java.net.URL; import java.net.URLConnection; import java.util.List; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; + import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.ContributionFactory; @@ -35,8 +38,10 @@ import org.apache.tuscany.sca.contribution.DefaultImport; import org.apache.tuscany.sca.contribution.Export; import org.apache.tuscany.sca.contribution.Import; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.resolver.ClassReference; @@ -59,6 +64,7 @@ import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner; * @version $Rev$ $Date$ */ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribution>{ + private ExtensionPointRegistry extensionPoints; private ContributionFactory contributionFactory; private ModelResolverExtensionPoint modelResolvers; private ModelFactoryExtensionPoint modelFactories; @@ -66,17 +72,23 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut private URLArtifactProcessor<Object> artifactProcessor; private StAXArtifactProcessor<Object> extensionProcessor; - public ContributionInfoProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { + public ContributionInfoProcessor(ExtensionPointRegistry extensionPoints, Monitor monitor) { + this.extensionPoints = extensionPoints; this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); this.modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); hackResolvers(modelResolvers); URLArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); this.artifactProcessors = artifactProcessors; this.artifactProcessor = new ExtensibleURLArtifactProcessor(artifactProcessors, monitor); - this.extensionProcessor = extensionProcessor; + // Get and initialize artifact processors + StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); + XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); + this.extensionProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, monitor); this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); } + /* public ContributionInfoProcessor(ModelFactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor) { this.modelFactories = modelFactories; this.modelResolvers = modelResolvers; @@ -84,6 +96,7 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut this.artifactProcessor = artifactProcessor; this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); } + */ public String getArtifactType() { return ".contribution/info"; @@ -99,7 +112,7 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut Contribution contribution = contributionFactory.createContribution(); contribution.setURI(contributionURI.toString()); contribution.setLocation(contributionURL.toString()); - ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories); + ModelResolver modelResolver = new ExtensibleModelResolver(contribution, extensionPoints); contribution.setModelResolver(modelResolver); contribution.setUnresolved(true); diff --git a/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java b/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java index 28eede693d..67bd07dfb6 100644 --- a/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java +++ b/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java @@ -94,7 +94,7 @@ import org.xml.sax.SAXException; * @version $Rev$ $Date$ */ public class DistributeAndRunComponents { - + private static ExtensionPointRegistry extensionPoints; private static URLArtifactProcessor<Contribution> contributionProcessor; private static ModelResolverExtensionPoint modelResolvers; private static ModelFactoryExtensionPoint modelFactories; @@ -113,7 +113,7 @@ public class DistributeAndRunComponents { private static void init() { // Create extension point registry - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + extensionPoints = new DefaultExtensionPointRegistry(); // Create a monitor UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); @@ -171,7 +171,7 @@ public class DistributeAndRunComponents { // Create workspace model Workspace workspace = workspaceFactory.createWorkspace(); - workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); // Read the sample store contribution URI storeURI = URI.create("store"); diff --git a/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/DistributeComponents.java b/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/DistributeComponents.java index def0a1894f..08ddc8875e 100644 --- a/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/DistributeComponents.java +++ b/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/DistributeComponents.java @@ -49,7 +49,6 @@ import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; import org.apache.tuscany.sca.binding.atom.AtomBindingFactory; import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.ContributionFactory; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; @@ -71,7 +70,6 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; import org.apache.tuscany.sca.workspace.Workspace; import org.apache.tuscany.sca.workspace.WorkspaceFactory; import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; @@ -107,7 +105,7 @@ import org.xml.sax.SAXException; * @version $Rev$ $Date$ */ public class DistributeComponents { - + private static ExtensionPointRegistry extensionPoints; private static URLArtifactProcessor<Contribution> contributionProcessor; private static ModelResolverExtensionPoint modelResolvers; private static ModelFactoryExtensionPoint modelFactories; @@ -126,7 +124,7 @@ public class DistributeComponents { private static void init() { // Create extension point registry - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + extensionPoints = new DefaultExtensionPointRegistry(); // Create a monitor UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); @@ -184,7 +182,7 @@ public class DistributeComponents { // Create workspace model Workspace workspace = workspaceFactory.createWorkspace(); - workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); // Read the sample store contribution URI storeURI = URI.create("store"); diff --git a/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/ListComponents.java b/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/ListComponents.java index 27cb31d57f..7b3950833a 100644 --- a/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/ListComponents.java +++ b/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/ListComponents.java @@ -66,7 +66,7 @@ import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuild * @version $Rev$ $Date$ */ public class ListComponents { - + private static ExtensionPointRegistry extensionPoints; private static URLArtifactProcessor<Contribution> contributionProcessor; private static ModelResolverExtensionPoint modelResolvers; private static ModelFactoryExtensionPoint modelFactories; @@ -76,7 +76,7 @@ public class ListComponents { private static void init() { // Create extension point registry - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + extensionPoints = new DefaultExtensionPointRegistry(); // Initialize the Tuscany module activators ModuleActivatorExtensionPoint moduleActivators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class); @@ -110,7 +110,7 @@ public class ListComponents { // Create workspace model Workspace workspace = workspaceFactory.createWorkspace(); - workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); // Read the sample store contribution URI storeURI = URI.create("store"); diff --git a/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/WireComponents.java b/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/WireComponents.java index d24d5c67c9..16cda9d3e7 100644 --- a/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/WireComponents.java +++ b/branches/sca-java-1.x/samples/domain-management/src/main/java/manager/WireComponents.java @@ -86,7 +86,7 @@ import org.w3c.dom.Document; * @version $Rev$ $Date$ */ public class WireComponents { - + private static ExtensionPointRegistry extensionPoints; private static URLArtifactProcessor<Contribution> contributionProcessor; private static ModelResolverExtensionPoint modelResolvers; private static ModelFactoryExtensionPoint modelFactories; @@ -102,7 +102,7 @@ public class WireComponents { private static void init() { // Create extension point registry - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + extensionPoints = new DefaultExtensionPointRegistry(); // Create a monitor UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); @@ -155,7 +155,7 @@ public class WireComponents { // Create workspace model Workspace workspace = workspaceFactory.createWorkspace(); - workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); // Read the sample store contribution URI storeURI = URI.create("store"); |