You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/10/09 21:59:45 UTC
svn commit: r823672 [1/2] - in /tuscany/java/sca/modules: ./
assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/
core-spi/src/main/java/org/apache/tuscany/sca/context/
core-spi/src/main/java/org/apache/tuscany/sca/runtime/ core/src/main/jav...
Author: rfeng
Date: Fri Oct 9 19:59:43 2009
New Revision: 823672
URL: http://svn.apache.org/viewvc?rev=823672&view=rev
Log:
Refactor the runtime build logic into EndpointReferenceBinder
Refactor the endpoint-wrapper into domainRegistryFactory that delegates to endpoint registry implementations by the scheme
Improve/workaround the monitor so that it can be shared by multiple nodes (We need a better design for this)
Added:
tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java (with props)
tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java (with props)
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java (with props)
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java (with props)
tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder
tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/
tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java (with props)
tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java (with props)
Removed:
tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointReferenceBuilderImpl.java
tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.EndpointReferenceBuilder
Modified:
tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java
tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
tuscany/java/sca/modules/domain-node/META-INF/MANIFEST.MF
tuscany/java/sca/modules/domain-node/pom.xml
tuscany/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
tuscany/java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
tuscany/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF
tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
tuscany/java/sca/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.java
tuscany/java/sca/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
tuscany/java/sca/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java
tuscany/java/sca/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
tuscany/java/sca/modules/pom.xml
Modified: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java (original)
+++ tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java Fri Oct 9 19:59:43 2009
@@ -21,6 +21,7 @@
import org.apache.tuscany.sca.assembly.Composite;
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.invocation.Message;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -66,6 +67,12 @@
* @param runtimeComponent
*/
public abstract void bindComponent(RuntimeComponent runtimeComponent);
+
+ /**
+ *
+ * @param endpointReference
+ */
+ public abstract void bindEndpointReference(EndpointReference endpointReference);
/**
* Get the ExtensionPointRegistry for this node
Modified: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java (original)
+++ tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java Fri Oct 9 19:59:43 2009
@@ -31,30 +31,34 @@
public interface CompositeActivator {
/**
* Activate a composite
+ * @param compositeContext The context of the Node
* @param composite
*/
- void activate(Composite composite) throws ActivationException;
+ void activate(CompositeContext compositeContext, Composite composite) throws ActivationException;
/**
* Activate a component reference
+ * @param compositeContext The context of the Node
* @param component
* @param ref
*/
- void start(RuntimeComponent component, RuntimeComponentReference ref);
+ void start(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference ref);
/**
* Activate a component reference
+ * @param compositeContext The context of the Node
* @param component
* @param ref
*/
- void activate(RuntimeComponent component, RuntimeComponentReference ref);
+ void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference ref);
/**
* Activate a component reference
+ * @param compositeContext The context of the Node
* @param component
* @param ref
*/
- void activate(RuntimeComponent component, RuntimeComponentService service);
+ void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentService service);
/**
* De-activate a component reference
Added: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java?rev=823672&view=auto
==============================================================================
--- tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java (added)
+++ tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java Fri Oct 9 19:59:43 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.runtime;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ *
+ */
+public interface DomainRegistryFactory {
+ /**
+ * Get the EndpointRegistry for the given registry URI and domain URI
+ * @param endpointRegistryURI A URI can be used to connect to the registry, such as vm://localhost
+ * or multicast://200.0.100.200:50000/...
+ * @param domainURI The domain URI
+ * @return
+ */
+ EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI);
+
+ /**
+ * Return all active endpoint registries
+ * @return
+ */
+ Collection<EndpointRegistry> getEndpointRegistries();
+ void addListener(EndpointListener listener);
+ void removeListener(EndpointListener listener);
+ List<EndpointListener> getListeners();
+}
Propchange: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java?rev=823672&view=auto
==============================================================================
--- tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java (added)
+++ tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java Fri Oct 9 19:59:43 2009
@@ -0,0 +1,42 @@
+/*
+ * 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.runtime;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+
+/**
+ * A utility responsible for resolving the endpoint reference against a matching endpoint published
+ * to the EndpointRegistry
+ */
+public interface EndpointReferenceBinder {
+ /**
+ * @param endpointRegistry
+ * @param endpointReference
+ * @return
+ */
+ boolean bind(EndpointRegistry endpointRegistry, EndpointReference endpointReference);
+ /**
+ *
+ * @param endpointRegistry
+ * @param endpointReference
+ * @return
+ */
+ boolean isOutOfDate(EndpointRegistry endpointRegistry, EndpointReference endpointReference);
+}
Propchange: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java Fri Oct 9 19:59:43 2009
@@ -100,13 +100,13 @@
// Composite activation/deactivation
- public void activate(Composite composite) throws ActivationException {
+ public void activate(CompositeContext compositeContext, Composite composite) throws ActivationException {
try {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Activating composite: " + composite.getName());
}
for (Component component : composite.getComponents()) {
- activateComponent(component);
+ activateComponent(compositeContext, component);
}
} catch (Exception e) {
throw new ActivationException(e);
@@ -128,7 +128,7 @@
// Component activation/deactivation
- public void activateComponent(Component component)
+ public void activateComponent(CompositeContext compositeContext, Component component)
throws ActivationException {
try {
if (logger.isLoggable(Level.FINE)) {
@@ -137,7 +137,7 @@
Implementation implementation = component.getImplementation();
if (implementation instanceof Composite) {
- activate((Composite) implementation);
+ activate(compositeContext, (Composite) implementation);
} else if (implementation != null) {
addImplementationProvider((RuntimeComponent) component,
implementation);
@@ -145,13 +145,13 @@
}
for (ComponentService service : component.getServices()) {
- activate((RuntimeComponent) component,
- (RuntimeComponentService) service);
+ activate(compositeContext,
+ (RuntimeComponent) component, (RuntimeComponentService) service);
}
for (ComponentReference reference : component.getReferences()) {
- activate((RuntimeComponent) component,
- (RuntimeComponentReference) reference);
+ activate(compositeContext,
+ (RuntimeComponent) component, (RuntimeComponentReference) reference);
}
} catch (Exception e) {
throw new ActivationException(e);
@@ -237,7 +237,7 @@
// Service activation/deactivation
- public void activate(RuntimeComponent component, RuntimeComponentService service) {
+ public void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentService service) {
if (service.getService() == null) {
if (logger.isLoggable(Level.WARNING)) {
logger.warning("Skipping component service not defined in the component type: " + component.getURI()
@@ -261,7 +261,7 @@
for (Endpoint endpoint : service.getEndpoints()) {
addServiceBindingProvider(endpoint, component, service, endpoint.getBinding());
}
- addServiceWires(component, service);
+ addServiceWires(compositeContext, component, service);
}
public void deactivate(RuntimeComponent component, RuntimeComponentService service) {
@@ -313,7 +313,7 @@
}
}
- private void addServiceWires(Component serviceComponent, ComponentService service) {
+ private void addServiceWires(CompositeContext compositeContext, Component serviceComponent, ComponentService service) {
if (!(service instanceof RuntimeComponentService)) {
return;
}
@@ -341,7 +341,7 @@
endpointReference.setInterfaceContract(getServiceBindingInterfaceContract(service, endpoint.getBinding()));
// create the wire
- RuntimeWire wire = new RuntimeWireImpl(extensionPoints,
+ RuntimeWire wire = new RuntimeWireImpl(compositeContext,
false,
endpointReference,
endpoint,
@@ -381,7 +381,7 @@
// Reference activation/deactivation
- public void activate(RuntimeComponent component, RuntimeComponentReference reference) {
+ public void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference reference) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Activating component reference: " + component.getURI() + "#" + reference.getName());
}
@@ -641,7 +641,7 @@
// Used by component context start
// TODO - EPR I don't know why reference wires don't get added until component start
- public void start(RuntimeComponent component, RuntimeComponentReference componentReference) {
+ public void start(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference componentReference) {
synchronized (componentReference) {
if (!(componentReference instanceof RuntimeComponentReference)) {
@@ -696,7 +696,7 @@
// current composite). Endpoint reference resolution takes place when the wire
// is first used (when the chains are created)
for (EndpointReference endpointReference : componentReference.getEndpointReferences()){
- addReferenceWire(component, componentReference, endpointReference);
+ addReferenceWire(compositeContext, component, componentReference, endpointReference);
component.getComponentContext().getCompositeContext().getEndpointRegistry().addEndpointReference(endpointReference);
}
@@ -723,7 +723,7 @@
}
}
- private void addReferenceWire(Component component, ComponentReference reference, EndpointReference endpointReference) {
+ private void addReferenceWire(CompositeContext compositeContext, Component component, ComponentReference reference, EndpointReference endpointReference) {
RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
// Use the interface contract of the reference on the component type and if there
@@ -789,7 +789,7 @@
// create the wire
// null endpoint passed in here as the endpoint reference may
// not be resolved yet
- RuntimeWire wire = new RuntimeWireImpl(extensionPoints,
+ RuntimeWire wire = new RuntimeWireImpl(compositeContext,
true,
endpointReference,
null,
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java Fri Oct 9 19:59:43 2009
@@ -20,9 +20,8 @@
package org.apache.tuscany.sca.core.assembly.impl;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import org.apache.tuscany.sca.assembly.Endpoint;
@@ -38,25 +37,23 @@
public class EndpointRegistryImpl implements EndpointRegistry, LifeCycleListener {
private final Logger logger = Logger.getLogger(EndpointRegistryImpl.class.getName());
- private MappedList<EndpointRegistry, Endpoint> endpoints = new MappedList<EndpointRegistry, Endpoint>();
- private MappedList<EndpointRegistry, EndpointReference> endpointreferences =
- new MappedList<EndpointRegistry, EndpointReference>();
+ private List<Endpoint> endpoints = new ArrayList<Endpoint>();
+ private List<EndpointReference> endpointreferences = new ArrayList<EndpointReference>();
+ private List<EndpointListener> listeners = new ArrayList<EndpointListener>();
- private List<EndpointListener> listeners = new CopyOnWriteArrayList<EndpointListener>();
-
- public EndpointRegistryImpl(ExtensionPointRegistry extensionPoints) {
+ public EndpointRegistryImpl(ExtensionPointRegistry extensionPoints, String endpointRegistryURI, String domainURI) {
}
- public void addEndpoint(Endpoint endpoint) {
- endpoints.putValue(this, endpoint);
+ public synchronized void addEndpoint(Endpoint endpoint) {
+ endpoints.add(endpoint);
for (EndpointListener listener : listeners) {
listener.endpointAdded(endpoint);
}
logger.info("Add endpoint - " + endpoint.toString());
}
- public void addEndpointReference(EndpointReference endpointReference) {
- endpointreferences.putValue(this, endpointReference);
+ public synchronized void addEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.add(endpointReference);
logger.fine("Add endpoint reference - " + endpointReference.toString());
}
@@ -104,153 +101,108 @@
return true;
}
- public List<Endpoint> findEndpoint(EndpointReference endpointReference) {
+ public synchronized List<Endpoint> findEndpoint(EndpointReference endpointReference) {
List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
logger.fine("Find endpoint for reference - " + endpointReference.toString());
if (endpointReference.getReference() != null) {
Endpoint targetEndpoint = endpointReference.getTargetEndpoint();
- for (List<Endpoint> collection : endpoints.values()) {
- for (Endpoint endpoint : collection) {
- // TODO: implement more complete matching
- if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
- foundEndpoints.add(endpoint);
- logger.fine("Found endpoint with matching service - " + endpoint);
- }
- // else the service name doesn't match
+ for (Endpoint endpoint : endpoints) {
+ // TODO: implement more complete matching
+ if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
}
+ // else the service name doesn't match
}
}
return foundEndpoints;
}
- public List<EndpointReference> findEndpointReference(Endpoint endpoint) {
+ public synchronized List<EndpointReference> findEndpointReference(Endpoint endpoint) {
return null;
}
- public void removeEndpoint(Endpoint endpoint) {
- endpoints.removeValue(this, endpoint);
+ public synchronized void removeEndpoint(Endpoint endpoint) {
+ endpoints.remove(endpoint);
+ endpointRemoved(endpoint);
+ }
+
+ private void endpointRemoved(Endpoint endpoint) {
for (EndpointListener listener : listeners) {
listener.endpointRemoved(endpoint);
}
logger.info("Remove endpoint - " + endpoint.toString());
}
- public void removeEndpointReference(EndpointReference endpointReference) {
- endpointreferences.removeValue(this, endpointReference);
+ public synchronized void removeEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.remove(endpointReference);
logger.fine("Remove endpoint reference - " + endpointReference.toString());
}
- public List<EndpointReference> getEndpointRefereneces() {
- return endpointreferences.getAllValues();
+ public synchronized List<EndpointReference> getEndpointRefereneces() {
+ return endpointreferences;
}
- public List<Endpoint> getEndpoints() {
- return endpoints.getAllValues();
+ public synchronized List<Endpoint> getEndpoints() {
+ return endpoints;
}
- public void addListener(EndpointListener listener) {
+ public synchronized void addListener(EndpointListener listener) {
listeners.add(listener);
}
- public List<EndpointListener> getListeners() {
+ public synchronized List<EndpointListener> getListeners() {
return listeners;
}
- public void removeListener(EndpointListener listener) {
+ public synchronized void removeListener(EndpointListener listener) {
listeners.remove(listener);
}
- public Endpoint getEndpoint(String uri) {
- for (List<Endpoint> collection : endpoints.values()) {
- for (Endpoint ep : collection) {
- String epURI =
- ep.getComponent().getURI() + "#" + ep.getService().getName() + "/" + ep.getBinding().getName();
+ public synchronized Endpoint getEndpoint(String uri) {
+ for (Endpoint ep : endpoints) {
+ String epURI =
+ ep.getComponent().getURI() + "#" + ep.getService().getName() + "/" + ep.getBinding().getName();
+ if (epURI.equals(uri)) {
+ return ep;
+ }
+ if (ep.getBinding().getName() == null || ep.getBinding().getName().equals(ep.getService().getName())) {
+ epURI = ep.getComponent().getURI() + "#" + ep.getService().getName();
if (epURI.equals(uri)) {
return ep;
}
- if (ep.getBinding().getName() == null || ep.getBinding().getName().equals(ep.getService().getName())) {
- epURI = ep.getComponent().getURI() + "#" + ep.getService().getName();
- if (epURI.equals(uri)) {
- return ep;
- }
- }
}
}
return null;
}
- public void updateEndpoint(String uri, Endpoint endpoint) {
+ public synchronized void updateEndpoint(String uri, Endpoint endpoint) {
Endpoint oldEndpoint = getEndpoint(uri);
if (oldEndpoint == null) {
throw new IllegalArgumentException("Endpoint is not found: " + uri);
}
- endpoints.removeValue(this, oldEndpoint);
- endpoints.putValue(this, endpoint);
+ endpoints.remove(oldEndpoint);
+ endpoints.add(endpoint);
for (EndpointListener listener : listeners) {
listener.endpointUpdated(oldEndpoint, endpoint);
}
}
- public void start() {
+ public synchronized void start() {
}
- public void stop() {
- List<Endpoint> localEndpoints = endpoints.remove(this);
- if (localEndpoints != null) {
- for (Endpoint endpoint : localEndpoints) {
- removeEndpoint(endpoint);
- }
- }
- List<EndpointReference> localEndpointReferences = endpointreferences.remove(this);
- if (localEndpointReferences != null) {
- for (EndpointReference endpointReference : localEndpointReferences) {
- removeEndpointReference(endpointReference);
- }
+ public synchronized void stop() {
+ for (Iterator<Endpoint> i = endpoints.iterator(); i.hasNext();) {
+ Endpoint ep = i.next();
+ i.remove();
+ endpointRemoved(ep);
}
+ endpointreferences.clear();
listeners.clear();
}
- private static class MappedList<K, V> extends ConcurrentHashMap<K, List<V>> {
- private static final long serialVersionUID = -8926174610229029369L;
-
- public boolean putValue(K key, V value) {
- List<V> collection = get(key);
- if (collection == null) {
- collection = new ArrayList<V>();
- put(key, collection);
- }
- return collection.add(value);
- }
-
- public boolean putValue(K key, List<? extends V> value) {
- List<V> collection = get(key);
- if (collection == null) {
- collection = new ArrayList<V>();
- put(key, collection);
- }
- return collection.addAll(value);
- }
-
- public boolean removeValue(K key, V value) {
- List<V> collection = get(key);
- if (collection == null) {
- return false;
- }
- return collection.remove(value);
- }
-
- public List<V> getAllValues() {
- List<V> values = new ArrayList<V>();
- for (List<V> collection : values()) {
- values.addAll(collection);
- }
- return values;
- }
-
- }
-
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java Fri Oct 9 19:59:43 2009
@@ -35,7 +35,7 @@
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.EndpointReferenceBuilder;
+import org.apache.tuscany.sca.context.CompositeContext;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -52,7 +52,6 @@
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.invocation.Phase;
-import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.ImplementationProvider;
import org.apache.tuscany.sca.provider.PolicyProvider;
@@ -63,6 +62,7 @@
import org.apache.tuscany.sca.provider.ReferenceBindingProviderRRB;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -78,7 +78,8 @@
*/
public class RuntimeWireImpl implements RuntimeWire {
- ExtensionPointRegistry extensionPoints;
+ private CompositeContext compositeContext;
+ private ExtensionPointRegistry extensionPoints;
private Boolean isReferenceWire = false;
private EndpointReference endpointReference;
@@ -100,7 +101,7 @@
private List<InvocationChain> chains;
private InvocationChain bindingInvocationChain;
- private EndpointReferenceBuilder endpointReferenceBuilder;
+ private EndpointReferenceBinder eprBinder;
private final ProviderFactoryExtensionPoint providerFactories;
/**
@@ -112,7 +113,7 @@
* @param messageFactory
* @param conversationManager
*/
- public RuntimeWireImpl(ExtensionPointRegistry extensionPoints,
+ public RuntimeWireImpl(CompositeContext compositeContext,
boolean isReferenceWire,
EndpointReference endpointReference,
Endpoint endpoint,
@@ -121,7 +122,8 @@
RuntimeWireProcessor wireProcessor,
MessageFactory messageFactory) {
super();
- this.extensionPoints = extensionPoints;
+ this.compositeContext = compositeContext;
+ this.extensionPoints = compositeContext.getExtensionPointRegistry();
this.isReferenceWire = isReferenceWire;
this.endpointReference = endpointReference;
this.endpoint = endpoint;
@@ -132,16 +134,17 @@
this.invoker = new RuntimeWireInvoker(this.messageFactory, this);
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- this.endpointReferenceBuilder = utilities.getUtility(EndpointReferenceBuilder.class);
+ this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
}
- public RuntimeWireImpl(ExtensionPointRegistry extensionPoints,
+ public RuntimeWireImpl(CompositeContext compositeContext,
boolean isReferenceWire,
EndpointReference endpointReference,
Endpoint endpoint) {
super();
- this.extensionPoints = extensionPoints;
+ this.compositeContext = compositeContext;
+ this.extensionPoints = compositeContext.getExtensionPointRegistry();
this.isReferenceWire = isReferenceWire;
this.endpointReference = endpointReference;
this.endpoint = endpoint;
@@ -154,9 +157,10 @@
this.messageFactory = factories.getFactory(MessageFactory.class);
this.invoker = new RuntimeWireInvoker(this.messageFactory, this);
- this.endpointReferenceBuilder = utilities.getUtility(EndpointReferenceBuilder.class);
+ this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
}
+
public synchronized List<InvocationChain> getInvocationChains() {
if (chains == null) {
initInvocationChains();
@@ -331,10 +335,10 @@
* is first used
*/
private void resolveEndpointReference(){
- Problem problem = endpointReferenceBuilder.runtimeBuild(endpointReference);
+ boolean ok = eprBinder.bind(compositeContext.getEndpointRegistry(), endpointReference);
- if (problem != null){
- throw new SCARuntimeException(problem.toString());
+ if (!ok) {
+ throw new SCARuntimeException("Unable to bind " + endpointReference);
}
// set the endpoint based on the resolved endpoint
@@ -774,6 +778,6 @@
}
public boolean isOutOfDate() {
- return endpointReferenceBuilder.isOutOfDate(getEndpointReference());
+ return eprBinder.isOutOfDate(compositeContext.getEndpointRegistry(), getEndpointReference());
}
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java Fri Oct 9 19:59:43 2009
@@ -34,7 +34,6 @@
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.EndpointReferenceBuilder;
import org.apache.tuscany.sca.context.CompositeContext;
import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
import org.apache.tuscany.sca.context.PropertyValueFactory;
@@ -52,8 +51,8 @@
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
-import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -78,7 +77,7 @@
private final AssemblyFactory assemblyFactory;
private final JavaInterfaceFactory javaInterfaceFactory;
private final PropertyValueFactory propertyFactory;
- private final EndpointReferenceBuilder endpointReferenceBuilder;
+ private final EndpointReferenceBinder eprBinder;
private final Monitor monitor;
public ComponentContextImpl(ExtensionPointRegistry registry, CompositeContext compositeContext, RuntimeComponent component) {
@@ -97,7 +96,7 @@
this.proxyFactory = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
this.propertyFactory = factories.getFactory(PropertyValueFactory.class);
- this.endpointReferenceBuilder = utilities.getUtility(EndpointReferenceBuilder.class);
+ this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
this.monitor = monitorFactory.createMonitor();
@@ -394,10 +393,10 @@
componentReference.getEndpointReferences().add(endpointReference);
// do binding matching
- Problem problem = endpointReferenceBuilder.runtimeBuild(endpointReference);
+ boolean ok = eprBinder.bind(compositeContext.getEndpointRegistry(), endpointReference);
- if (problem != null){
- throw new SCARuntimeException(problem.toString());
+ if (!ok) {
+ throw new SCARuntimeException("Unable to bind " + endpointReference);
}
return componentReference;
@@ -441,7 +440,7 @@
* @see org.apache.tuscany.sca.runtime.RuntimeComponentContext#start(org.apache.tuscany.sca.runtime.RuntimeComponentReference)
*/
public void start(RuntimeComponentReference reference) {
- compositeActivator.start(component, reference);
+ compositeActivator.start(compositeContext, component, reference);
}
Added: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java?rev=823672&view=auto
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java (added)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java Fri Oct 9 19:59:43 2009
@@ -0,0 +1,157 @@
+/*
+ * 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.core.runtime;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the
+ * given domain
+ */
+public class DefaultDomainRegistryFactory implements DomainRegistryFactory, LifeCycleListener {
+ private ExtensionPointRegistry extensionRegistry;
+ private Map<String, ServiceDeclaration> declarations = new HashMap<String, ServiceDeclaration>();
+ private Map<String, EndpointRegistry> endpointRegistries = new ConcurrentHashMap<String, EndpointRegistry>();
+ private List<EndpointListener> listeners = new ArrayList<EndpointListener>();
+
+ /**
+ * @param extensionRegistry
+ */
+ public DefaultDomainRegistryFactory(ExtensionPointRegistry extensionRegistry) {
+ super();
+ this.extensionRegistry = extensionRegistry;
+ }
+
+ public void start() {
+ Collection<ServiceDeclaration> sds = null;
+ try {
+ sds = ServiceDiscovery.getInstance().getServiceDeclarations(EndpointRegistry.class);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ for (ServiceDeclaration sd : sds) {
+ String scheme = sd.getAttributes().get("scheme");
+ if (scheme != null) {
+ scheme = scheme.toLowerCase();
+ }
+ declarations.put(scheme, sd);
+ }
+ }
+
+ public synchronized EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI) {
+ if (endpointRegistryURI == null) {
+ endpointRegistryURI = "vm://localhost";
+ }
+
+ String key = endpointRegistryURI + "," + domainURI;
+
+ EndpointRegistry endpointRegistry = endpointRegistries.get(key);
+ if (endpointRegistry != null) {
+ return endpointRegistry;
+ }
+
+ URI uri = URI.create(endpointRegistryURI);
+ String scheme = uri.getScheme();
+ if (scheme != null) {
+ scheme = scheme.toLowerCase();
+ }
+
+ ServiceDeclaration sd = declarations.get(scheme);
+
+ try {
+ Class<?> implClass = sd.loadClass();
+ Constructor<?> constructor = null;
+ try {
+ constructor = implClass.getConstructor(ExtensionPointRegistry.class, String.class, String.class);
+ endpointRegistry =
+ (EndpointRegistry)constructor.newInstance(extensionRegistry, endpointRegistryURI, domainURI);
+ } catch (NoSuchMethodException e) {
+ constructor =
+ implClass.getConstructor(ExtensionPointRegistry.class, Map.class, String.class, String.class);
+ endpointRegistry =
+ (EndpointRegistry)constructor.newInstance(extensionRegistry,
+ sd.getAttributes(),
+ endpointRegistryURI,
+ domainURI);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ if (endpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)endpointRegistry).start();
+ }
+
+ for (EndpointListener listener : listeners) {
+ endpointRegistry.addListener(listener);
+ }
+ endpointRegistries.put(key, endpointRegistry);
+ return endpointRegistry;
+ }
+
+ public void stop() {
+ declarations.clear();
+ for (EndpointRegistry endpointRegistry : endpointRegistries.values()) {
+ if (endpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)endpointRegistry).stop();
+ }
+ }
+ endpointRegistries.clear();
+ listeners.clear();
+ }
+
+ public synchronized Collection<EndpointRegistry> getEndpointRegistries() {
+ return new ArrayList<EndpointRegistry>(endpointRegistries.values());
+ }
+
+ public synchronized void addListener(EndpointListener listener) {
+ listeners.add(listener);
+ for(EndpointRegistry registry: endpointRegistries.values()) {
+ registry.addListener(listener);
+ }
+ }
+
+ public synchronized List<EndpointListener> getListeners() {
+ return listeners;
+ }
+
+ public synchronized void removeListener(EndpointListener listener) {
+ listeners.remove(listener);
+ for(EndpointRegistry registry: endpointRegistries.values()) {
+ registry.removeListener(listener);
+ }
+ }
+}
Propchange: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=823672&view=auto
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java (added)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java Fri Oct 9 19:59:43 2009
@@ -0,0 +1,299 @@
+/*
+ * 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.core.runtime.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * An builder that takes endpoint references and resolves them. It either finds local
+ * service endpoints if they are available or asks the domain. The main function here
+ * is to perform binding and policy matching.
+ * This is a separate builder in case it is required by undresolved endpoints
+ * once the runtime has started.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
+
+ protected ExtensionPointRegistry extensionPoints;
+ protected AssemblyFactory assemblyFactory;
+ protected InterfaceContractMapper interfaceContractMapper;
+ private Monitor monitor;
+
+
+ public EndpointReferenceBinderImpl(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+ UtilityExtensionPoint utils = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utils.getUtility(InterfaceContractMapper.class);
+ MonitorFactory monitorFactory = utils.getUtility(MonitorFactory.class);
+ monitor = monitorFactory.createMonitor();
+ }
+
+
+
+ /**
+ * Build a single endpoint reference
+ *
+ * @param endpoint
+ * @param monitor
+ */
+ public boolean bind(EndpointRegistry endpointRegistry, EndpointReference endpointReference) {
+ Problem problem = null;
+ if ( endpointReference.getStatus() == EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED ||
+ endpointReference.getStatus() == EndpointReference.RESOLVED_BINDING ) {
+ // The endpoint reference is already resolved to either
+ // a service endpoint local to this composite or it has
+ // a remote binding
+
+ // still need to check that the callback endpoint is set correctly
+ if (hasCallback(endpointReference) &&
+ endpointReference.getCallbackEndpoint() != null &&
+ endpointReference.getCallbackEndpoint().isUnresolved() == true ){
+ problem = selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService().getEndpoints());
+ }
+ } else if (endpointReference.getStatus() == EndpointReference.WIRED_TARGET_FOUND_READY_FOR_MATCHING ){
+ // The endpoint reference is already resolved to either
+ // a service endpoint but no binding was specified in the
+ // target URL and/or the policies have yet to be matched.
+
+ problem = selectForwardEndpoint(endpointReference,
+ endpointReference.getTargetEndpoint().getService().getEndpoints());
+
+ if (problem == null && hasCallback(endpointReference)){
+ problem = selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService().getEndpoints());
+ }
+
+ } else if (endpointReference.getStatus() == EndpointReference.WIRED_TARGET_NOT_FOUND ||
+ endpointReference.getStatus() == EndpointReference.NOT_CONFIGURED){
+ // The service is in a remote composite somewhere else in the domain
+
+ // find the service in the endpoint registry
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+
+ if (endpoints.size() == 0) {
+ problem = monitor.createProblem(this.getClass().getName(),
+ "endpoint-validation-messages",
+ Problem.Severity.ERROR,
+ this,
+ "NoEndpointsFound",
+ endpointReference.toString());
+ }
+
+ problem = selectForwardEndpoint(endpointReference,
+ endpoints);
+
+ if (problem == null && hasCallback(endpointReference)){
+ problem = selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService().getEndpoints());
+ }
+ }
+
+ if (problem != null){
+ monitor.problem(problem);
+ return false;
+ }
+
+ if (endpointReference.getStatus() != EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED &&
+ endpointReference.getStatus() != EndpointReference.RESOLVED_BINDING){
+ problem = monitor.createProblem(this.getClass().getName(),
+ "endpoint-validation-messages",
+ Problem.Severity.ERROR,
+ this,
+ "EndpointReferenceCantBeMatched",
+ endpointReference.toString());
+ monitor.problem(problem);
+ return false;
+ }
+
+ return true;
+
+ }
+
+ private Problem selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints) {
+
+ Endpoint matchedEndpoint = null;
+
+ if (endpointReference.getReference().getName().startsWith("$self$.")){
+ // just select the first one and don't do any policy matching
+ matchedEndpoint = endpoints.get(0);
+ } else {
+ // find the first endpoint that matches this endpoint reference
+ for (Endpoint endpoint : endpoints){
+ if (haveMatchingPolicy(endpointReference, endpoint)){
+ matchedEndpoint = endpoint;
+ break;
+ }
+ }
+ }
+
+ if (matchedEndpoint == null){
+ return null;
+ }
+
+ endpointReference.setTargetEndpoint(matchedEndpoint);
+ endpointReference.setBinding(endpointReference.getTargetEndpoint().getBinding());
+ endpointReference.setStatus(EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED);
+ endpointReference.setUnresolved(false);
+
+ return null;
+ }
+
+ private boolean hasCallback(EndpointReference endpointReference){
+ if (endpointReference.getReference().getInterfaceContract() == null ||
+ endpointReference.getReference().getInterfaceContract().getCallbackInterface() == null ||
+ endpointReference.getReference().getName().startsWith("$self$.")){
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private Problem selectCallbackEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints) {
+
+ Problem problem = null;
+
+ // find the first callback endpoint that matches a callback endpoint reference
+ // at the service
+ Endpoint matchedEndpoint = null;
+ match:
+ for ( EndpointReference callbackEndpointReference : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
+ for (Endpoint endpoint : endpoints){
+ if (haveMatchingPolicy(callbackEndpointReference, endpoint)){
+ matchedEndpoint = endpoint;
+ break match;
+ }
+ }
+ }
+
+ if (matchedEndpoint == null){
+ return null;
+ }
+
+ endpointReference.setCallbackEndpoint(matchedEndpoint);
+
+ return problem;
+ }
+
+ // FIXME: [rfeng] This implementation is wrong. It is the responsibility of the policy language
+ // to compare the reference and service side setting to determine if they are compatible. Some of
+ // policies apply to the reference side only, some of the policies apply to the service side only,
+ // while others apply to both sides. Even for those policies that apply to both side, they can be
+ // independent or related.
+ private boolean haveMatchingPolicy(EndpointReference endpointReference, Endpoint endpoint){
+
+ /*
+ // if no policy sets or intents are present then they match
+ if ((endpointReference.getRequiredIntents().size() == 0) &&
+ (endpoint.getRequiredIntents().size() == 0) &&
+ (endpointReference.getPolicySets().size() == 0) &&
+ (endpoint.getPolicySets().size() == 0)) {
+ return true;
+ }
+
+ // if there are different numbers of intents
+ // then they don't match
+ if (endpointReference.getRequiredIntents().size() !=
+ endpoint.getRequiredIntents().size()) {
+ return false;
+ }
+
+ // if there are different numbers of policy sets
+ // then they don't match
+ if (endpointReference.getPolicySets().size() !=
+ endpoint.getPolicySets().size()) {
+ return false;
+ }
+
+ // check intents for compatibility
+ for(Intent intentEPR : endpointReference.getRequiredIntents()){
+ boolean matched = false;
+ for (Intent intentEP : endpoint.getRequiredIntents()){
+ if (intentEPR.getName().equals(intentEP.getName())){
+ matched = true;
+ break;
+ }
+ }
+ if (matched == false){
+ return false;
+ }
+ }
+
+ // check policy sets for compatibility. The list of policy sets
+ // may be a subset of the list of intents as some of the intents
+ // may be directly provided. We can't just rely on intent compatibility
+ // as different policy sets might have been attached at each end to
+ // satisfy the listed intents
+
+ // if all of the policy sets on the endpoint reference match a
+ // policy set on the endpoint then they match
+ for(PolicySet policySetEPR : endpointReference.getPolicySets()){
+ boolean matched = false;
+ for (PolicySet policySetEP : endpoint.getPolicySets()){
+ // find if there is a policy set with the same name
+ if (policySetEPR.getName().equals(policySetEP.getName())){
+ matched = true;
+ break;
+ }
+ // find if the policies inside the policy set match the
+ // policies inside a policy set on the endpoint
+
+ // TODO - need a policy specific matcher to do this
+ // so need a new extension point
+
+ }
+
+ if (matched == false){
+ return false;
+ }
+ }
+ */
+
+ return true;
+ }
+
+ public boolean isOutOfDate(EndpointRegistry endpointRegistry, EndpointReference endpointReference) {
+ Endpoint te = endpointReference.getTargetEndpoint();
+ if (!te.isUnresolved() && te.getURI()!= null) {
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+ return ! endpoints.contains(endpointReference.getTargetEndpoint());
+ }
+ return false;
+ }
+
+}
Propchange: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory?rev=823672&view=auto
==============================================================================
--- tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory (added)
+++ tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory Fri Oct 9 19:59:43 2009
@@ -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.
+# Set the ranking to be greater than the DefaultAssemblyFactory
+org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;ranking=100
\ No newline at end of file
Added: tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory?rev=823672&view=auto
==============================================================================
--- tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory (added)
+++ tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory Fri Oct 9 19:59:43 2009
@@ -0,0 +1,17 @@
+# 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.core.runtime.DefaultDomainRegistryFactory
Added: tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder?rev=823672&view=auto
==============================================================================
--- tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder (added)
+++ tuscany/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder Fri Oct 9 19:59:43 2009
@@ -0,0 +1,17 @@
+# 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.core.runtime.impl.EndpointReferenceBinderImpl
Modified: tuscany/java/sca/modules/domain-node/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/domain-node/META-INF/MANIFEST.MF?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/domain-node/META-INF/MANIFEST.MF (original)
+++ tuscany/java/sca/modules/domain-node/META-INF/MANIFEST.MF Fri Oct 9 19:59:43 2009
@@ -11,6 +11,7 @@
Import-Package:
org.apache.tuscany.sca.management;version="2.0.0",
org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
org.apache.tuscany.sca.node.impl;version="2.0.0"
Bundle-SymbolicName: org.apache.tuscany.sca.domain.node
Bundle-DocURL: http://www.apache.org/
Modified: tuscany/java/sca/modules/domain-node/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/domain-node/pom.xml?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/domain-node/pom.xml (original)
+++ tuscany/java/sca/modules/domain-node/pom.xml Fri Oct 9 19:59:43 2009
@@ -58,12 +58,6 @@
<version>2.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-endpoint-wrapper</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
</dependencies>
</project>
Modified: tuscany/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java (original)
+++ tuscany/java/sca/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java Fri Oct 9 19:59:43 2009
@@ -24,10 +24,9 @@
import java.util.Map;
import org.apache.tuscany.sca.management.ConfigAttributes;
-import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
-import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
public class DomainNode {
@@ -37,8 +36,9 @@
public static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
private ConfigAttributes configAttributes = new ConfigAttributesImpl();
+ private String domainRegistryURI;
- private NodeFactoryImpl nodeFactory;
+ private NodeFactory nodeFactory;
private Map<String, Node> nodes = new HashMap<String, Node>();
public DomainNode() {
@@ -46,11 +46,13 @@
}
public DomainNode(String configURI) {
+ this.domainRegistryURI = configURI;
parseConfigURI(configURI);
start();
}
public DomainNode(String configURI, String... contributionLocations) {
+ this.domainRegistryURI = configURI;
parseConfigURI(configURI);
start();
for (String loc : contributionLocations) {
@@ -60,12 +62,10 @@
public void start() {
if (nodeFactory != null) {
- throw new IllegalStateException("Already started");
+ throw new IllegalStateException("The node is already started");
}
- //TODO shouldn't really be working with the impl
- nodeFactory = (NodeFactoryImpl)NodeFactory.getInstance(configAttributes.getAttributes().get(DOMAIN_NAME_ATTR));
- nodeFactory.setConfigAttributes(configAttributes);
+ nodeFactory = NodeFactory.getInstance(configAttributes.getAttributes().get(DOMAIN_NAME_ATTR));
}
public boolean isStarted() {
@@ -74,17 +74,13 @@
public void stop() {
if (nodeFactory == null) {
- throw new IllegalStateException("not started");
+ throw new IllegalStateException("The node is not started");
}
for (Node node : nodes.values()) {
node.stop();
}
-
-// TODO: stopping the node factory stops _all_ domain nodes not just this instance
-// nodeFactory.destroy();
-// nodeFactory = null;
-// nodes.clear();
+
}
public String addContribution(String location) {
@@ -97,7 +93,11 @@
if (nodes.containsKey(uri)) {
throw new IllegalArgumentException("contribution already added: " + uri);
}
- Node node = nodeFactory.createNode(new Contribution(uri, location)).start();
+ NodeConfiguration configuration =
+ nodeFactory.createNodeConfiguration().addContribution(uri, location)
+ .setDomainRegistryURI(domainRegistryURI).setDomainURI(configAttributes.getAttributes()
+ .get(DOMAIN_NAME_ATTR)).setURI(uri);
+ Node node = nodeFactory.createNode(configuration).start();
nodes.put(uri, node);
}
Modified: tuscany/java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java (original)
+++ tuscany/java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java Fri Oct 9 19:59:43 2009
@@ -24,7 +24,6 @@
import static org.junit.Assert.fail;
import itest.nodes.Helloworld;
-import org.apache.tuscany.sca.domain.node.DomainNode;
import org.junit.After;
import org.junit.Test;
import org.oasisopen.sca.client.SCAClient;
@@ -58,7 +57,6 @@
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
fail();
} catch (Exception e) {
- e.printStackTrace();
// expected
}
Modified: tuscany/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF (original)
+++ tuscany/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF Fri Oct 9 19:59:43 2009
@@ -14,6 +14,7 @@
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
Import-Package: org.apache.catalina.tribes,
org.apache.catalina.tribes.group,
+ org.apache.catalina.tribes.group.interceptors,
org.apache.catalina.tribes.io,
org.apache.catalina.tribes.membership,
org.apache.catalina.tribes.tipis,
Modified: tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java (original)
+++ tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java Fri Oct 9 19:59:43 2009
@@ -20,12 +20,16 @@
package org.apache.tuscany.sca.endpoint.tribes;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.NetworkInterface;
+import java.net.URI;
import java.net.URL;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -36,11 +40,8 @@
import org.apache.catalina.tribes.Channel;
import org.apache.catalina.tribes.ChannelException;
-import org.apache.catalina.tribes.ChannelInterceptor;
import org.apache.catalina.tribes.Member;
-import org.apache.catalina.tribes.group.ChannelCoordinator;
import org.apache.catalina.tribes.group.GroupChannel;
-import org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor;
import org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor;
import org.apache.catalina.tribes.membership.McastService;
import org.apache.catalina.tribes.membership.StaticMember;
@@ -48,10 +49,8 @@
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.tribes.AbstractReplicatedMap.MapEntry;
import org.apache.tuscany.sca.endpoint.tribes.MapStore.MapListener;
-import org.apache.tuscany.sca.management.ConfigAttributes;
import org.apache.tuscany.sca.runtime.EndpointListener;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -98,26 +97,50 @@
return channel;
}
- public ReplicatedEndpointRegistry(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ public ReplicatedEndpointRegistry(ExtensionPointRegistry registry,
+ Map<String, String> attributes,
+ String domainRegistryURI,
+ String domainURI) {
this.registry = registry;
+ this.domainURI = domainURI;
- UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
- ConfigAttributes domainConfig = utilities.getUtility(ConfigAttributes.class);
- if (domainConfig != null) {
- setConfig(domainConfig.getAttributes());
- } else {
- setConfig(attributes);
+ getParameters(domainRegistryURI);
+ }
+
+ private Map<String, String> getParameters(String domainRegistryURI) {
+ Map<String, String> map = new HashMap<String, String>();
+ URI uri = URI.create(domainRegistryURI);
+ map.put("address", uri.getHost());
+ map.put("port", String.valueOf(uri.getPort()));
+ int index = domainRegistryURI.indexOf('?');
+ if (index == -1) {
+ setConfig(map);
+ return map;
+ }
+ String query = domainRegistryURI.substring(index + 1);
+ try {
+ query = URLDecoder.decode(query, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException(e);
+ }
+ String[] params = query.split("&");
+ for (String param : params) {
+ index = param.indexOf('=');
+ if (index != -1) {
+ map.put(param.substring(0, index), param.substring(index + 1));
+ }
}
+ setConfig(map);
+ return map;
}
private void setConfig(Map<String, String> attributes) {
- if (attributes.containsKey("domainName")) {
- domainURI = attributes.get("domainName");
- }
-
String portStr = attributes.get("port");
if (portStr != null) {
port = Integer.parseInt(portStr);
+ if (port == -1) {
+ port = MULTICAST_PORT;
+ }
}
String address = attributes.get("address");
if (address == null) {
@@ -143,11 +166,6 @@
}
}
- public ReplicatedEndpointRegistry(String domainURI) {
- this.domainURI = domainURI;
- // start();
- }
-
public void start() {
if (map != null) {
throw new IllegalStateException("The registry has already been started");
Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java?rev=823672&r1=823671&r2=823672&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java (original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java Fri Oct 9 19:59:43 2009
@@ -33,6 +33,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.apache.tuscany.sca.extensibility.impl.LDAPFilter;
+
/**
* Service discovery for Tuscany based on J2SE Jar service provider spec.
* Services are described using configuration files in META-INF/services.
@@ -152,9 +154,52 @@
return sds;
}
+ /**
+ * Discover all service providers that are compatible with the service type
+ * @param serviceType
+ * @return
+ * @throws IOException
+ */
public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType) throws IOException {
return getServiceDeclarations(serviceType, false);
}
+
+ /**
+ * Discover all service providers that are compatible with the service type and match the filter
+ * @param serviceType
+ * @param filter
+ * @return
+ * @throws IOException
+ */
+ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType, String filter) throws IOException {
+ Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType, false);
+ Collection<ServiceDeclaration> filtered = new ArrayList<ServiceDeclaration>();
+ LDAPFilter filterImpl = LDAPFilter.newInstance(filter);
+ for(ServiceDeclaration sd: sds) {
+ if(filterImpl.match(sd.getAttributes())) {
+ filtered.add(sd);
+ }
+ }
+ return filtered;
+ }
+
+ /**
+ * @param serviceName
+ * @param filter
+ * @return
+ * @throws IOException
+ */
+ public Collection<ServiceDeclaration> getServiceDeclarations(String serviceName, String filter) throws IOException {
+ Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceName, false);
+ Collection<ServiceDeclaration> filtered = new ArrayList<ServiceDeclaration>();
+ LDAPFilter filterImpl = LDAPFilter.newInstance(filter);
+ for(ServiceDeclaration sd: sds) {
+ if(filterImpl.match(sd.getAttributes())) {
+ filtered.add(sd);
+ }
+ }
+ return filtered;
+ }
public ServiceDeclaration getServiceDeclaration(Class<?> serviceType) throws IOException {
Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType, true);
Added: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java?rev=823672&view=auto
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java (added)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java Fri Oct 9 19:59:43 2009
@@ -0,0 +1,86 @@
+/*
+ * 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.extensibility.impl;
+
+/**
+ * A Framework exception used to indicate that a filter string has an invalid
+ * syntax.
+ *
+ * <p>
+ * An <code>InvalidSyntaxException</code> object indicates that a filter
+ * string parameter has an invalid syntax and cannot be parsed.
+ *
+ * <p>
+ * This exception conforms to the general purpose exception chaining mechanism.
+ *
+ */
+
+public class InvalidSyntaxException extends RuntimeException {
+ static final long serialVersionUID = -4295194420816491875L;
+ /**
+ * The invalid filter string.
+ */
+ private final String filter;
+
+ /**
+ * Creates an exception of type <code>InvalidSyntaxException</code>.
+ *
+ * <p>
+ * This method creates an <code>InvalidSyntaxException</code> object with
+ * the specified message and the filter string which generated the
+ * exception.
+ *
+ * @param msg The message.
+ * @param filter The invalid filter string.
+ */
+ public InvalidSyntaxException(String msg, String filter) {
+ super(msg);
+ this.filter = filter;
+ }
+
+ /**
+ * Creates an exception of type <code>InvalidSyntaxException</code>.
+ *
+ * <p>
+ * This method creates an <code>InvalidSyntaxException</code> object with
+ * the specified message and the filter string which generated the
+ * exception.
+ *
+ * @param msg The message.
+ * @param filter The invalid filter string.
+ * @param cause The cause of this exception.
+ * @since 1.3
+ */
+ public InvalidSyntaxException(String msg, String filter, Throwable cause) {
+ super(msg, cause);
+ this.filter = filter;
+ }
+
+ /**
+ * Returns the filter string that generated the
+ * <code>InvalidSyntaxException</code> object.
+ *
+ * @return The invalid filter string.
+ * @see BundleContext#getServiceReferences
+ * @see BundleContext#addServiceListener(ServiceListener,String)
+ */
+ public String getFilter() {
+ return filter;
+ }
+}
\ No newline at end of file
Propchange: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date