summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-03-14 00:50:38 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-03-14 00:50:38 +0000
commitb4f48f407a8fefba16395eceb34de6bd48e74d12 (patch)
tree7e1bcf4456ef1dfd3b4d337ed7ea262f1259ffef /sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org
parent014971ccb5b2041147cf9d84d498cce64ea0493e (diff)
Improve the IP address binding to be based on the host from the uri
Having servlet host to return deployed uri git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@922701 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java66
-rw-r--r--sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java6
2 files changed, 31 insertions, 41 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java b/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
index 0917804d65..5316efeef0 100644
--- a/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
+++ b/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
@@ -36,9 +36,10 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.directwebremoting.Container;
import org.directwebremoting.create.AbstractCreator;
import org.directwebremoting.extend.CreatorManager;
@@ -57,7 +58,7 @@ import org.directwebremoting.servlet.UrlProcessor;
public class ClientServlet extends DwrServlet {
private static final long serialVersionUID = 1L;
- private transient Map<String, ServiceHolder> services;
+ private transient Map<String, RuntimeEndpointReference> serviceRefs;
// private transient List<String> referenceNames;
private transient boolean initialized;
private transient Map<String, String> initParams;
@@ -65,7 +66,7 @@ public class ClientServlet extends DwrServlet {
public static final String SCRIPT_PATH = "/org.oasisopen.sca.componentContext.js";
public ClientServlet() {
- this.services = new HashMap<String, ServiceHolder>();
+ this.serviceRefs = new HashMap<String, RuntimeEndpointReference>();
// this.referenceNames = new ArrayList<String>();
this.initParams = new HashMap<String, String>();
@@ -88,7 +89,7 @@ public class ClientServlet extends DwrServlet {
if (!initialized) {
super.init(patchConfig(servletConfig));
addScriptHandler();
- initServices();
+ // initServices();
initialized = true;
}
}
@@ -159,8 +160,8 @@ public class ClientServlet extends DwrServlet {
Remoter remoter = (Remoter)getContainer().getBean(Remoter.class.getName());
- for (String serviceName : services.keySet()) {
- String path = request.getServletPath() + "/" + services.get(serviceName).c.getName();
+ for (String serviceName : serviceRefs.keySet()) {
+ String path = request.getServletPath() + "/" + serviceName;
String serviceScript = remoter.generateInterfaceScript(serviceName, path);
out.println(serviceScript);
out.println("SCA.componentContext.serviceNames.push('" + serviceName + "');");
@@ -210,42 +211,27 @@ public class ClientServlet extends DwrServlet {
/**
* Add an SCA service to be added to the DWR runtime
*/
- public void addService(ComponentReference cr, RuntimeComponent c) {
- ServiceHolder holder = new ServiceHolder();
- holder.name = cr.getName();
- holder.cr = cr;
- holder.c = c;
- services.put(cr.getName(), holder);
- }
-
- /**
- * Defines each SCA service proxy instance to DWR
- */
- private void initServices() {
+ public void addService(RuntimeEndpointReference epr) {
+
CreatorManager creatorManager = (CreatorManager)getContainer().getBean(CreatorManager.class.getName());
-
- for (final ServiceHolder service : services.values()) {
-
- final Class<?> iface = ((JavaInterface)service.cr.getInterfaceContract().getInterface()).getJavaClass();
- final Object instance = service.c.getComponentContext().getServiceReference(iface, service.cr.getName()).getService();
-
- creatorManager.addCreator(service.cr.getName(), new AbstractCreator() {
- public Class<?> getType() {
- return iface;
- }
-
- public Object getInstance() throws InstantiationException {
- return instance;
- }
- });
- }
+ addService(creatorManager, epr);
+ serviceRefs.put(epr.getReference().getName(), epr);
}
- // utility class to aid passing around services
- private class ServiceHolder {
- String name;
- ComponentReference cr;
- RuntimeComponent c;
+ private void addService(CreatorManager creatorManager, final RuntimeEndpointReference epr) {
+ final Class<?> iface = ((JavaInterface)epr.getComponentTypeReferenceInterfaceContract().getInterface()).getJavaClass();
+
+ creatorManager.addCreator(epr.getReference().getName(), new AbstractCreator() {
+ public Class<?> getType() {
+ return iface;
+ }
+
+ public Object getInstance() throws InstantiationException {
+ ExtensionPointRegistry registry = epr.getCompositeContext().getExtensionPointRegistry();
+ ExtensibleProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ return proxyFactory.createProxy(iface, epr);
+ }
+ });
}
/**
diff --git a/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java b/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java
index e57d751048..049cda2eb8 100644
--- a/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java
+++ b/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java
@@ -20,6 +20,7 @@
package org.apache.tuscany.sca.implementation.web.client;
import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.host.http.ServletHostHelper;
@@ -30,6 +31,7 @@ import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.provider.ImplementationProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
public class JSClientExtensionPointImpl implements ClientExtensionPoint {
@@ -46,7 +48,9 @@ public class JSClientExtensionPointImpl implements ClientExtensionPoint {
if (component.getReferences().size() > 0) {
for (ComponentReference cr : component.getReferences()) {
- clientServlet.addService(cr, component);
+ for (EndpointReference epr : cr.getEndpointReferences()) {
+ clientServlet.addService((RuntimeEndpointReference)epr);
+ }
}
}