org.springframework.remoting.jaxrpc
Class JaxRpcPortClientInterceptor

java.lang.Object
  extended byorg.springframework.remoting.jaxrpc.LocalJaxRpcServiceFactory
      extended byorg.springframework.remoting.jaxrpc.JaxRpcPortClientInterceptor
All Implemented Interfaces:
Advice, InitializingBean, Interceptor, MethodInterceptor
Direct Known Subclasses:
JaxRpcPortProxyFactoryBean

public class JaxRpcPortClientInterceptor
extends LocalJaxRpcServiceFactory
implements MethodInterceptor, InitializingBean

Interceptor for accessing a specific port of a JAX-RPC service. Uses either LocalJaxRpcServiceFactory's facilities underneath, or takes an explicit reference to an existing JAX-RPC Service instance (for example looked up via JndiObjectFactoryBean).

Allows to set JAX-RPC's standard stub properties directly, via the "username", "password", "endpointAddress" and "maintainSession" properties. For typical usage, it is not necessary to specify those, though.

This invoker is typically used with an RMI service interface. Alternatively, this invoker can also proxy a JAX-RPC service with a matching non-RMI business interface, i.e. an interface that mirrors the RMI service methods but does not declare RemoteExceptions. In the latter case, RemoteExceptions thrown by the JAX-RPC stub will automatically get converted to Spring's unchecked RemoteAccessException.

If exposing the JAX-RPC port interface (i.e. an RMI interface) directly, setting "serviceInterface" is sufficient. If exposing a non-RMI business interface, the business interface needs to be set as "serviceInterface", and the JAX-RPC port interface as "portInterface".

Since:
15.12.2003
Author:
Juergen Hoeller
See Also:
setPortName(java.lang.String), setServiceInterface(java.lang.Class), setPortInterface(java.lang.Class), Service.getPort(javax.xml.namespace.QName, java.lang.Class), Stub, RemoteAccessException, JndiObjectFactoryBean

Field Summary
 
Fields inherited from class org.springframework.remoting.jaxrpc.LocalJaxRpcServiceFactory
logger
 
Constructor Summary
JaxRpcPortClientInterceptor()
           
 
Method Summary
 void afterPropertiesSet()
          Create and initialize the JAX-RPC stub for the specified port.
 Properties getCustomProperties()
          Return custom properties to be set on the stub for the port.
 String getEndpointAddress()
          Return the endpoint address to specify on the stub.
 Service getJaxRpcService()
          Return a reference to an existing JAX-RPC Service instance, if any.
 String getPassword()
          Return the password to specify on the stub.
 Class getPortInterface()
          Return the JAX-RPC port interface to use.
 String getPortName()
          Return the name of the port.
protected  Remote getPortStub()
          Return the underlying JAX-RPC port stub that this interceptor delegates to for each method invocation on the proxy.
 Class getServiceInterface()
          Return the interface of the service that this factory should create a proxy for.
 String getUsername()
          Return the username to specify on the stub.
 Object invoke(MethodInvocation invocation)
           
 boolean isMaintainSession()
          Return the maintain session flag to specify on the stub.
protected  void postProcessJaxRpcService(Service service)
          Post-process the given JAX-RPC Service.
protected  void postProcessPortStub(Stub portStub)
          Post-process the given JAX-RPC port stub.
 void setCustomProperties(Properties customProperties)
          Set custom properties to be set on the stub for the port.
 void setEndpointAddress(String endpointAddress)
          Set the endpoint address to specify on the stub.
 void setJaxRpcService(Service jaxRpcService)
          Set a reference to an existing JAX-RPC Service instance, for example looked up via JndiObjectFactoryBean.
 void setMaintainSession(boolean maintainSession)
          Set the maintain session flag to specify on the stub.
 void setPassword(String password)
          Set the password to specify on the stub.
 void setPortInterface(Class portInterface)
          Set the JAX-RPC port interface to use.
 void setPortName(String portName)
          Set the name of the port.
 void setServiceInterface(Class serviceInterface)
          Set the interface of the service that this factory should create a proxy for.
 void setUsername(String username)
          Set the username to specify on the stub.
 
Methods inherited from class org.springframework.remoting.jaxrpc.LocalJaxRpcServiceFactory
createJaxRpcService, createServiceFactory, getNamespaceUri, getQName, getServiceFactoryClass, getServiceName, getWsdlDocumentUrl, setNamespaceUri, setServiceFactoryClass, setServiceName, setWsdlDocumentUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxRpcPortClientInterceptor

