diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-21 22:11:10 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-21 22:11:10 +0000 |
commit | 9c6777cd9df0a0c0d0410a31bf2b526372a179bb (patch) | |
tree | 012fa067571412736536f4651942a6c0bee780ff /sca-java-2.x/trunk/modules/binding-websocket/src | |
parent | c273cc2dbd9ad3ccf07d4018e4262617d4ba1793 (diff) |
Properly creating endpoints, to avoid issues with OSGi in Eclipse env
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1173891 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-websocket/src')
4 files changed, 22 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingDispatcher.java b/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingDispatcher.java index eda78de98a..3b62c726e9 100644 --- a/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingDispatcher.java +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingDispatcher.java @@ -21,6 +21,7 @@ package org.apache.tuscany.sca.binding.websocket.runtime; import java.util.HashMap; import java.util.Map; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.runtime.RuntimeEndpoint; @@ -32,8 +33,8 @@ public class WebsocketBindingDispatcher { private Map<String, WebsocketServiceInvoker> invokers = new HashMap<String, WebsocketServiceInvoker>(); - public void addOperation(String uri, RuntimeEndpoint endpoint, Operation operation) { - invokers.put(uri, new WebsocketServiceInvoker(operation, endpoint)); + public void addOperation(String uri, ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint, Operation operation) { + invokers.put(uri, new WebsocketServiceInvoker(extensionPoints, operation, endpoint)); } public WebsocketServiceInvoker dispatch(String uri) { diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.java b/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.java index 5c5f96bd76..97f548aa74 100644 --- a/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.java +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.java @@ -34,9 +34,11 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; */
public class WebsocketBindingProviderFactory implements BindingProviderFactory<WebsocketBinding> {
+ private ExtensionPointRegistry extensionPoints;
private ServletHost servletHost;
public WebsocketBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
}
@@ -49,7 +51,7 @@ public class WebsocketBindingProviderFactory implements BindingProviderFactory<W }
public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
- return new WebsocketServiceBindingProvider(endpoint, servletHost);
+ return new WebsocketServiceBindingProvider(extensionPoints, endpoint, servletHost);
}
}
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java index 2352970b2e..5a8fd0f7ad 100644 --- a/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.Map;
import org.apache.tuscany.sca.binding.websocket.WebsocketBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -38,10 +39,12 @@ public class WebsocketServiceBindingProvider implements ServiceBindingProvider { private static final int DEFAULT_PORT = 9000;
private static final String JAVASCRIPT_RESOURCE_PATH = "/org.apache.tuscany.sca.WebsocketComponentContext.js";
private static Map<Integer, WebsocketServer> servers = new HashMap<Integer, WebsocketServer>();
+ private ExtensionPointRegistry extensionPoints;
private RuntimeEndpoint endpoint;
private ServletHost servletHost;
- public WebsocketServiceBindingProvider(RuntimeEndpoint endpoint, ServletHost servletHost) {
+ public WebsocketServiceBindingProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint, ServletHost servletHost) {
+ this.extensionPoints = extensionPoints;
this.endpoint = endpoint;
this.servletHost = servletHost;
}
@@ -58,7 +61,7 @@ public class WebsocketServiceBindingProvider implements ServiceBindingProvider { String service = endpoint.getService().getName();
for (Operation op : getBindingInterfaceContract().getInterface().getOperations()) {
String operation = op.getName();
- server.getDispatcher().addOperation(component + "." + service + "." + operation, endpoint, op);
+ server.getDispatcher().addOperation(component + "." + service + "." + operation, extensionPoints, endpoint, op);
}
JavascriptGenerator.generateServiceProxy(component, service, getBindingInterfaceContract().getInterface()
.getOperations(), port);
diff --git a/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java b/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java index 3efb25adea..6bf6d865b1 100644 --- a/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java @@ -21,9 +21,11 @@ package org.apache.tuscany.sca.binding.websocket.runtime; import java.lang.reflect.InvocationTargetException;
+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.assembly.impl.RuntimeEndpointImpl;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.invocation.Constants;
import org.apache.tuscany.sca.core.invocation.impl.MessageImpl;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -36,10 +38,14 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpoint; */
public class WebsocketServiceInvoker {
+ protected AssemblyFactory assemblyFactory;
protected Operation operation;
protected RuntimeEndpoint endpoint;
- public WebsocketServiceInvoker(Operation operation, RuntimeEndpoint endpoint) {
+ public WebsocketServiceInvoker(ExtensionPointRegistry extensionPoints, Operation operation, RuntimeEndpoint endpoint) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+
this.operation = operation;
this.endpoint = endpoint;
}
@@ -63,8 +69,8 @@ public class WebsocketServiceInvoker { Message msg = new MessageImpl();
msg.getHeaders().put(Constants.MESSAGE_ID, channel.getId());
msg.setBody(args);
- EndpointReference re = new RuntimeEndpointReferenceImpl();
- RuntimeEndpointImpl callbackEndpoint = new RuntimeEndpointImpl();
+ EndpointReference re = assemblyFactory.createEndpointReference(); //new RuntimeEndpointReferenceImpl();
+ Endpoint callbackEndpoint = assemblyFactory.createEndpoint(); //new RuntimeEndpointImpl();
callbackEndpoint.setURI(request.getOperation());
re.setCallbackEndpoint(callbackEndpoint);
msg.setFrom(re);
|