|
From: Julien V. <ju...@jb...> - 2006-07-10 10:26:58
|
User: julien
Date: 06/07/10 06:26:51
Modified: wsrp/src/main/org/jboss/portal/wsrp/services
AbstractJNDIServiceFactory.java
PerEndpointSOAPInvokerServiceFactory.java
SOAPInvokerServiceFactory.java
Added: wsrp/src/main/org/jboss/portal/wsrp/services
AbstractSOAPServiceFactory.java
Log:
- introduced AbstractSOAPServiceFactory which performs lookup and caching of soap rcp service
- removed caching from the AbstractJNDIServiceFactory
- let subclasses of AbstractSOAPServiceFactory customize the stub obtained from the service
Revision Changes Path
1.2 +26 -65 jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractJNDIServiceFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AbstractJNDIServiceFactory.java 7 Jul 2006 20:02:58 -0000 1.1
+++ AbstractJNDIServiceFactory.java 10 Jul 2006 10:26:51 -0000 1.2
@@ -39,7 +39,7 @@
*
* @author <a href="mailto:ju...@jb...">Julien Viet</a>
* @author <a href="mailto:chr...@jb...">Chris Laprun</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
* @noinspection ALL
* @since 2.4
*/
@@ -55,9 +55,6 @@
/** A Map recording the mapping between WSRP port type class name and JDNI name of the implementing service. */
protected Properties portJNDIMapping;
- /** Cache the services. */
- private Map services;
-
protected void createService() throws Exception
{
for (Iterator i = env.entrySet().iterator(); i.hasNext();)
@@ -67,14 +64,6 @@
String value = (String)entry.getValue();
log.debug("Use env property " + name + "=" + value);
}
-
- //
- services = new ConcurrentReaderHashMap();
- }
-
- protected void destroyService() throws Exception
- {
- services = null;
}
public Properties getEnv()
@@ -87,20 +76,6 @@
this.env = env;
}
- /**
- * Give a chance to subclass to customize the service between the retrieval and the caching. The default
- * implementation returns the passed service.
- *
- * @param serviceClass the requested service class
- * @param service the service implementation obtained from the JNDI lookup
- * @return an implementation based on the provided service
- * @throws Exception
- */
- protected Object customizeServiceImplementation(Class serviceClass, Object service) throws Exception
- {
- return service;
- }
-
public Object getService(Class serviceClass) throws Exception
{
if (serviceClass == null)
@@ -115,11 +90,6 @@
throw new IllegalArgumentException("Unknown service class: " + key);
}
- //
- Object service = services.get(key);
- if (service == null)
- {
- //
String jndiName = (String)portJNDIMapping.get(key);
log.debug("Looking up service for class " + key + " using JNDI name " + jndiName);
if (jndiName == null)
@@ -141,18 +111,13 @@
}
//
- service = ctx.lookup(jndiName);
+ Object service = ctx.lookup(jndiName);
if (log.isTraceEnabled())
{
log.trace("JNDI lookup for " + jndiName + " returned " + service);
}
//
- if (service != null)
- {
- service = customizeServiceImplementation(serviceClass, service);
- services.put(key, service);
- }
return service;
}
finally
@@ -161,10 +126,6 @@
}
}
- //
- return service;
- }
-
public Properties getPortJNDIMapping()
{
return portJNDIMapping;
1.6 +7 -10 jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PerEndpointSOAPInvokerServiceFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- PerEndpointSOAPInvokerServiceFactory.java 7 Jul 2006 20:02:58 -0000 1.5
+++ PerEndpointSOAPInvokerServiceFactory.java 10 Jul 2006 10:26:51 -0000 1.6
@@ -32,10 +32,10 @@
/**
* @author <a href="mailto:chr...@jb...">Chris Laprun</a>
* @author <a href="mailto:ju...@jb...">Julien Viet</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
* @since 2.4
*/
-public class PerEndpointSOAPInvokerServiceFactory extends AbstractJNDIServiceFactory
+public class PerEndpointSOAPInvokerServiceFactory extends AbstractSOAPServiceFactory
{
/** . */
@@ -96,13 +96,10 @@
/**
* If retrieve object is of javax.xml.rpc.Service class, we're using the WS stack and we need to get the port.
*/
- protected Object customizeServiceImplementation(Class serviceClass, Object service) throws Exception
+ protected Object getStubFromService(Class serviceClass, Service service) throws Exception
{
- Service rpcService = (Service)service;
-
- //
- log.debug("Unwrapping service " + rpcService + " for class " + serviceClass);
- Object port = rpcService.getPort(serviceClass);
+ log.debug("Unwrapping service " + service + " for class " + serviceClass);
+ Object stub = service.getPort(serviceClass);
//
String portAddress = null;
@@ -127,7 +124,7 @@
if (portAddress != null)
{
log.debug("Setting the end point to: " + portAddress);
- ((Stub)port)._setProperty(PerEndpointSOAPInvokerServiceFactory.ENDPOINT_ADDRESS_PROP, portAddress);
+ ((Stub)stub)._setProperty(PerEndpointSOAPInvokerServiceFactory.ENDPOINT_ADDRESS_PROP, portAddress);
}
else
{
@@ -136,6 +133,6 @@
}
//
- return port;
+ return stub;
}
}
1.4 +7 -10 jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SOAPInvokerServiceFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/services/SOAPInvokerServiceFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- SOAPInvokerServiceFactory.java 7 Jul 2006 20:02:58 -0000 1.3
+++ SOAPInvokerServiceFactory.java 10 Jul 2006 10:26:51 -0000 1.4
@@ -35,10 +35,10 @@
/**
* @author <a href="mailto:chr...@jb...">Chris Laprun</a>
* @author <a href="mailto:ju...@jb...">Julien Viet</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
* @since 2.4
*/
-public class SOAPInvokerServiceFactory extends AbstractJNDIServiceFactory
+public class SOAPInvokerServiceFactory extends AbstractSOAPServiceFactory
{
/** . */
@@ -71,21 +71,18 @@
/**
* If retrieve object is of javax.xml.rpc.Service class, we're using the WS stack and we need to get the port.
*/
- protected Object customizeServiceImplementation(Class serviceClass, Object service) throws Exception
+ protected Object getStubFromService(Class serviceClass, Service service) throws Exception
{
- Service rpcService = (Service)service;
-
- //
- log.debug("Unwrapping service " + rpcService + " for class " + serviceClass);
- Object port = rpcService.getPort(serviceClass);
+ log.debug("Unwrapping service " + service + " for class " + serviceClass);
+ Object stub = service.getPort(serviceClass);
//
if (endpointURL != null)
{
String portAddress = endpointURL + PORT_NAMES.get(serviceClass);
log.debug("Setting the end point to: " + portAddress);
- ((Stub)port)._setProperty(ENDPOINT_ADDRESS_PROP, portAddress);
+ ((Stub)stub)._setProperty(ENDPOINT_ADDRESS_PROP, portAddress);
}
- return port;
+ return stub;
}
}
1.1 date: 2006/07/10 10:26:51; author: julien; state: Exp;jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java
Index: AbstractSOAPServiceFactory.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.portal.wsrp.services;
import java.util.Map;
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
import javax.xml.rpc.Service;
/**
* @author <a href="mailto:ju...@jb...">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public abstract class AbstractSOAPServiceFactory extends AbstractJNDIServiceFactory
{
/** Cache the services. */
private Map services;
protected void createService() throws Exception
{
super.createService();
//
services = new ConcurrentReaderHashMap();
}
protected void destroyService() throws Exception
{
services = null;
//
super.destroyService();
}
/**
* Retrieve the sub from the service
*
* @param serviceClass the requested service class
* @param service the service implementation obtained from the JNDI lookup
* @return an implementation based on the provided service
* @throws Exception
*/
protected abstract Object getStubFromService(Class serviceClass, Service service) throws Exception;
public Object getService(Class serviceClass) throws Exception
{
if (serviceClass == null)
{
throw new IllegalArgumentException("Null class not accepted to perform lookup");
}
//
String key = serviceClass.getName();
//
Service service = (Service)services.get(key);
if (service == null)
{
service = (Service)super.getService(serviceClass);
//
if (service != null)
{
services.put(key, service);
}
}
//
if (service != null)
{
return getStubFromService(serviceClass, service);
}
else
{
return null;
}
}
}
|