diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-27 20:09:55 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-27 20:09:55 +0000 |
commit | f7955300b8af64fdaea6404852fd83997c6b7b9a (patch) | |
tree | 10edc1fa216b297ed6837015940e0b38acf12874 | |
parent | dd4b0b581d036c4f7f647f3b2a93af907010590a (diff) |
Register ExtensionPointRegistry as an OSGi service and BundleContext as a utility
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@759327 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
2 files changed, 26 insertions, 8 deletions
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java index 2e008fa1cc..f0ee07acf1 100644 --- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java +++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java @@ -28,7 +28,9 @@ import java.io.StringReader; import java.net.URI; import java.net.URL; import java.util.ArrayList; +import java.util.Dictionary; import java.util.HashSet; +import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Set; @@ -96,6 +98,8 @@ import org.oasisopen.sca.CallableReference; import org.oasisopen.sca.ServiceReference; import org.oasisopen.sca.ServiceRuntimeException; import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; /** * Represents an SCA runtime node. @@ -109,6 +113,8 @@ public class NodeFactoryImpl { private static final Logger logger = Logger.getLogger(NodeFactoryImpl.class.getName()); private boolean inited; + private BundleContext bundleContext; + private ServiceRegistration registration; private ExtensionPointRegistry extensionPoints; private UtilityExtensionPoint utilities; @@ -135,7 +141,8 @@ public class NodeFactoryImpl { /** * Constructs a new Node controller */ - public NodeFactoryImpl() { + public NodeFactoryImpl(BundleContext bundleContext) { + this.bundleContext = bundleContext; } private ConfiguredNodeImplementation getNodeConfiguration(Bundle bundle) { @@ -223,6 +230,15 @@ public class NodeFactoryImpl { // Create extension point registry extensionPoints = new DefaultExtensionPointRegistry(); + utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + + // Add the OSGi BundleContext as a system utility + utilities.addUtility(bundleContext); + + // Register the ExtensionPointRegistry as an OSGi service + Dictionary<Object, Object> props = new Hashtable<Object, Object>(); + registration = bundleContext.registerService(ExtensionPointRegistry.class.getName(), extensionPoints, props); + // Enable schema validation only of the logger level is FINE or higher ValidationSchemaExtensionPoint schemas = extensionPoints.getExtensionPoint(ValidationSchemaExtensionPoint.class); @@ -236,9 +252,7 @@ public class NodeFactoryImpl { modelFactories.addFactory(assemblyFactory); // Create a monitor - utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - monitor = monitorFactory.createMonitor(); // Initialize the Tuscany module activators @@ -475,6 +489,10 @@ public class NodeFactoryImpl { } public void destroy() { + if (registration != null) { + registration.unregister(); + } + // Stop the runtime modules for (ModuleActivator moduleActivator : moduleActivators) { moduleActivator.stop(extensionPoints); @@ -490,7 +508,7 @@ public class NodeFactoryImpl { return node; } - public Node creatNode(Bundle bundle, String compositeContent) { + public Node createNode(Bundle bundle, String compositeContent) { Node node = new NodeImpl(bundle, compositeContent); nodes.put(bundle, node); return node; diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java index 73c98af714..47368a9f18 100644 --- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java +++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.node.osgi.impl; @@ -42,7 +42,7 @@ public class NodeManager implements SynchronousBundleListener, ServiceListener { public NodeManager(BundleContext bundleContext) { super(); this.bundleContext = bundleContext; - this.factory = new NodeFactoryImpl(); + this.factory = new NodeFactoryImpl(this.bundleContext); } public void start() { |