summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-06-08 09:21:49 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-06-08 09:21:49 +0000
commit667922434cac802841b4e5d3fa5b7d3645acecb0 (patch)
treeaaf9e702463fc2f4079571e9507a91642207a3df /java/sca/modules
parent1495a66e88093d05af62ac85252b37ed2aee3a68 (diff)
TUSCANY-3081 - Add a pluggable local endpoint registry implementation. This replaces the implementation that is in assembly but I've left that there for the time being as I don't know if anyone is using it.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@782568 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/endpoint/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/endpoint/pom.xml6
-rw-r--r--java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointRegistryImpl.java101
-rw-r--r--java/sca/modules/endpoint/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointRegistry18
4 files changed, 126 insertions, 0 deletions
diff --git a/java/sca/modules/endpoint/META-INF/MANIFEST.MF b/java/sca/modules/endpoint/META-INF/MANIFEST.MF
index 2fbb0b1a69..834c83f297 100644
--- a/java/sca/modules/endpoint/META-INF/MANIFEST.MF
+++ b/java/sca/modules/endpoint/META-INF/MANIFEST.MF
@@ -21,6 +21,7 @@ Import-Package: javax.xml.stream;resolution:=optional,
org.apache.tuscany.sca.interfacedef;version="2.0.0";resolution:=optional,
org.apache.tuscany.sca.monitor;version="2.0.0";resolution:=optional,
org.apache.tuscany.sca.policy;version="2.0.0";resolution:=optional,
+ org.oasisopen.sca;version="2.0.0",
org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional
Bundle-SymbolicName: org.apache.tuscany.sca.endpoint
Bundle-DocURL: http://www.apache.org/
diff --git a/java/sca/modules/endpoint/pom.xml b/java/sca/modules/endpoint/pom.xml
index ac2c8a61be..1d5218c361 100644
--- a/java/sca/modules/endpoint/pom.xml
+++ b/java/sca/modules/endpoint/pom.xml
@@ -31,6 +31,12 @@
<name>Apache Tuscany SCA Endpoint Default Runtime</name>
<dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
diff --git a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointRegistryImpl.java b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointRegistryImpl.java
new file mode 100644
index 0000000000..b7bf52183d
--- /dev/null
+++ b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointRegistryImpl.java
@@ -0,0 +1,101 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+import org.apache.tuscany.sca.assembly.EndpointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+public class EndpointRegistryImpl implements EndpointRegistry {
+
+ //public static final EndpointRegistryImpl INSTANCE = new EndpointRegistryImpl();
+ //public static EndpointRegistryImpl getInstance() {
+ // return INSTANCE;
+ //}
+
+ static List<Endpoint2> endpoints = new ArrayList<Endpoint2>();
+ static List<EndpointReference2> endpointreferences = new ArrayList<EndpointReference2>();
+
+ public EndpointRegistryImpl(ExtensionPointRegistry extensionPoints) {
+ }
+
+ public void addEndpoint(Endpoint2 endpoint) {
+ endpoints.add(endpoint);
+ System.out.println("EndpointRegistry: Add endpoint - " + endpoint.toString());
+ }
+
+ public void addEndpointReference(EndpointReference2 endpointReference) {
+ endpointreferences.add(endpointReference);
+ System.out.println("EndpointRegistry: Add endpoint reference - " + endpointReference.toString());
+ }
+
+ public List<Endpoint2> findEndpoint(EndpointReference2 endpointReference) {
+ List<Endpoint2> foundEndpoints = new ArrayList<Endpoint2>();
+
+ System.out.println("EndpointRegistry: Find endpoint for reference - " + endpointReference.toString());
+
+ if (endpointReference.getReference() != null) {
+ Endpoint2 targetEndpoint = endpointReference.getTargetEndpoint();
+ for (Endpoint2 endpoint : endpoints) {
+ // TODO: implement more complete matching
+ if (endpoint.getComponentName().equals(targetEndpoint.getComponentName())) {
+ if ( (targetEndpoint.getServiceName() != null) &&
+ (endpoint.getServiceName().equals(targetEndpoint.getServiceName())) ){
+ foundEndpoints.add(endpoint);
+ System.out.println("EndpointRegistry: Found endpoint with matching service - " + endpoint.toString());
+ } else if (targetEndpoint.getServiceName() == null) {
+ foundEndpoints.add(endpoint);
+ System.out.println("EndpointRegistry: Found endpoint with matching component - " + endpoint.toString());
+ }
+ // else the service name doesn't match
+ }
+ }
+ }
+ return foundEndpoints;
+ }
+
+ public List<EndpointReference2> findEndpointReference(Endpoint2 endpoint) {
+ return null;
+ }
+
+ public void removeEndpoint(Endpoint2 endpoint) {
+ endpoints.remove(endpoint);
+ System.out.println("EndpointRegistry: Remove endpoint - " + endpoint.toString());
+ }
+
+ public void removeEndpointReference(EndpointReference2 endpointReference) {
+ endpointreferences.remove(endpointReference);
+ System.out.println("EndpointRegistry: Remove endpoint reference - " + endpointReference.toString());
+ }
+
+ public List<EndpointReference2> getEndpointRefereneces() {
+ return endpointreferences;
+ }
+
+ public List<Endpoint2> getEndpoints() {
+ return endpoints;
+ }
+
+}
diff --git a/java/sca/modules/endpoint/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointRegistry b/java/sca/modules/endpoint/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointRegistry
new file mode 100644
index 0000000000..26ee8ce362
--- /dev/null
+++ b/java/sca/modules/endpoint/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.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.impl.EndpointRegistryImpl \ No newline at end of file