summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java2
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java8
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java2
-rw-r--r--java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner8
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java11
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java11
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java13
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java12
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java8
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java8
-rw-r--r--java/sca/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java7
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java2
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java2
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java2
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java10
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java6
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java28
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java3
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java5
-rw-r--r--java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java2
-rw-r--r--java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java2
-rw-r--r--java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java1
-rw-r--r--java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java5
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java15
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java18
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java2
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java25
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java8
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java32
-rw-r--r--java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java3
-rw-r--r--java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java2
-rw-r--r--java/sca/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF2
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java2
-rw-r--r--java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java9
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java14
-rw-r--r--java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java13
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java49
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java48
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java22
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory2
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java1
42 files changed, 223 insertions, 203 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
index 1f256de3a2..af59324c7c 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
@@ -80,7 +80,7 @@ public class DefaultDefinitionsExtensionPoint implements DefinitionsExtensionPoi
// Get the definitions declarations
Collection<ServiceDeclaration> definitionsDeclarations;
try {
- definitionsDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(DEFINITIONS_FILE);
+ definitionsDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DEFINITIONS_FILE);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
index a886908589..b71764e0a4 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
@@ -127,11 +127,11 @@ public class ReadDocumentTestCase {
@Test
public void testReadImplementation() throws Exception {
-
- ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(registry);
schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas);
- DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry);
factories.addFactory(validatingInputFactory);
CompositeDocumentProcessor compositeDocumentProcessor =
@@ -157,7 +157,7 @@ public class ReadDocumentTestCase {
public void testReadBinding() throws Exception {
ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
- ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(registry);
schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas);
DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry);
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java
index 6d85405861..8afe493dec 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java
@@ -98,7 +98,7 @@ public class DefaultBuilderExtensionPoint implements BuilderExtensionPoint, Life
// Get the provider factory service declarations
Collection<ServiceDeclaration> builderDeclarations;
- ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance();
+ ServiceDiscovery serviceDiscovery = registry.getServiceDiscovery();
try {
builderDeclarations = serviceDiscovery.getServiceDeclarations(CompositeBuilder.class.getName());
} catch (Exception e) {
diff --git a/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner b/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner
index 4259d8c69a..4a8f93c084 100644
--- a/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner
+++ b/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner
@@ -13,6 +13,10 @@
# "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.
+# under the License.
+#
+# Eclipse Equinox
org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleContributionScanner;type=bundleentry
-org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleContributionScanner;type=bundleresource \ No newline at end of file
+org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleContributionScanner;type=bundleresource
+# Apache Felix
+org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleContributionScanner;type=bundle \ No newline at end of file
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
index 9c176fe1bf..151edeae0b 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
@@ -33,10 +33,8 @@ import javax.xml.stream.XMLStreamWriter;
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.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDeclarationParser;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
@@ -49,7 +47,7 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
public class DefaultStAXArtifactProcessorExtensionPoint extends
DefaultArtifactProcessorExtensionPoint<StAXArtifactProcessor<?>> implements StAXArtifactProcessorExtensionPoint {
- private ExtensionPointRegistry extensionPoints;
+ private ExtensionPointRegistry registry;
private FactoryExtensionPoint modelFactories;
private boolean loaded;
private StAXArtifactProcessor<Object> extensibleStAXProcessor;
@@ -59,11 +57,10 @@ public class DefaultStAXArtifactProcessorExtensionPoint extends
* Constructs a new extension point.
*/
public DefaultStAXArtifactProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) {
- this.extensionPoints = extensionPoints;
+ this.registry = extensionPoints;
this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
- UtilityExtensionPoint utilities = this.extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
this.extensibleStAXProcessor = new ExtensibleStAXArtifactProcessor(this, inputFactory, outputFactory);
StAXAttributeProcessorExtensionPoint attributeExtensionPoint =
@@ -113,7 +110,7 @@ public class DefaultStAXArtifactProcessorExtensionPoint extends
Collection<ServiceDeclaration> processorDeclarations;
try {
processorDeclarations =
- ServiceDiscovery.getInstance().getServiceDeclarations(StAXArtifactProcessor.class.getName());
+ registry.getServiceDiscovery().getServiceDeclarations(StAXArtifactProcessor.class.getName());
} catch (IOException e) {
IllegalStateException ie = new IllegalStateException(e);
throw ie;
@@ -136,7 +133,7 @@ public class DefaultStAXArtifactProcessorExtensionPoint extends
// Create a processor wrapper and register it
StAXArtifactProcessor<?> processor =
new LazyStAXArtifactProcessor(artifactType, modelTypeName, factoryName, processorDeclaration,
- extensionPoints, modelFactories, extensibleStAXProcessor,
+ registry, modelFactories, extensibleStAXProcessor,
extensibleStAXAttributeProcessor);
addArtifactProcessor(processor);
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
index 66a605c46a..e76d6cb299 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
@@ -36,7 +36,6 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDeclarationParser;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.Problem;
@@ -50,7 +49,7 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
public class DefaultStAXAttributeProcessorExtensionPoint extends
DefaultArtifactProcessorExtensionPoint<StAXAttributeProcessor<?>> implements StAXAttributeProcessorExtensionPoint {
- private ExtensionPointRegistry extensionPoints;
+ private ExtensionPointRegistry registry;
private FactoryExtensionPoint modelFactories;
private StAXAttributeProcessor<Object> extensibleStAXAttributeProcessor;
private boolean loaded;
@@ -60,11 +59,11 @@ public class DefaultStAXAttributeProcessorExtensionPoint extends
* Constructs a new extension point.
*/
public DefaultStAXAttributeProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) {
- this.extensionPoints = extensionPoints;
+ this.registry = extensionPoints;
this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
- UtilityExtensionPoint utilities = this.extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ UtilityExtensionPoint utilities = this.registry.getExtensionPoint(UtilityExtensionPoint.class);
MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
if (monitorFactory != null) {
this.monitor = monitorFactory.createMonitor();
@@ -133,7 +132,7 @@ public class DefaultStAXAttributeProcessorExtensionPoint extends
Collection<ServiceDeclaration> processorDeclarations;
try {
processorDeclarations =
- ServiceDiscovery.getInstance().getServiceDeclarations(StAXAttributeProcessor.class.getName());
+ registry.getServiceDiscovery().getServiceDeclarations(StAXAttributeProcessor.class.getName());
} catch (IOException e) {
IllegalStateException ie = new IllegalStateException(e);
error("IllegalStateException", extensibleStAXAttributeProcessor, ie);
@@ -157,7 +156,7 @@ public class DefaultStAXAttributeProcessorExtensionPoint extends
// Create a processor wrapper and register it
StAXAttributeProcessor<?> processor =
new LazyStAXAttributeProcessor(artifactType, modelTypeName, factoryName, processorDeclaration,
- extensionPoints, modelFactories, extensibleStAXAttributeProcessor);
+ registry, modelFactories, extensibleStAXAttributeProcessor);
addArtifactProcessor(processor);
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
index 3fc6140f6d..e22d7762fa 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
@@ -35,9 +35,7 @@ import javax.xml.stream.XMLOutputFactory;
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.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
* The default implementation of a URL artifact processor extension point.
@@ -47,7 +45,7 @@ import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
public class DefaultURLArtifactProcessorExtensionPoint extends
DefaultArtifactProcessorExtensionPoint<URLArtifactProcessor<?>> implements URLArtifactProcessorExtensionPoint {
- private ExtensionPointRegistry extensionPoints;
+ private ExtensionPointRegistry registry;
private StAXArtifactProcessor<?> staxProcessor;
private boolean loaded;
@@ -55,11 +53,10 @@ public class DefaultURLArtifactProcessorExtensionPoint extends
* Constructs a new extension point.
*/
public DefaultURLArtifactProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) {
- this.extensionPoints = extensionPoints;
- FactoryExtensionPoint modelFactories = this.extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.registry = extensionPoints;
+ FactoryExtensionPoint modelFactories = this.registry.getExtensionPoint(FactoryExtensionPoint.class);
XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
- UtilityExtensionPoint utilities = this.extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
StAXArtifactProcessorExtensionPoint staxProcessors =
extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
@@ -201,7 +198,7 @@ public class DefaultURLArtifactProcessorExtensionPoint extends
Collection<ServiceDeclaration> processorDeclarations;
try {
processorDeclarations =
- ServiceDiscovery.getInstance().getServiceDeclarations(URLArtifactProcessor.class.getName());
+ registry.getServiceDiscovery().getServiceDeclarations(URLArtifactProcessor.class.getName());
} catch (IOException e) {
IllegalStateException ie = new IllegalStateException(e);
throw ie;
@@ -215,7 +212,7 @@ public class DefaultURLArtifactProcessorExtensionPoint extends
// Create a processor wrapper and register it
URLArtifactProcessor<?> processor =
- new LazyURLArtifactProcessor(artifactType, modelTypeName, processorDeclaration, extensionPoints,
+ new LazyURLArtifactProcessor(artifactType, modelTypeName, processorDeclaration, registry,
staxProcessor);
addArtifactProcessor(processor);
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java
index 8fa873d7c7..da7a57a687 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java
@@ -27,8 +27,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
* Default implementation of an extension point for XML schemas.
@@ -39,7 +39,13 @@ public class DefaultValidationSchemaExtensionPoint implements ValidationSchemaEx
private boolean enabled = true;
private List<String> schemas = new ArrayList<String>();
private boolean loaded;
-
+ private ExtensionPointRegistry registry;
+
+ public DefaultValidationSchemaExtensionPoint(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
public void addSchema(String uri) {
schemas.add(uri);
}
@@ -60,7 +66,7 @@ public class DefaultValidationSchemaExtensionPoint implements ValidationSchemaEx
Collection<ServiceDeclaration> schemaDeclarations;
try {
schemaDeclarations =
- ServiceDiscovery.getInstance()
+ registry.getServiceDiscovery()
.getServiceDeclarations("org.apache.tuscany.sca.contribution.processor.ValidationSchema");
} catch (IOException e) {
throw new IllegalStateException(e);
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
index e66dee26af..ac16d413eb 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
@@ -24,8 +24,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
@@ -37,11 +37,13 @@ public class DefaultModelResolverExtensionPoint implements ModelResolverExtensio
private final Map<Class<?>, Class<? extends ModelResolver>> resolvers = new HashMap<Class<?>, Class<? extends ModelResolver>>();
private Map<String, ServiceDeclaration> loadedResolvers;
+ private ExtensionPointRegistry registry;
/**
* Constructs a new DefaultModelResolverExtensionPoint.
*/
- public DefaultModelResolverExtensionPoint() {
+ public DefaultModelResolverExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
}
public void addResolver(Class<?> modelType, Class<? extends ModelResolver> resolver) {
@@ -98,7 +100,7 @@ public class DefaultModelResolverExtensionPoint implements ModelResolverExtensio
// Get the model resolver service declarations
Collection<ServiceDeclaration> modelResolverDeclarations;
try {
- modelResolverDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ModelResolver.class.getName());
+ modelResolverDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ModelResolver.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
index a1af72da72..610a1eb7ba 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
@@ -29,8 +29,8 @@ import java.util.Map;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
* Default implementation of a contribution scanner extension point.
@@ -41,8 +41,10 @@ public class DefaultContributionScannerExtensionPoint implements ContributionSca
private Map<String, ContributionScanner> scanners = new HashMap<String, ContributionScanner>();
private boolean loaded;
+ private ExtensionPointRegistry registry;
- public DefaultContributionScannerExtensionPoint() {
+ public DefaultContributionScannerExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
}
public void addContributionScanner(ContributionScanner scanner) {
@@ -65,7 +67,7 @@ public class DefaultContributionScannerExtensionPoint implements ContributionSca
// Get the scanner service declarations
Collection<ServiceDeclaration> scannerDeclarations;
try {
- scannerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ContributionScanner.class.getName());
+ scannerDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ContributionScanner.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/java/sca/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java
index d6461bd094..7692c8ecdf 100644
--- a/java/sca/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java
+++ b/java/sca/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java
@@ -27,6 +27,7 @@ import org.apache.tuscany.sca.contribution.DefaultContributionFactory;
import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.junit.Before;
import org.junit.Test;
@@ -44,11 +45,11 @@ public class ExtensibleModelResolverTestCase {
@Before
public void setUp() throws Exception {
-
- ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint();
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(registry);
resolvers.addResolver(Model.class, TestModelResolver.class);
context = new ProcessorContext();
- FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
+ FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry);
resolver = new ExtensibleModelResolver(null, resolvers, factories);
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
index 3c4be9cd55..c079a9dc66 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
@@ -94,7 +94,7 @@ public class DefaultContextFactoryExtensionPoint implements ContextFactoryExtens
// Dynamically load a factory class declared under META-INF/services
try {
- ServiceDeclaration factoryDeclaration = ServiceDiscovery.getInstance().getServiceDeclaration(factoryInterface.getName());
+ ServiceDeclaration factoryDeclaration = registry.getServiceDiscovery().getServiceDeclaration(factoryInterface.getName());
if (factoryDeclaration != null) {
Class<?> factoryClass = factoryDeclaration.loadClass();
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
index 61af242182..2ee058a14d 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
@@ -131,7 +131,7 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte
// Get the provider factory service declarations
Collection<ServiceDeclaration> factoryDeclarations;
- ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance();
+ ServiceDiscovery serviceDiscovery = registry.getServiceDiscovery();
try {
factoryDeclarations = serviceDiscovery.getServiceDeclarations(factoryClass.getName(), true);
} catch (Exception e) {
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java
index 9f28f7650a..283d1d1a8b 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java
@@ -90,7 +90,7 @@ public class DefaultWireProcessorExtensionPoint implements RuntimeWireProcessorE
}
try {
Collection<ServiceDeclaration> sds =
- ServiceDiscovery.getInstance().getServiceDeclarations(RuntimeWireProcessor.class, true);
+ registry.getServiceDiscovery().getServiceDeclarations(RuntimeWireProcessor.class, true);
for (ServiceDeclaration sd : sds) {
Class type = sd.loadClass();
Constructor constructor = null;
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
index 62b71c47d1..3284168aeb 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
@@ -43,6 +43,7 @@ import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
import org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker;
import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl;
+import org.apache.tuscany.sca.core.invocation.impl.PhaseManager;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -88,6 +89,7 @@ public class RuntimeWireImpl implements RuntimeWire {
private transient RuntimeWireProcessor wireProcessor;
private transient InterfaceContractMapper interfaceContractMapper;
private transient WorkScheduler workScheduler;
+ private transient PhaseManager phaseManager;
private transient MessageFactory messageFactory;
private transient RuntimeWireInvoker invoker;
@@ -135,6 +137,7 @@ public class RuntimeWireImpl implements RuntimeWire {
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
+ this.phaseManager = utilities.getUtility(PhaseManager.class);
this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
}
@@ -158,6 +161,7 @@ public class RuntimeWireImpl implements RuntimeWire {
this.invoker = new RuntimeWireInvoker(this.messageFactory, this);
this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
+ this.phaseManager = utilities.getUtility(PhaseManager.class);
this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
}
@@ -170,7 +174,7 @@ public class RuntimeWireImpl implements RuntimeWire {
public synchronized InvocationChain getBindingInvocationChain() {
if (bindingInvocationChain == null) {
- bindingInvocationChain = new InvocationChainImpl(null, null, isReferenceWire);
+ bindingInvocationChain = new InvocationChainImpl(null, null, isReferenceWire, phaseManager);
if (isReferenceWire) {
initReferenceBindingInvocationChains();
} else {
@@ -289,7 +293,7 @@ public class RuntimeWireImpl implements RuntimeWire {
+ "#"
+ reference.getName());
}
- InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true);
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true, phaseManager);
if (operation.isNonBlocking()) {
addNonBlockingInterceptor(reference, refBinding, chain);
}
@@ -315,7 +319,7 @@ public class RuntimeWireImpl implements RuntimeWire {
+ "#"
+ service.getName());
}
- InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false);
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false, phaseManager);
if (operation.isNonBlocking()) {
addNonBlockingInterceptor(service, serviceBinding, chain);
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
index d8eb746776..60914f799b 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
@@ -40,15 +40,15 @@ public class InvocationChainImpl implements InvocationChain {
private Operation targetOperation;
private List<Node> nodes = new ArrayList<Node>();
- // FIXME: Not a good practice to use static reference
- private static final PhaseManager phaseManager = new PhaseManager();
+ private final PhaseManager phaseManager;
private boolean forReference;
private boolean allowsPassByReference;
- public InvocationChainImpl(Operation sourceOperation, Operation targetOperation, boolean forReference) {
+ public InvocationChainImpl(Operation sourceOperation, Operation targetOperation, boolean forReference, PhaseManager phaseManager) {
this.targetOperation = targetOperation;
this.sourceOperation = sourceOperation;
this.forReference = forReference;
+ this.phaseManager = phaseManager;
}
public Operation getTargetOperation() {
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
index c9024fecef..1649eade87 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
@@ -49,8 +49,10 @@ import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.invocation.Phase;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -59,7 +61,7 @@ import org.oasisopen.sca.ServiceRuntimeException;
*/
public class PhaseManager {
private static final Logger log = Logger.getLogger(PhaseManager.class.getName());
-
+
public static final String STAGE_REFERENCE = "reference";
public static final String STAGE_REFERENCE_BINDING = "reference.binding";
public static final String STAGE_SERVICE_BINDING = "service.binding";
@@ -80,6 +82,7 @@ public class PhaseManager {
private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {IMPLEMENTATION_POLICY, IMPLEMENTATION};
+ private ExtensionPointRegistry registry;
private String pattern = Phase.class.getName();
private Map<String, Stage> stages;
private List<String> phases;
@@ -121,14 +124,25 @@ public class PhaseManager {
return name + phases;
}
}
-
+
+ /**
+ * @param registry
+ */
+ public PhaseManager(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public static PhaseManager getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilityExtensionPoint.getUtility(PhaseManager.class);
+ }
+
// For unit test purpose
PhaseManager(String pattern) {
super();
this.pattern = pattern;
- }
-
- public PhaseManager() {
+ this.registry = new DefaultExtensionPointRegistry();
}
private List<String> getPhases(String stage) {
@@ -176,7 +190,7 @@ public class PhaseManager {
Collection<ServiceDeclaration> services;
try {
- services = ServiceDiscovery.getInstance().getServiceDeclarations(pattern);
+ services = registry.getServiceDiscovery().getServiceDeclarations(pattern);
} catch (IOException e) {
throw new ServiceRuntimeException(e);
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
index d80e2b5490..3240b4e50d 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
@@ -32,7 +32,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.EndpointListener;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -58,7 +57,7 @@ public class DefaultDomainRegistryFactory implements DomainRegistryFactory, Life
public void start() {
Collection<ServiceDeclaration> sds = null;
try {
- sds = ServiceDiscovery.getInstance().getServiceDeclarations(EndpointRegistry.class);
+ sds = extensionRegistry.getServiceDiscovery().getServiceDeclarations(EndpointRegistry.class);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java
index c8990686b9..1302bed681 100644
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java
+++ b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java
@@ -20,6 +20,7 @@ package org.apache.tuscany.sca.core.invocation.impl;
import static org.junit.Assert.assertEquals;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
import org.apache.tuscany.sca.invocation.Interceptor;
@@ -37,7 +38,7 @@ public class InvocationChainImplTestCase {
@Test
public void testInsertAtEnd() throws Exception {
Operation op = newOperation("foo");
- InvocationChain chain = new InvocationChainImpl(op, op, true);
+ InvocationChain chain = new InvocationChainImpl(op, op, true, new PhaseManager(new DefaultExtensionPointRegistry()));
Interceptor inter2 = new MockInterceptor();
Interceptor inter1 = new MockInterceptor();
chain.addInterceptor(inter1);
@@ -50,7 +51,7 @@ public class InvocationChainImplTestCase {
@Test
public void testAddByPhase() throws Exception {
Operation op = newOperation("foo");
- InvocationChain chain = new InvocationChainImpl(op, op, false);
+ InvocationChain chain = new InvocationChainImpl(op, op, false, new PhaseManager(new DefaultExtensionPointRegistry()));
Interceptor inter1 = new MockInterceptor();
Interceptor inter2 = new MockInterceptor();
Interceptor inter3 = new MockInterceptor();
diff --git a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
index 26d6133472..19455fcd29 100644
--- a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
+++ b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
@@ -107,7 +107,7 @@ public class DefaultDataBindingExtensionPoint implements DataBindingExtensionPoi
// Get the databinding service declarations
Collection<ServiceDeclaration> dataBindingDeclarations;
try {
- dataBindingDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(DataBinding.class.getName());
+ dataBindingDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DataBinding.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
index 6258465c13..39889b1e97 100644
--- a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
+++ b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
@@ -118,7 +118,7 @@ public class DefaultTransformerExtensionPoint implements TransformerExtensionPoi
Collection<ServiceDeclaration> transformerDeclarations;
try {
- transformerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(transformerClass.getName());
+ transformerDeclarations = registry.getServiceDiscovery().getServiceDeclarations(transformerClass.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
diff --git a/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java b/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java
index a9a0d6d3f6..4ccaf57c19 100644
--- a/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java
+++ b/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java
@@ -38,6 +38,7 @@ public class EquinoxServiceDiscoveryActivator implements BundleActivator {
}
public void stop(BundleContext context) throws Exception {
+ ServiceDiscovery.getInstance().setServiceDiscoverer(null);
}
}
diff --git a/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java b/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
index bfa98ad725..51cb58f3b3 100644
--- a/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
+++ b/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
@@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -42,7 +43,7 @@ public class OSGiExtensionPointRegistry extends DefaultExtensionPointRegistry {
private BundleContext bundleContext;
public OSGiExtensionPointRegistry(BundleContext bundleContext) {
- super();
+ super(ServiceDiscovery.getInstance(new EquinoxServiceDiscoverer(bundleContext)));
this.bundleContext = bundleContext;
}
@@ -102,7 +103,7 @@ public class OSGiExtensionPointRegistry extends DefaultExtensionPointRegistry {
}
@Override
- public void stop() {
+ public synchronized void stop() {
// Get a unique map as an extension point may exist in the map by different keys
Map<LifeCycleListener, LifeCycleListener> map = new IdentityHashMap<LifeCycleListener, LifeCycleListener>();
for (ServiceRegistration reg : services.values()) {
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
index f6be464cbc..66df61996b 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
@@ -42,11 +42,16 @@ import org.apache.tuscany.sca.extensibility.ServiceHelper;
*/
public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
private Map<Class<?>, Object> extensionPoints = new HashMap<Class<?>, Object>();
-
+ private ServiceDiscovery discovery;
/**
* Constructs a new registry.
*/
public DefaultExtensionPointRegistry() {
+ this.discovery = ServiceDiscovery.getInstance();
+ }
+
+ protected DefaultExtensionPointRegistry(ServiceDiscovery discovery) {
+ this.discovery = discovery;
}
/**
@@ -162,11 +167,11 @@ public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
}
}
- public void start() {
+ public synchronized void start() {
// Do nothing
}
- public void stop() {
+ public synchronized void stop() {
// Get a unique map as an extension point may exist in the map by different keys
Map<LifeCycleListener, LifeCycleListener> map = new IdentityHashMap<LifeCycleListener, LifeCycleListener>();
for (Object extp : extensionPoints.values()) {
@@ -179,4 +184,8 @@ public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
extensionPoints.clear();
}
+ public ServiceDiscovery getServiceDiscovery() {
+ return discovery;
+ }
+
}
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
index 300acdc259..2ccb192fdb 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
@@ -26,9 +26,9 @@ import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
+import java.util.Map;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
@@ -38,14 +38,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>();
+ private ExtensionPointRegistry registry;
+ private Map<Class<?>, Object> factories = new HashMap<Class<?>, Object>();
/**
* Constructs a new DefaultModelFactoryExtensionPoint.
*/
public DefaultFactoryExtensionPoint(ExtensionPointRegistry extensionPointRegistry) {
- this.extensionPointRegistry = extensionPointRegistry;
+ this.registry = extensionPointRegistry;
}
/**
@@ -53,7 +53,7 @@ public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint {
*
* @param factory The factory to add
*/
- public void addFactory(Object factory) {
+ public synchronized void addFactory(Object factory) {
Class<?>[] interfaces = factory.getClass().getInterfaces();
if (interfaces.length == 0) {
Class<?> sc = factory.getClass().getSuperclass();
@@ -72,7 +72,7 @@ public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint {
*
* @param factory The factory to remove
*/
- public void removeFactory(Object factory) {
+ public synchronized void removeFactory(Object factory) {
Class<?>[] interfaces = factory.getClass().getInterfaces();
if (interfaces.length == 0) {
Class<?> sc = factory.getClass().getSuperclass();
@@ -103,18 +103,18 @@ public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint {
* @param factoryInterface The lookup key (factory interface)
* @return The factory
*/
- public <T> T getFactory(Class<T> factoryInterface) {
+ public synchronized <T> T getFactory(Class<T> factoryInterface) {
Object factory = factories.get(factoryInterface);
if (factory == null) {
// Dynamically load a factory class declared under META-INF/services
try {
ServiceDeclaration factoryDeclaration =
- ServiceDiscovery.getInstance().getServiceDeclaration(factoryInterface);
+ registry.getServiceDiscovery().getServiceDeclaration(factoryInterface);
if (factoryDeclaration != null) {
try {
// Constructor taking the extension point registry
- factory = newInstance(extensionPointRegistry, factoryDeclaration);
+ factory = newInstance(registry, factoryDeclaration);
} catch (NoSuchMethodException e) {
factory = newInstance(factoryDeclaration.loadClass(), FactoryExtensionPoint.class, this);
}
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
index 83bc4a836e..fc958afad5 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
@@ -77,7 +77,7 @@ public class DefaultModuleActivatorExtensionPoint implements ModuleActivatorExte
Collection<ServiceDeclaration> activatorDeclarations;
try {
// Load the module activators by ranking
- activatorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class.getName(), true);
+ activatorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ModuleActivator.class.getName(), true);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
index eca59d689d..41e2377db5 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
@@ -30,7 +30,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
* Default implementation of an extension point to hold Tuscany utility utilities.
@@ -40,12 +39,12 @@ import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
private Map<Object, Object> utilities = new ConcurrentHashMap<Object, Object>();
- private ExtensionPointRegistry extensionPoints;
+ private ExtensionPointRegistry registry;
/**
* Constructs a new extension point.
*/
public DefaultUtilityExtensionPoint(ExtensionPointRegistry extensionPoints) {
- this.extensionPoints = extensionPoints;
+ this.registry = extensionPoints;
}
/**
@@ -56,11 +55,11 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
*
* @throws IllegalArgumentException if utility is null
*/
- public void addUtility(Object utility) {
+ public synchronized void addUtility(Object utility) {
addUtility(null, utility);
}
- public void addUtility(Object key, Object utility) {
+ public synchronized void addUtility(Object key, Object utility) {
if (utility == null) {
throw new IllegalArgumentException("Cannot register null as a Service");
}
@@ -91,7 +90,7 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
*
* @throws IllegalArgumentException if utilityType is null
*/
- public <T> T getUtility(Class<T> utilityType) {
+ public synchronized <T> T getUtility(Class<T> utilityType) {
return getUtility(utilityType, null);
}
@@ -102,7 +101,7 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
*
* @throws IllegalArgumentException if utility is null
*/
- public void removeUtility(Object utility) {
+ public synchronized void removeUtility(Object utility) {
if (utility == null) {
throw new IllegalArgumentException("Cannot remove null as a Service");
}
@@ -144,7 +143,7 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
}
}
- public <T> T getUtility(Class<T> utilityType, Object key) {
+ public synchronized <T> T getUtility(Class<T> utilityType, Object key) {
if (utilityType == null) {
throw new IllegalArgumentException("Cannot lookup Service of type null");
}
@@ -160,7 +159,7 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
// Dynamically load a utility class declared under META-INF/services/"utilityType"
try {
ServiceDeclaration utilityDeclaration =
- ServiceDiscovery.getInstance().getServiceDeclaration(utilityType.getName());
+ registry.getServiceDiscovery().getServiceDeclaration(utilityType.getName());
Class<?> utilityClass = null;
if (utilityDeclaration != null) {
utilityClass = utilityDeclaration.loadClass();
@@ -171,10 +170,10 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
if (utilityClass != null) {
// Construct the utility
if (utilityDeclaration != null) {
- utility = newInstance(extensionPoints, utilityDeclaration);
+ utility = newInstance(registry, utilityDeclaration);
} else {
try {
- utility = newInstance(utilityClass, ExtensionPointRegistry.class, extensionPoints);
+ utility = newInstance(utilityClass, ExtensionPointRegistry.class, registry);
} catch (NoSuchMethodException e) {
utility = newInstance(utilityClass);
}
@@ -198,11 +197,11 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
return !utilityType.isInterface() && Modifier.isPublic(modifiers) && !Modifier.isAbstract(modifiers);
}
- public void start() {
+ public synchronized void start() {
// NOOP
}
- public void stop() {
+ public synchronized void stop() {
// Get a unique map as an extension point may exist in the map by different keys
Map<LifeCycleListener, LifeCycleListener> map = new IdentityHashMap<LifeCycleListener, LifeCycleListener>();
for (Object util : utilities.values()) {
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java
index 4c6fbd283f..762fcad7aa 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java
@@ -19,6 +19,8 @@
package org.apache.tuscany.sca.core;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+
/**
* The registry for the Tuscany core extension points. As the point of contact
@@ -53,4 +55,10 @@ public interface ExtensionPointRegistry extends LifeCycleListener {
* @throws IllegalArgumentException if extensionPoint is null
*/
void removeExtensionPoint(Object extensionPoint);
+
+ /**
+ * Get an instance of the ServiceDiscovery
+ * @return an instance of the ServiceDiscovery associated with the environment
+ */
+ ServiceDiscovery getServiceDiscovery();
}
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
index ca401a6484..1c03166eeb 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
@@ -53,6 +53,11 @@ public final class ServiceDiscovery implements ServiceDiscoverer {
super();
}
+ private ServiceDiscovery(ServiceDiscoverer discoverer) {
+ super();
+ this.discoverer = discoverer;
+ }
+
/**
* Get an instance of Service discovery, one instance is created per
* ClassLoader that this class is loaded from
@@ -62,6 +67,10 @@ public final class ServiceDiscovery implements ServiceDiscoverer {
public static ServiceDiscovery getInstance() {
return INSTANCE;
}
+
+ public static ServiceDiscovery getInstance(ServiceDiscoverer discoverer) {
+ return new ServiceDiscovery(discoverer);
+ }
public ServiceDiscoverer getServiceDiscoverer() {
if (discoverer != null) {
@@ -80,8 +89,8 @@ public final class ServiceDiscovery implements ServiceDiscoverer {
}
public void setServiceDiscoverer(ServiceDiscoverer sd) {
- if (discoverer != null) {
- throw new IllegalStateException("The ServiceDiscoverer cannot be reset");
+ if (discoverer != null && sd != null) {
+ logger.warning("ServiceDiscoverer is reset to " + sd);
}
discoverer = sd;
}
@@ -255,9 +264,9 @@ public final class ServiceDiscovery implements ServiceDiscoverer {
@Override
protected Class<?> findClass(String className) throws ClassNotFoundException {
- for (ClassLoader parent : classLoaders) {
+ for (ClassLoader delegate : classLoaders) {
try {
- return parent.loadClass(className);
+ return delegate.loadClass(className);
} catch (ClassNotFoundException e) {
continue;
}
@@ -267,8 +276,8 @@ public final class ServiceDiscovery implements ServiceDiscoverer {
@Override
protected URL findResource(String resName) {
- for (ClassLoader parent : classLoaders) {
- URL url = parent.getResource(resName);
+ for (ClassLoader delegate : classLoaders) {
+ URL url = delegate.getResource(resName);
if (url != null) {
return url;
}
@@ -279,8 +288,8 @@ public final class ServiceDiscovery implements ServiceDiscoverer {
@Override
protected Enumeration<URL> findResources(String resName) throws IOException {
Set<URL> urlSet = new HashSet<URL>();
- for (ClassLoader parent : classLoaders) {
- Enumeration<URL> urls = parent.getResources(resName);
+ for (ClassLoader delegate : classLoaders) {
+ Enumeration<URL> urls = delegate.getResources(resName);
if (urls != null) {
while (urls.hasMoreElements()) {
urlSet.add(urls.nextElement());
@@ -327,6 +336,13 @@ public final class ServiceDiscovery implements ServiceDiscoverer {
return loaders;
}
+ /**
+ * Set the thread context classloader (TCCL) to a classloader that delegates to a collection
+ * of classloaders
+ * @param parent The parent classloader
+ * @param delegates A list of classloaders to try
+ * @return The existing TCCL
+ */
public ClassLoader setContextClassLoader(ClassLoader parent, ClassLoader... delegates) {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
List<ClassLoader> loaders = new ArrayList<ClassLoader>();
diff --git a/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java b/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
index 6e9e3f07d3..0a5f4d6442 100644
--- a/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
+++ b/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.extensibility;
import java.io.Serializable;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.DefaultUtilityExtensionPoint;
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -41,7 +42,7 @@ public class DefaultUtilityExtensionPointTestCase {
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- ep = new DefaultUtilityExtensionPoint(null);
+ ep = new DefaultUtilityExtensionPoint(new DefaultExtensionPointRegistry());
ep.start();
}
diff --git a/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java b/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
index d91485cbb5..04b2f4c199 100644
--- a/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
+++ b/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
@@ -76,7 +76,7 @@ public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoi
// Get the databinding service declarations
Collection<ServiceDeclaration> sds;
try {
- sds = ServiceDiscovery.getInstance().getServiceDeclarations(ServletHost.class, true);
+ sds = registry.getServiceDiscovery().getServiceDeclarations(ServletHost.class, true);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF b/java/sca/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF
index 722d5b3c81..5e40de7a52 100644
--- a/java/sca/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF
+++ b/java/sca/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF
@@ -53,7 +53,7 @@ Import-Package: javax.resource.spi,
org.apache.tuscany.sca.policy;version="2.0.0",
org.apache.tuscany.sca.provider;version="2.0",
org.apache.tuscany.sca.runtime;version="2.0",
- org.eclipse.core.runtime;common=split,
+ org.eclipse.core.runtime;resolution:=optional;common=split,
org.oasisopen.sca.annotation;version="2.0",
org.w3c.dom;resolution:=optional
Bundle-SymbolicName: org.apache.tuscany.sca.implementation.bpel.ode
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
index a1f65ecc00..aefc5c7e6b 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
@@ -95,7 +95,7 @@ public abstract class JavaImplementationFactoryImpl implements JavaImplementatio
// Get the databinding service declarations
Collection<ServiceDeclaration> visitorDeclarations;
try {
- visitorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(JavaClassVisitor.class, true);
+ visitorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(JavaClassVisitor.class, true);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
index 85af53068a..1e36b95da3 100644
--- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
+++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
@@ -26,7 +26,6 @@ import java.util.logging.Logger;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceFactoryImpl;
import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
@@ -38,13 +37,13 @@ import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
public class DefaultJavaInterfaceFactory extends JavaInterfaceFactoryImpl implements JavaInterfaceFactory {
private static final Logger logger = Logger.getLogger(DefaultJavaInterfaceFactory.class.getName());
- private ExtensionPointRegistry extensionPointRegistry;
+ private ExtensionPointRegistry registry;
// private Monitor monitor = null;
private boolean loadedVisitors;
public DefaultJavaInterfaceFactory(ExtensionPointRegistry registry) {
super();
- this.extensionPointRegistry = registry;
+ this.registry = registry;
}
@Override
@@ -64,7 +63,7 @@ public class DefaultJavaInterfaceFactory extends JavaInterfaceFactoryImpl implem
// Get the databinding service declarations
Collection<ServiceDeclaration> visitorDeclarations;
try {
- visitorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(JavaInterfaceVisitor.class, true);
+ visitorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(JavaInterfaceVisitor.class, true);
} catch (IOException e) {
throw new IllegalStateException(e);
}
@@ -77,7 +76,7 @@ public class DefaultJavaInterfaceFactory extends JavaInterfaceFactoryImpl implem
try {
Constructor<JavaInterfaceVisitor> constructor = visitorClass.getConstructor(ExtensionPointRegistry.class);
- visitor = constructor.newInstance(extensionPointRegistry);
+ visitor = constructor.newInstance(registry);
} catch (NoSuchMethodException e) {
visitor = visitorClass.newInstance();
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
index 24dac505ef..a4daa2177d 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
@@ -166,8 +166,8 @@ public abstract class NodeFactory extends DefaultNodeConfigurationFactory {
Class<?> discoveryClass = Class.forName("org.apache.tuscany.sca.extensibility.ServiceDiscovery");
Object instance = discoveryClass.getMethod("getInstance").invoke(null);
Object factoryDeclaration =
- discoveryClass.getMethod("getServiceDeclaration", String.class).invoke(instance,
- NodeFactory.class.getName());
+ discoveryClass.getMethod("getServiceDeclaration", Class.class).invoke(instance,
+ NodeFactory.class);
if (factoryDeclaration != null) {
Class<?> factoryImplClass =
(Class<?>)factoryDeclaration.getClass().getMethod("loadClass").invoke(factoryDeclaration);
@@ -177,11 +177,13 @@ public abstract class NodeFactory extends DefaultNodeConfigurationFactory {
// Ignore
}
- // Fail back to default impl
- String className = "org.apache.tuscany.sca.node.impl.NodeFactoryImpl";
+ if (nodeFactory == null) {
+ // Fail back to default impl
+ String className = "org.apache.tuscany.sca.node.impl.NodeFactoryImpl";
- Class<?> cls = Class.forName(className);
- nodeFactory = (NodeFactory)cls.newInstance();
+ Class<?> cls = Class.forName(className);
+ nodeFactory = (NodeFactory)cls.newInstance();
+ }
} catch (Exception e) {
throw new ServiceRuntimeException(e);
diff --git a/java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF b/java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF
index 70ba184107..3eae6468a1 100644
--- a/java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF
+++ b/java/sca/modules/node-impl-osgi/META-INF/MANIFEST.MF
@@ -42,6 +42,7 @@ Import-Package: javax.xml.namespace,
org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
org.osgi.framework;version="1.4.0",
org.osgi.framework.hooks.service;version="1.0.0";resolution:=optional,
+ org.osgi.service.cm;version="1.2.1",
org.osgi.service.component;version="1.1.0";resolution:=optional,
org.osgi.service.event;version="1.2.0",
org.osgi.service.packageadmin;version="1.2.0";resolution:=optional,
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
index 42481c7e8e..e8bf5def45 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
@@ -33,6 +33,7 @@ import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceRegistration;
/**
@@ -44,10 +45,22 @@ public class OSGiNodeFactoryImpl extends NodeFactoryImpl {
private ServiceRegistration registration;
private BundleContext bundleContext;
+ public OSGiNodeFactoryImpl() {
+ super();
+ Bundle bundle = FrameworkUtil.getBundle(OSGiNodeFactoryImpl.class);
+ if (bundle != null) {
+ this.bundleContext = bundle.getBundleContext();
+ autoDestroy = false;
+ setNodeFactory(this);
+ } else {
+ throw new IllegalStateException(OSGiNodeFactoryImpl.class + " is not loaded by OSGi");
+ }
+ }
/**
* Constructs a new Node controller
*/
public OSGiNodeFactoryImpl(BundleContext bundleContext) {
+ super();
this.bundleContext = bundleContext;
autoDestroy = false;
setNodeFactory(this);
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
index d6cbe1a44b..02603417cc 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
@@ -30,29 +30,18 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
-import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
import org.apache.tuscany.sca.node.impl.NodeImpl;
import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
import org.apache.tuscany.sca.osgi.remoteserviceadmin.ExportRegistration;
-import org.apache.tuscany.sca.osgi.service.discovery.impl.LocalDiscoveryService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
/**
* Watching and exporting OSGi services
*/
-public class OSGiServiceExporter implements ServiceTrackerCustomizer, LifeCycleListener {
- private ExtensionPointRegistry registry;
- private BundleContext context;
- private NodeFactoryImpl nodeFactory;
- private EndpointIntrospector introspector;
- private ServiceTracker discoveryTracker;
+public class OSGiServiceExporter extends AbstractOSGiServiceHandler implements ServiceTrackerCustomizer {
/**
* @param context
@@ -60,32 +49,13 @@ public class OSGiServiceExporter implements ServiceTrackerCustomizer, LifeCycleL
* @param customizer
*/
public OSGiServiceExporter(BundleContext context) {
- this.context = context;
- }
-
- private synchronized void init() {
- if (nodeFactory == null) {
- this.nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance();
- this.nodeFactory.init();
- this.discoveryTracker = LocalDiscoveryService.getTracker(context);
- discoveryTracker.open();
- this.introspector = new EndpointIntrospector(context, getExtensionPointRegistry(), discoveryTracker);
- }
+ super(context);
}
public void start() {
init();
}
- public void stop() {
- discoveryTracker.close();
- discoveryTracker = null;
- introspector = null;
- nodeFactory = null;
- registry = null;
- context = null;
- }
-
public Object addingService(ServiceReference reference) {
return exportService(reference, null);
}
@@ -97,6 +67,9 @@ public class OSGiServiceExporter implements ServiceTrackerCustomizer, LifeCycleL
if (contribution != null) {
NodeConfiguration configuration = nodeFactory.createNodeConfiguration();
+ if (domainRegistry != null) {
+ configuration.setDomainRegistryURI(domainRegistry);
+ }
configuration.setURI(contribution.getURI());
configuration.getExtensions().add(reference.getBundle());
// FIXME: Configure the domain and node URI
@@ -132,16 +105,4 @@ public class OSGiServiceExporter implements ServiceTrackerCustomizer, LifeCycleL
exportRegistration.close();
}
}
-
- protected ExtensionPointRegistry getExtensionPointRegistry() {
- if (registry == null) {
- ServiceTracker tracker = new ServiceTracker(context, ExtensionPointRegistry.class.getName(), null);
- tracker.open();
- // tracker.waitForService(1000);
- registry = (ExtensionPointRegistry)tracker.getService();
- tracker.close();
- }
- return registry;
- }
-
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
index 582adb22ef..5d5b72183f 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
@@ -24,30 +24,19 @@ import java.util.Collections;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
-import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
import org.apache.tuscany.sca.node.impl.NodeImpl;
import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
import org.apache.tuscany.sca.osgi.remoteserviceadmin.ImportRegistration;
-import org.apache.tuscany.sca.osgi.service.discovery.impl.LocalDiscoveryService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
/**
* Watching and exporting OSGi services
*/
-public class OSGiServiceImporter implements LifeCycleListener {
- private ExtensionPointRegistry registry;
- private BundleContext context;
- private NodeFactoryImpl nodeFactory;
- private EndpointIntrospector introspector;
- private ServiceTracker discoveryTracker;
+public class OSGiServiceImporter extends AbstractOSGiServiceHandler {
/**
* @param context
@@ -55,31 +44,12 @@ public class OSGiServiceImporter implements LifeCycleListener {
* @param customizer
*/
public OSGiServiceImporter(BundleContext context) {
- this.context = context;
- }
-
- private synchronized void init() {
- if (nodeFactory == null) {
- this.nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance();
- this.nodeFactory.init();
- this.discoveryTracker = LocalDiscoveryService.getTracker(context);
- discoveryTracker.open();
- this.introspector = new EndpointIntrospector(context, getExtensionPointRegistry(), discoveryTracker);
- }
+ super(context);
}
public void start() {
}
- public void stop() {
- discoveryTracker.close();
- discoveryTracker = null;
- introspector = null;
- nodeFactory = null;
- registry = null;
- context = null;
- }
-
public ImportRegistration importService(Bundle bundle, EndpointDescription endpointDescription) {
init();
try {
@@ -87,6 +57,9 @@ public class OSGiServiceImporter implements LifeCycleListener {
if (contribution != null) {
NodeConfiguration configuration = nodeFactory.createNodeConfiguration();
+ if (domainRegistry != null) {
+ configuration.setDomainRegistryURI(domainRegistry);
+ }
configuration.setURI(contribution.getURI());
configuration.getExtensions().add(bundle);
// FIXME: Configure the domain and node URI
@@ -115,15 +88,4 @@ public class OSGiServiceImporter implements LifeCycleListener {
node.stop();
}
- protected ExtensionPointRegistry getExtensionPointRegistry() {
- if (registry == null) {
- ServiceTracker tracker = new ServiceTracker(context, ExtensionPointRegistry.class.getName(), null);
- tracker.open();
- // tracker.waitForService(1000);
- registry = (ExtensionPointRegistry)tracker.getService();
- tracker.close();
- }
- return registry;
- }
-
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
index 698fbb2942..544297da43 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
@@ -21,7 +21,9 @@ package org.apache.tuscany.sca.osgi.remoteserviceadmin.impl;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Dictionary;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.List;
import java.util.Map;
@@ -36,6 +38,8 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
import org.osgi.util.tracker.ServiceTracker;
@@ -43,9 +47,10 @@ import org.osgi.util.tracker.ServiceTracker;
/**
* SCA Implementation of {@link RemoteServiceAdmin}
*/
-public class RemoteServiceAdminImpl implements RemoteServiceAdmin {
+public class RemoteServiceAdminImpl implements RemoteServiceAdmin, ManagedService {
private BundleContext context;
private ServiceRegistration registration;
+ private ServiceRegistration managedService;
private ServiceTracker listeners;
private OSGiServiceExporter exporter;
@@ -64,6 +69,9 @@ public class RemoteServiceAdminImpl implements RemoteServiceAdmin {
exporter.start();
importer.start();
registration = context.registerService(RemoteServiceAdmin.class.getName(), this, null);
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put(Constants.SERVICE_PID, RemoteServiceAdminImpl.class.getName());
+ managedService = context.registerService(ManagedService.class.getName(), this, props);
listeners = new ServiceTracker(this.context, RemoteServiceAdminListener.class.getName(), null);
listeners.open();
}
@@ -73,6 +81,10 @@ public class RemoteServiceAdminImpl implements RemoteServiceAdmin {
registration.unregister();
registration = null;
}
+ if (managedService != null) {
+ managedService.unregister();
+ managedService = null;
+ }
if (listeners != null) {
listeners.close();
listeners = null;
@@ -249,4 +261,12 @@ public class RemoteServiceAdminImpl implements RemoteServiceAdmin {
}
return importReg;
}
+
+ public synchronized void updated(Dictionary props) throws ConfigurationException {
+ String domainRegistry = (String)props.get("org.osgi.sca.domain.registry");
+ if (domainRegistry != null) {
+ exporter.setDomainRegistry(domainRegistry);
+ importer.setDomainRegistry(domainRegistry);
+ }
+ }
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory b/java/sca/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory
index 488529a04f..7ef0213d11 100644
--- a/java/sca/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory
+++ b/java/sca/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory
@@ -14,4 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-# org.apache.tuscany.sca.node.osgi.impl.OSGiNodeFactoryImpl \ No newline at end of file
+# org.apache.tuscany.sca.node.osgi.impl.OSGiNodeFactoryImpl;ranking=100 \ No newline at end of file
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
index 91eb7592d0..f60409e9ac 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
@@ -154,6 +154,7 @@ public class NodeFactoryImpl extends NodeFactory {
nodes.clear();
deployer.stop();
registry.stop();
+ super.destroy();
inited = false;
}
}