summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-06-02 05:47:41 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-06-02 05:47:41 +0000
commit0634059ea836e1af2a3a448e0467c3ac6b20310e (patch)
treecf20ab62518e997c592d3c78455865cddbe251fa
parentf02d956f041f65a2a5a8ec1e5c5ab3c1a4028855 (diff)
Commit initial strawman prototype of the EndpointRegistry being discussed on the ML
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@780938 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointRegistry.java36
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointRegistryImpl.java89
2 files changed, 125 insertions, 0 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointRegistry.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointRegistry.java
new file mode 100644
index 0000000000..ef63ac781a
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointRegistry.java
@@ -0,0 +1,36 @@
+/*
+ * 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.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
+
+public interface EndpointRegistry {
+ void addEndpoint(Endpoint2 endpoint);
+ void removeEndpoint(Endpoint2 endpoint);
+ void addEndpointReference(EndpointReference2 endpointReference);
+ void removeEndpointReference(EndpointReference2 endpointReference);
+ List<Endpoint2> findEndpoint(EndpointReference2 endpointReference);
+ List<EndpointReference2> findEndpointReference(Endpoint2 endpoint);
+ List<Endpoint2> getEndpoints();
+ List<EndpointReference2> getEndpointRefereneces();
+}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointRegistryImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointRegistryImpl.java
new file mode 100644
index 0000000000..f5cc99d167
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointRegistryImpl.java
@@ -0,0 +1,89 @@
+/*
+ * 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.assembly.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;
+
+public class EndpointRegistryImpl implements EndpointRegistry {
+
+ public static final EndpointRegistryImpl INSTANCE = new EndpointRegistryImpl();
+ public static EndpointRegistryImpl getInstance() {
+ return INSTANCE;
+ }
+
+ List<Endpoint2> endpoints = new ArrayList<Endpoint2>();
+ List<EndpointReference2> endpointreferences = new ArrayList<EndpointReference2>();
+
+ private EndpointRegistryImpl() {
+ }
+
+ public void addEndpoint(Endpoint2 endpoint) {
+ endpoints.add(endpoint);
+ }
+
+ public void addEndpointReference(EndpointReference2 endpointReference) {
+ endpointreferences.add(endpointReference);
+ }
+
+ public List<Endpoint2> findEndpoint(EndpointReference2 endpointReference) {
+ List<Endpoint2> foundEndpoints = new ArrayList<Endpoint2>();
+ if (endpointReference.getReference() != null) {
+ List<ComponentService> targets = endpointReference.getReference().getTargets();
+ if (targets != null) {
+ for (ComponentService targetService : targets) {
+ for (Endpoint2 endpoint : endpoints) {
+ // TODO: implement more complete matching
+ if (endpoint.getComponent().getName().equals(targetService.getName())) {
+ foundEndpoints.add(endpoint);
+ }
+ }
+ }
+ }
+ }
+ return foundEndpoints;
+ }
+
+ public List<EndpointReference2> findEndpointReference(Endpoint2 endpoint) {
+ return null;
+ }
+
+ public void removeEndpoint(Endpoint2 endpoint) {
+ endpoints.remove(endpoint);
+ }
+
+ public void removeEndpointReference(EndpointReference2 endpointReference) {
+ endpointreferences.remove(endpointReference);
+ }
+
+ public List<EndpointReference2> getEndpointRefereneces() {
+ return endpointreferences;
+ }
+
+ public List<Endpoint2> getEndpoints() {
+ return endpoints;
+ }
+
+}