From 667922434cac802841b4e5d3fa5b7d3645acecb0 Mon Sep 17 00:00:00 2001 From: slaws Date: Mon, 8 Jun 2009 09:21:49 +0000 Subject: 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 --- java/sca/modules/endpoint/META-INF/MANIFEST.MF | 1 + java/sca/modules/endpoint/pom.xml | 6 ++ .../sca/endpoint/impl/EndpointRegistryImpl.java | 101 +++++++++++++++++++++ ...rg.apache.tuscany.sca.assembly.EndpointRegistry | 18 ++++ 4 files changed, 126 insertions(+) create mode 100644 java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointRegistryImpl.java create mode 100644 java/sca/modules/endpoint/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointRegistry (limited to 'java/sca/modules') 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 @@ Apache Tuscany SCA Endpoint Default Runtime + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-SNAPSHOT + org.apache.tuscany.sca 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 endpoints = new ArrayList(); + static List endpointreferences = new ArrayList(); + + 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 findEndpoint(EndpointReference2 endpointReference) { + List foundEndpoints = new ArrayList(); + + 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 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 getEndpointRefereneces() { + return endpointreferences; + } + + public List 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 -- cgit v1.2.3