You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2007/10/26 00:26:04 UTC
svn commit: r588374 -
/incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java
Author: lresende
Date: Thu Oct 25 15:26:01 2007
New Revision: 588374
URL: http://svn.apache.org/viewvc?rev=588374&view=rev
Log:
Bringing back support for scaDomain.js
Modified:
incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java
Modified: incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java?rev=588374&r1=588373&r2=588374&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java Thu Oct 25 15:26:01 2007
@@ -19,10 +19,12 @@
package org.apache.tuscany.sca.binding.jsonrpc.provider;
+import java.net.URI;
import java.util.List;
import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCServiceServlet;
+import org.apache.tuscany.sca.binding.jsonrpc.ScaDomainScriptServlet;
import org.apache.tuscany.sca.core.invocation.JDKProxyFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
@@ -43,6 +45,11 @@
* @version $Rev$ $Date$
*/
public class JSONRPCServiceBindingProvider implements ServiceBindingProvider {
+ // path to the scaDomain.js script
+ // Note: this is the same as the Ajax binding to keep the client code
+ // the same for clients using either the ajax or jsonrpc binding
+ private static final String SCA_DOMAIN_SCRIPT = "/SCADomain/scaDomain.js";
+
private RuntimeComponentService service;
private InterfaceContract serviceContract;
private JSONRPCBinding binding;
@@ -102,25 +109,27 @@
}
servletHost.addServletMapping(mapping, serviceServlet);
- // TODO add support for scaDomain.js
// register service to scaDomain.js
-
- /*
- * int port; servletHost.addServletMapping(binding.getURI(),
- * serviceServlet); URI uri = URI.create(binding.getURI()); port =
- * uri.getPort(); if (port == -1) port = 8080; // get the
- * ScaDomainScriptServlet, if it doesn't yet exist create one // this
- * uses removeServletMapping / addServletMapping as theres no
- * getServletMapping facility URI domainURI =
- * URI.create("http://localhost:" + port + SCA_DOMAIN_SCRIPT);
- * ScaDomainScriptServlet scaDomainServlet = (ScaDomainScriptServlet)
- * servletHost.getServletMapping(domainURI.toString()); if
- * (scaDomainServlet == null) { scaDomainServlet = new
- * ScaDomainScriptServlet();
- * servletHost.addServletMapping(domainURI.toString(),
- * scaDomainServlet); } // Add this service to the scadomain script
- * servlet scaDomainServlet.addService(binding.getName());
- */
+ int port;
+ servletHost.addServletMapping(binding.getURI(), serviceServlet);
+ URI uri = URI.create(binding.getURI());
+ port = uri.getPort();
+ if (port == -1) {
+ port = 8080;
+ }
+
+ // get the ScaDomainScriptServlet, if it doesn't yet exist create one
+ // this uses removeServletMapping / addServletMapping as theres no getServletMapping facility
+ URI domainURI = URI.create("http://localhost:" + port + SCA_DOMAIN_SCRIPT);
+ ScaDomainScriptServlet scaDomainServlet =
+ (ScaDomainScriptServlet)servletHost.getServletMapping(domainURI.toString());
+ if (scaDomainServlet == null) {
+ scaDomainServlet = new ScaDomainScriptServlet();
+ servletHost.addServletMapping(domainURI.toString(), scaDomainServlet);
+ }
+ // Add this service to the scadomain script servlet
+ scaDomainServlet.addService(binding.getName());
+
}
@@ -128,24 +137,26 @@
// remove the servlet mapping from servletHost
servletHost.removeServletMapping(uri);
- // TODO add support for scaDomain.js
// unregister service from scaDomain.js
+ int port;
+ servletHost.removeServletMapping(binding.getURI());
+ URI uri = URI.create(binding.getURI());
+ port = uri.getPort();
+ if (port == -1) {
+ port = 8080;
+ }
- /*
- * // Unregister from the service servlet mapping int port;
- * servletHost.removeServletMapping(binding.getURI()); URI uri =
- * URI.create(binding.getURI()); port = uri.getPort(); if (port == -1)
- * port = 8080; // Unregister the service from the scaDomain script
- * servlet URI domainURI = URI.create("http://localhost:" + port +
- * SCA_DOMAIN_SCRIPT); ScaDomainScriptServlet scaDomainServlet =
- * (ScaDomainScriptServlet)
- * servletHost.getServletMapping(domainURI.toString()); if
- * (scaDomainServlet != null) {
- * scaDomainServlet.removeService(binding.getName()); // Remove the
- * servlet if there's no more registered services if
- * (scaDomainServlet.getServiceNames().isEmpty()) {
- * servletHost.removeServletMapping(domainURI.toString()); } }
- */
+ // Unregister the service from the scaDomain script servlet
+ URI domainURI = URI.create("http://localhost:" + port + SCA_DOMAIN_SCRIPT);
+ ScaDomainScriptServlet scaDomainServlet = (ScaDomainScriptServlet) servletHost.getServletMapping(domainURI.toString());
+ if (scaDomainServlet != null) {
+ scaDomainServlet.removeService(binding.getName());
+
+ // Remove the servlet if there's no more registered services
+ if (scaDomainServlet.getServiceNames().isEmpty()) {
+ servletHost.removeServletMapping(domainURI.toString());
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org