diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-29 00:31:15 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-29 00:31:15 +0000 |
commit | 175ff4ef119d2205e4b8371c98d582d20a19edae (patch) | |
tree | fcd4f453571f23a48857f2460971f49c17b8ad17 /java/sca/modules/endpoint-wrapper | |
parent | 0d60e1e5b8fc24fa07a8eeb89c4110018428a3e3 (diff) |
Refactor tuscany-endpoint module into tuscany-core
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@819786 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/endpoint-wrapper')
4 files changed, 44 insertions, 30 deletions
diff --git a/java/sca/modules/endpoint-wrapper/META-INF/MANIFEST.MF b/java/sca/modules/endpoint-wrapper/META-INF/MANIFEST.MF index 4d358f3884..fc99ede258 100644 --- a/java/sca/modules/endpoint-wrapper/META-INF/MANIFEST.MF +++ b/java/sca/modules/endpoint-wrapper/META-INF/MANIFEST.MF @@ -10,10 +10,8 @@ Bundle-ManifestVersion: 2 Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Default Endpoint Wrapper
Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0";resolution:=optional,
- org.apache.tuscany.sca.assembly.builder;version="2.0.0";resolution:=optional,
org.apache.tuscany.sca.core;version="2.0.0";resolution:=optional,
- org.apache.tuscany.sca.endpoint.impl;version="2.0.0",
- org.apache.tuscany.sca.endpoint.tribes;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
org.apache.tuscany.sca.management;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0"
Bundle-SymbolicName: org.apache.tuscany.sca.endpoint.wrapper
diff --git a/java/sca/modules/endpoint-wrapper/pom.xml b/java/sca/modules/endpoint-wrapper/pom.xml index 339e0a7e38..f62ea86442 100644 --- a/java/sca/modules/endpoint-wrapper/pom.xml +++ b/java/sca/modules/endpoint-wrapper/pom.xml @@ -40,50 +40,41 @@ <dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-endpoint</artifactId>
+ <artifactId>tuscany-assembly-xml</artifactId>
<version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-endpoint-tribes</artifactId>
+ <artifactId>tuscany-core-spi</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-assembly-xml</artifactId>
+ <artifactId>tuscany-monitor</artifactId>
<version>2.0-SNAPSHOT</version>
- <scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-core</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-extensibility</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-monitor</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-sca-api</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/java/sca/modules/endpoint-wrapper/src/main/java/org/apache/tuscany/sca/endpoint/wrapper/EndpointRegistryWrapper.java b/java/sca/modules/endpoint-wrapper/src/main/java/org/apache/tuscany/sca/endpoint/wrapper/EndpointRegistryWrapper.java index bfa7a4410a..25330b229c 100644 --- a/java/sca/modules/endpoint-wrapper/src/main/java/org/apache/tuscany/sca/endpoint/wrapper/EndpointRegistryWrapper.java +++ b/java/sca/modules/endpoint-wrapper/src/main/java/org/apache/tuscany/sca/endpoint/wrapper/EndpointRegistryWrapper.java @@ -19,7 +19,10 @@ package org.apache.tuscany.sca.endpoint.wrapper;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.logging.Logger;
import org.apache.tuscany.sca.assembly.Endpoint;
@@ -27,8 +30,8 @@ import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.endpoint.impl.EndpointRegistryImpl;
-import org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.management.ConfigAttributes;
import org.apache.tuscany.sca.runtime.EndpointListener;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -38,7 +41,7 @@ import org.apache.tuscany.sca.runtime.EndpointRegistry; */
public class EndpointRegistryWrapper implements EndpointRegistry, LifeCycleListener {
private final Logger logger = Logger.getLogger(EndpointRegistryWrapper.class.getName());
-
+
private ExtensionPointRegistry extensionPoints;
private EndpointRegistry delegateEndpointRegistry;
@@ -49,12 +52,34 @@ public class EndpointRegistryWrapper implements EndpointRegistry, LifeCycleListe public void start() {
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
ConfigAttributes domainConfig = utilities.getUtility(ConfigAttributes.class);
- if (domainConfig != null && "tribes".equals(domainConfig.getAttributes().get("domainScheme"))) {
- logger.info("Using Tribes based EndpointRegistry");
- delegateEndpointRegistry = new ReplicatedEndpointRegistry(extensionPoints, null);
- } else {
- logger.info("Using in-VM EndpointRegistry");
- delegateEndpointRegistry = new EndpointRegistryImpl(extensionPoints);
+ String scheme = null;
+ if (domainConfig != null) {
+ scheme = domainConfig.getAttributes().get("domainScheme");
+ }
+ if (scheme == null) {
+ scheme = "vm";
+ }
+ try {
+ Collection<ServiceDeclaration> sds =
+ ServiceDiscovery.getInstance().getServiceDeclarations(EndpointRegistry.class);
+ for (ServiceDeclaration sd : sds) {
+ if (scheme.equals(sd.getAttributes().get("scheme"))) {
+ logger.info("EndpointRegistry found: " + sd.getClassName());
+ Class<?> implClass = sd.loadClass();
+ Constructor<?> constructor = null;
+ try {
+ constructor = implClass.getConstructor(ExtensionPointRegistry.class);
+ delegateEndpointRegistry = (EndpointRegistry)constructor.newInstance(extensionPoints);
+ } catch (NoSuchMethodException e) {
+ constructor = implClass.getConstructor(ExtensionPointRegistry.class, Map.class);
+ delegateEndpointRegistry =
+ (EndpointRegistry)constructor.newInstance(extensionPoints, sd.getAttributes());
+ }
+ break;
+ }
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
}
if (delegateEndpointRegistry instanceof LifeCycleListener) {
((LifeCycleListener)delegateEndpointRegistry).start();
diff --git a/java/sca/modules/endpoint-wrapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry b/java/sca/modules/endpoint-wrapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry index bc66c8c0dc..8ba40ef648 100644 --- a/java/sca/modules/endpoint-wrapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry +++ b/java/sca/modules/endpoint-wrapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry @@ -15,4 +15,4 @@ # specific language governing permissions and limitations
# under the License.
-org.apache.tuscany.sca.endpoint.wrapper.EndpointRegistryWrapper;ranking=200
+org.apache.tuscany.sca.endpoint.wrapper.EndpointRegistryWrapper;ranking=200,scheme=wrapper
|