diff options
Diffstat (limited to 'java')
9 files changed, 125 insertions, 57 deletions
diff --git a/java/sca/features/all/pom.xml b/java/sca/features/all/pom.xml index d3b38106ab..c390551e4a 100644 --- a/java/sca/features/all/pom.xml +++ b/java/sca/features/all/pom.xml @@ -80,6 +80,11 @@ <version>2.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java index e2ee776d55..befd60fd95 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint2.java @@ -33,8 +33,19 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public interface Endpoint2 extends Base, PolicySubject, Cloneable, Serializable { + /** + * Get the structural URI of the service binding + * @return structural URI of the service/binding + */ + String getURI(); /** + * Set the structural URI of the service binding + * @param uri <componentURI>#service-binding(serviceName/bindingName) + * or <componentURI>#service(serviceName) + */ + void setURI(String uri); + /** * Supports endpoint cloning * * @return endpoint diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference2.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference2.java index 2c6d95f20b..b6ca379996 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference2.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference2.java @@ -31,6 +31,19 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public interface EndpointReference2 extends Base, PolicySubject, Cloneable, Serializable { + /** + * Get the structural URI of the reference binding + * @return The structural URI of the reference/binding + */ + String getURI(); + + /** + * Set the structural URI of the reference binding + * @param uri <componentURI>#reference-binding(referenceName/bindingName) + * or <componentURI>#reference(referenceName) if binding is not present + * + */ + void setURI(String uri); /** * Supports endpoint reference cloning diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java index 26bf3bcda6..9844a8b7b1 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/Endpoint2Impl.java @@ -42,17 +42,18 @@ public class Endpoint2Impl implements Endpoint2 { private static final long serialVersionUID = 7344399683703812593L; protected ExtensionPointRegistry registry; - private Boolean unresolved; - private String componentName; - private Component component; - private String serviceName; - private ComponentService service; - private String bindingName; - private Binding binding; - private InterfaceContract interfaceContract; - private List<EndpointReference2> callbackEndpointReferences = new ArrayList<EndpointReference2>(); - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private List<Intent> requiredIntents = new ArrayList<Intent>(); + protected boolean unresolved; + protected String uri; + protected String componentName; + protected Component component; + protected String serviceName; + protected ComponentService service; + protected String bindingName; + protected Binding binding; + protected InterfaceContract interfaceContract; + protected List<EndpointReference2> callbackEndpointReferences = new ArrayList<EndpointReference2>(); + protected List<PolicySet> policySets = new ArrayList<PolicySet>(); + protected List<Intent> requiredIntents = new ArrayList<Intent>(); protected Endpoint2Impl(ExtensionPointRegistry registry) { this.registry = registry; @@ -184,4 +185,12 @@ public class Endpoint2Impl implements Endpoint2 { return output; } + public String getURI() { + return uri; + } + + public void setURI(String uri) { + this.uri = uri; + } + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java index 4514d0e64b..fa61de9bd8 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReference2Impl.java @@ -18,10 +18,6 @@ */ package org.apache.tuscany.sca.assembly.impl; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import java.util.ArrayList; import java.util.List; @@ -42,23 +38,24 @@ import org.apache.tuscany.sca.policy.PolicySubject; * * @version $Rev$ $Date$ */ -public class EndpointReference2Impl implements EndpointReference2, Externalizable { - private ExtensionPointRegistry registry; +public class EndpointReference2Impl implements EndpointReference2 { + protected ExtensionPointRegistry registry; // this endpoint reference - private Boolean unresolved = true; - private Component component; - private ComponentReference reference; - private Binding binding; - private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private List<Intent> requiredIntents = new ArrayList<Intent>(); - private InterfaceContract interfaceContract; + protected boolean unresolved = true; + protected String uri; + protected Component component; + protected ComponentReference reference; + protected Binding binding; + protected List<PolicySet> policySets = new ArrayList<PolicySet>(); + protected List<Intent> requiredIntents = new ArrayList<Intent>(); + protected InterfaceContract interfaceContract; // the target of the endpoint reference - private Endpoint2 targetEndpoint; + protected Endpoint2 targetEndpoint; // callback endpoint that messages across this reference // will be directed toward - private Endpoint2 callbackEndpoint; + protected Endpoint2 callbackEndpoint; protected EndpointReference2Impl(ExtensionPointRegistry registry) { this.registry = registry; @@ -178,15 +175,11 @@ public class EndpointReference2Impl implements EndpointReference2, Externalizabl return output; } - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - // TODO: Lookup an endpoint reference serializer utility from the UtilityExtensionPoint - // Read the EPR from the XML document - // See javax.xml.ws.wsaddressing.W3CEndpointReference + public String getURI() { + return uri; } - public void writeExternal(ObjectOutput out) throws IOException { - // TODO: Lookup an endpoint reference serializer utility from the UtilityExtensionPoint - // Write the EPR as XML document - // See javax.xml.ws.wsaddressing.W3CEndpointReference + public void setURI(String uri) { + this.uri = uri; } } diff --git a/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java index 70873310f2..330c22d4e9 100644 --- a/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java +++ b/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java @@ -35,6 +35,7 @@ import org.apache.catalina.tribes.tipis.AbstractReplicatedMap; import org.apache.catalina.tribes.tipis.ReplicatedMap;
import org.apache.tuscany.sca.assembly.Endpoint2;
import org.apache.tuscany.sca.assembly.EndpointReference2;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.runtime.EndpointListener;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -45,8 +46,14 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry { private final static Logger logger = Logger.getLogger(ReplicatedEndpointRegistry.class.getName());
private static final String MULTICAST_ADDRESS = "228.0.0.100";
private static final int MULTICAST_PORT = 50000;
- private String domainURI = "default";
+ private int port = MULTICAST_PORT;
+ private String address = MULTICAST_ADDRESS;
+ private String bind = null;
+ private int timeout = 50;
+
+ private final static String DEFAULT_DOMAIN_URI = "http://tuscany.apache.org/sca/1.1/domains/default";
+ private String domainURI = DEFAULT_DOMAIN_URI;
private List<EndpointReference2> endpointreferences = new CopyOnWriteArrayList<EndpointReference2>();
private List<EndpointListener> listeners = new CopyOnWriteArrayList<EndpointListener>();
@@ -67,25 +74,41 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry { mcastService.setBind(bindAddress);
}
- // mcastService.setBind("192.168.1.100");
-
- try {
- channel.start(Channel.DEFAULT);
- } catch (ChannelException e) {
- throw new IllegalStateException(e);
- }
+ mcastService.setBind("192.168.1.100");
return channel;
}
- public ReplicatedEndpointRegistry() {
- this("default");
+ public ReplicatedEndpointRegistry(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ String portStr = attributes.get("port");
+ if (portStr != null) {
+ port = Integer.parseInt(portStr);
+ }
+ String address = attributes.get("address");
+ if (address == null) {
+ address = MULTICAST_ADDRESS;
+ }
+ bind = attributes.get("bind");
+ String timeoutStr = attributes.get("timeout");
+ if (timeoutStr != null) {
+ timeout = Integer.parseInt(timeoutStr);
+ }
+ start();
}
public ReplicatedEndpointRegistry(String domainURI) {
this.domainURI = domainURI;
+ start();
+ }
+
+ public void start() {
map =
- new ReplicatedMap(null, createChannel(MULTICAST_ADDRESS, MULTICAST_PORT, null), 50, domainURI,
+ new ReplicatedMap(null, createChannel(address, port, bind), timeout, this.domainURI,
new ClassLoader[] {ReplicatedEndpointRegistry.class.getClassLoader()});
+ try {
+ map.getChannel().start(Channel.DEFAULT);
+ } catch (ChannelException e) {
+ throw new IllegalStateException(e);
+ }
}
public void addEndpoint(Endpoint2 endpoint) {
@@ -116,7 +139,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry { Endpoint2 endpoint = (Endpoint2)v;
// TODO: implement more complete matching
if (endpoint.getComponentName().equals(targetEndpoint.getComponentName())) {
- if ((targetEndpoint.getServiceName() != null) && (endpoint.getServiceName().equals(targetEndpoint
+ if ((targetEndpoint.getServiceName() == null) || (targetEndpoint.getServiceName().equals(endpoint
.getServiceName()))) {
foundEndpoints.add(endpoint);
logger.info("EndpointRegistry: Found endpoint with matching service - " + endpoint);
@@ -209,9 +232,9 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry { Thread.sleep(2000);
System.out.println(localhost + ": " + map.keySet());
}
- for(Object e: map.entrySetFull()) {
- Map.Entry en = (Map.Entry) e;
- AbstractReplicatedMap.MapEntry entry = (AbstractReplicatedMap.MapEntry) en.getValue();
+ for (Object e : map.entrySetFull()) {
+ Map.Entry en = (Map.Entry)e;
+ AbstractReplicatedMap.MapEntry entry = (AbstractReplicatedMap.MapEntry)en.getValue();
entry.isPrimary();
}
map.breakdown();
diff --git a/java/sca/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry b/java/sca/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry index 1b7d0e7d89..5a7bafd7f6 100644 --- a/java/sca/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry +++ b/java/sca/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry @@ -14,4 +14,4 @@ # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpointRegistry;ranking=100
\ No newline at end of file +org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpointRegistry;ranking=100,address=228.0.0.100,port=50000,timeout=50
\ No newline at end of file diff --git a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java index 7b34e988b0..093fba6446 100644 --- a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java +++ b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java @@ -184,6 +184,7 @@ public class EndpointReferenceBuilderImpl implements CompositeBuilder, EndpointR // The service is in the same composite // TODO - How do we get to here? matchForwardBinding(endpointReference, + true, monitor); matchCallbackBinding(endpointReference, @@ -207,11 +208,9 @@ public class EndpointReferenceBuilderImpl implements CompositeBuilder, EndpointR endpointReference.setTargetEndpoint(endpoints.get(0)); - matchForwardBinding(endpointReference, - monitor); + matchForwardBinding(endpointReference, false, monitor); - matchCallbackBinding(endpointReference, - monitor); + matchCallbackBinding(endpointReference, monitor); } } @@ -223,6 +222,7 @@ public class EndpointReferenceBuilderImpl implements CompositeBuilder, EndpointR // TODO - EPR - In OASIS case there are no bindings to match with on the // reference side. private void matchForwardBinding(EndpointReference2 endpointReference, + boolean local, Monitor monitor) { Endpoint2 endpoint = endpointReference.getTargetEndpoint(); @@ -232,13 +232,26 @@ public class EndpointReferenceBuilderImpl implements CompositeBuilder, EndpointR // Find the corresponding bindings from the service side for (Binding referenceBinding : endpointReference.getReference().getBindings()) { - for (Endpoint2 serviceEndpoint : endpoint.getService().getEndpoints()) { + if (local) { + for (Endpoint2 serviceEndpoint : endpoint.getService().getEndpoints()) { - if (referenceBinding.getClass() == serviceEndpoint.getBinding().getClass() && - hasCompatiblePolicySets(referenceBinding, serviceEndpoint.getBinding())) { + if (referenceBinding.getClass() == serviceEndpoint.getBinding().getClass() && hasCompatiblePolicySets(referenceBinding, + serviceEndpoint + .getBinding())) { + + matchedReferenceBinding.add(referenceBinding); + matchedServiceEndpoint.add(serviceEndpoint); + } + } + } else { + Endpoint2 serviceEndpoint = endpoint; + if (referenceBinding.getClass() == serviceEndpoint.getBinding().getClass() && hasCompatiblePolicySets(referenceBinding, + serviceEndpoint + .getBinding())) { matchedReferenceBinding.add(referenceBinding); matchedServiceEndpoint.add(serviceEndpoint); + } } } diff --git a/java/sca/modules/pom.xml b/java/sca/modules/pom.xml index a690efbc33..33af5082fa 100644 --- a/java/sca/modules/pom.xml +++ b/java/sca/modules/pom.xml @@ -57,6 +57,7 @@ <module>definitions</module> <module>definitions-xml</module> <module>endpoint</module> + <module>endpoint-tribes</module> <module>extensibility</module> <module>extensibility-equinox</module> <module>host-http</module> |