public JaxRpcPortClientInterceptor()
Method Detail

setJaxRpcService

public void setJaxRpcService(Service jaxRpcService)
Set a reference to an existing JAX-RPC Service instance, for example looked up via JndiObjectFactoryBean. If not set, LocalJaxRpcServiceFactory's properties have to be specified.

See Also:
LocalJaxRpcServiceFactory.setServiceFactoryClass(java.lang.Class), LocalJaxRpcServiceFactory.setWsdlDocumentUrl(java.net.URL), LocalJaxRpcServiceFactory.setNamespaceUri(java.lang.String), LocalJaxRpcServiceFactory.setServiceName(java.lang.String), JndiObjectFactoryBean

getJaxRpcService

public Service getJaxRpcService()
Return a reference to an existing JAX-RPC Service instance, if any.


setPortName

public void setPortName(String portName)
Set the name of the port. Corresponds to the "wsdl:port" name.


getPortName

public String getPortName()
Return the name of the port.


setUsername

public void setUsername(String username)
Set the username to specify on the stub.

See Also:
Stub.USERNAME_PROPERTY

getUsername

public String getUsername()
Return the username to specify on the stub.


setPassword

public void setPassword(String password)
Set the password to specify on the stub.

See Also:
Stub.PASSWORD_PROPERTY

getPassword

public String getPassword()
Return the password to specify on the stub.


setEndpointAddress

public void setEndpointAddress(String endpointAddress)
Set the endpoint address to specify on the stub.

See Also:
Stub.ENDPOINT_ADDRESS_PROPERTY

getEndpointAddress

public String getEndpointAddress()
Return the endpoint address to specify on the stub.


setMaintainSession

public void setMaintainSession(boolean maintainSession)
Set the maintain session flag to specify on the stub.

See Also:
Stub.SESSION_MAINTAIN_PROPERTY

isMaintainSession

public boolean isMaintainSession()
Return the maintain session flag to specify on the stub.


setCustomProperties

public void setCustomProperties(Properties customProperties)
Set custom properties to be set on the stub for the port.

See Also:
Stub._setProperty(java.lang.String, java.lang.Object)

getCustomProperties

public Properties getCustomProperties()
Return custom properties to be set on the stub for the port.


setServiceInterface

public void setServiceInterface(Class serviceInterface)
Set the interface of the service that this factory should create a proxy for. Can be different from the JAX-RPC port interface, if using a non-RMI business interface for exposed proxies.

The interface must be suitable for a JAX-RPC port, if "portInterface" is not set. Else, it must match the methods in the port interface but can be a non-RMI business interface.

See Also:
setPortInterface(java.lang.Class)

getServiceInterface

public Class getServiceInterface()
Return the interface of the service that this factory should create a proxy for.


setPortInterface

public void setPortInterface(Class portInterface)
Set the JAX-RPC port interface to use. Only needs to be set if the exposed service interface is different from the port interface, i.e. when using a non-RMI business interface as service interface for exposed proxies.

The interface must be suitable for a JAX-RPC port, i.e. it must be an RMI service interface (that extends java.rmi.Remote).

See Also:
setServiceInterface(java.lang.Class), Remote

getPortInterface

public Class getPortInterface()
Return the JAX-RPC port interface to use.


afterPropertiesSet

public void afterPropertiesSet()
                        throws ServiceException
Create and initialize the JAX-RPC stub for the specified port.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
ServiceException

postProcessJaxRpcService

protected void postProcessJaxRpcService(Service service)
Post-process the given JAX-RPC Service. Called by afterPropertiesSet. Useful for example to register custom type mappings.

Just applied when creating a JAX-RPC Service instance locally, i.e. not applied when an existing Service reference is passed in.

Parameters:
service - the current JAX-RPC Service
See Also:
afterPropertiesSet(), setJaxRpcService(javax.xml.rpc.Service), Service.getTypeMappingRegistry()

postProcessPortStub

protected void postProcessPortStub(Stub portStub)
Post-process the given JAX-RPC port stub. Called by afterPropertiesSet.

Parameters:
portStub - the current JAX-RPC port stub
See Also:
afterPropertiesSet()

getPortStub

protected Remote getPortStub()
Return the underlying JAX-RPC port stub that this interceptor delegates to for each method invocation on the proxy.


invoke

public Object invoke(MethodInvocation invocation)
              throws Throwable
Specified by:
invoke in interface MethodInterceptor
Throws:
Throwable


Copyright (C) 2003-2004 The Spring Framework Project.