diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-28 13:01:58 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-28 13:01:58 +0000 |
commit | bf8aee352a1613513ac495810427f46cb9ef1cd4 (patch) | |
tree | fe368a383f2038d42cb7d06cfeafd2e943e5a8a3 /java/sca/modules/endpoint-wrapper/src/main | |
parent | 4a125b077c05d1001351ee6437b93ad42707abfe (diff) |
Add a new endpoint module that wraps the existing ones choosing which to use based on the runtime configuration. I think ideally we'd change this so the exitsing inVM registry is the default one and it looks up and remote registry itself and uses that if configured
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@808871 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/endpoint-wrapper/src/main')
2 files changed, 140 insertions, 0 deletions
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 new file mode 100644 index 0000000000..bfa7a4410a --- /dev/null +++ b/java/sca/modules/endpoint-wrapper/src/main/java/org/apache/tuscany/sca/endpoint/wrapper/EndpointRegistryWrapper.java @@ -0,0 +1,122 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.endpoint.wrapper;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+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.management.ConfigAttributes;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * A EndpointRegistry implementation that sees registrations from the same JVM
+ */
+public class EndpointRegistryWrapper implements EndpointRegistry, LifeCycleListener {
+ private final Logger logger = Logger.getLogger(EndpointRegistryWrapper.class.getName());
+
+ private ExtensionPointRegistry extensionPoints;
+ private EndpointRegistry delegateEndpointRegistry;
+
+ public EndpointRegistryWrapper(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+
+ 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);
+ }
+ if (delegateEndpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)delegateEndpointRegistry).start();
+ }
+ }
+
+ public void stop() {
+ if (delegateEndpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)delegateEndpointRegistry).stop();
+ }
+ }
+
+ public void addEndpoint(Endpoint endpoint) {
+ delegateEndpointRegistry.addEndpoint(endpoint);
+ }
+
+ public void addEndpointReference(EndpointReference endpointReference) {
+ delegateEndpointRegistry.addEndpointReference(endpointReference);
+ }
+
+ public void addListener(EndpointListener listener) {
+ delegateEndpointRegistry.addListener(listener);
+ }
+
+ public List<Endpoint> findEndpoint(EndpointReference endpointReference) {
+ return delegateEndpointRegistry.findEndpoint(endpointReference);
+ }
+
+ public List<EndpointReference> findEndpointReference(Endpoint endpoint) {
+ return delegateEndpointRegistry.findEndpointReference(endpoint);
+ }
+
+ public Endpoint getEndpoint(String uri) {
+ return delegateEndpointRegistry.getEndpoint(uri);
+ }
+
+ public List<EndpointReference> getEndpointRefereneces() {
+ return delegateEndpointRegistry.getEndpointRefereneces();
+ }
+
+ public List<Endpoint> getEndpoints() {
+ return delegateEndpointRegistry.getEndpoints();
+ }
+
+ public List<EndpointListener> getListeners() {
+ return delegateEndpointRegistry.getListeners();
+ }
+
+ public void removeEndpoint(Endpoint endpoint) {
+ delegateEndpointRegistry.removeEndpoint(endpoint);
+ }
+
+ public void removeEndpointReference(EndpointReference endpointReference) {
+ delegateEndpointRegistry.removeEndpointReference(endpointReference);
+ }
+
+ public void removeListener(EndpointListener listener) {
+ delegateEndpointRegistry.removeListener(listener);
+ }
+
+ public void updateEndpoint(String uri, Endpoint endpoint) {
+ delegateEndpointRegistry.updateEndpoint(uri, endpoint);
+ }
+
+}
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 new file mode 100644 index 0000000000..bc66c8c0dc --- /dev/null +++ b/java/sca/modules/endpoint-wrapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.endpoint.wrapper.EndpointRegistryWrapper;ranking=200
|