From 0634059ea836e1af2a3a448e0467c3ac6b20310e Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 2 Jun 2009 05:47:41 +0000 Subject: 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 --- .../tuscany/sca/assembly/EndpointRegistry.java | 36 +++++++++ .../sca/assembly/impl/EndpointRegistryImpl.java | 89 ++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointRegistry.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointRegistryImpl.java (limited to 'java/sca/modules') 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 findEndpoint(EndpointReference2 endpointReference); + List findEndpointReference(Endpoint2 endpoint); + List getEndpoints(); + List 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 endpoints = new ArrayList(); + List endpointreferences = new ArrayList(); + + private EndpointRegistryImpl() { + } + + public void addEndpoint(Endpoint2 endpoint) { + endpoints.add(endpoint); + } + + public void addEndpointReference(EndpointReference2 endpointReference) { + endpointreferences.add(endpointReference); + } + + public List findEndpoint(EndpointReference2 endpointReference) { + List foundEndpoints = new ArrayList(); + if (endpointReference.getReference() != null) { + List 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 findEndpointReference(Endpoint2 endpoint) { + return null; + } + + public void removeEndpoint(Endpoint2 endpoint) { + endpoints.remove(endpoint); + } + + public void removeEndpointReference(EndpointReference2 endpointReference) { + endpointreferences.remove(endpointReference); + } + + public List getEndpointRefereneces() { + return endpointreferences; + } + + public List getEndpoints() { + return endpoints; + } + +} -- cgit v1.2.3