public class

JaxRpcPortClientInterceptor

extends LocalJaxRpcServiceFactory
implements InitializingBean
java.lang.Object
   ↳ org.springframework.remoting.jaxrpc.LocalJaxRpcServiceFactory
     ↳ org.springframework.remoting.jaxrpc.JaxRpcPortClientInterceptor
Known Direct Subclasses

This class is deprecated.
in favor of JAX-WS support in org.springframework.remoting.jaxws

Class Overview

org.aopalliance.intercept.MethodInterceptor 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 (e.g. obtained via a 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.

In standard JAX-RPC style, this invoker is used with an RMI service interface. Alternatively, this invoker can also proxy a JAX-RPC service with a matching non-RMI business interface, that is, an interface that declares the service methods without RemoteExceptions. In the latter case, RemoteExceptions thrown by JAX-RPC will automatically get converted to Spring's unchecked RemoteAccessException.

Setting "serviceInterface" is usually sufficient: The invoker will automatically use JAX-RPC "dynamic invocations" via the Call API in this case, no matter whether the specified interface is an RMI or non-RMI interface. Alternatively, a corresponding JAX-RPC port interface can be specified as "portInterface", which will turn this invoker into "static invocation" mode (operating on a standard JAX-RPC port stub).

Summary

[Expand]
Inherited Fields
From class org.springframework.remoting.jaxrpc.LocalJaxRpcServiceFactory
Public Constructors
JaxRpcPortClientInterceptor()
Public Methods
void addCustomProperty(String name, Object value)
Add a custom property to this JAX-RPC Stub/Call.
void afterPropertiesSet()
Prepares the JAX-RPC service and port if the "lookupServiceOnStartup" is turned on (which it is by default).
Map<StringObject> getCustomPropertyMap()
Allow Map access to the custom properties to be set on the stub or call, with the option to add or override specific entries.
String getEndpointAddress()
Return the endpoint address to specify on the stub or call.
Service getJaxRpcService()
Return a reference to an existing JAX-RPC Service instance, if any.
String getPassword()
Return the password to specify on the stub or call.
Class getPortInterface()
Return the JAX-RPC port interface to use.
String getPortName()
Return the name of the port.
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 or call.
Object invoke(MethodInvocation invocation)
Translates the method invocation into a JAX-RPC service invocation.
boolean isMaintainSession()
Return the maintain session flag to specify on the stub or call.
void prepare()
Create and initialize the JAX-RPC service for the specified port.
void setCustomProperties(Properties customProperties)
Set custom properties to be set on the stub or call.
void setCustomPropertyMap(Map<StringObject> customProperties)
Set custom properties to be set on the stub or call.
void setEndpointAddress(String endpointAddress)
Set the endpoint address to specify on the stub or call.
void setJaxRpcService(Service jaxRpcService)
Set a reference to an existing JAX-RPC Service instance, for example obtained via JndiObjectFactoryBean.
void setLookupServiceOnStartup(boolean lookupServiceOnStartup)
Set whether to look up the JAX-RPC service on startup.
void setMaintainSession(boolean maintainSession)
Set the maintain session flag to specify on the stub or call.
void setPassword(String password)
Set the password to specify on the stub or call.
void setPortInterface(Class portInterface)
Set the JAX-RPC port interface to use.
void setPortName(String portName)
Set the name of the port.
void setRefreshServiceAfterConnectFailure(boolean refreshServiceAfterConnectFailure)
Set whether to refresh the JAX-RPC service on connect failure, that is, whenever a JAX-RPC invocation throws a RemoteException.
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 or call.
Protected Methods
boolean alwaysUseJaxRpcCall()
Return whether to always use JAX-RPC dynamic calls.
Object doInvoke(MethodInvocation invocation, Remote portStub)
Perform a JAX-RPC service invocation on the given port stub.
Object doInvoke(MethodInvocation invocation)
Perform a JAX-RPC service invocation based on the given method invocation.
final QName getPortQName()
Return the prepared QName for the port.
Remote getPortStub()
Return the underlying JAX-RPC port stub that this interceptor delegates to for each method invocation on the proxy.
Throwable handleRemoteException(Method method, RemoteException ex)
Handle the given RemoteException that was thrown from a JAX-RPC port stub or JAX-RPC call invocation.
boolean isConnectFailure(RemoteException ex)
Determine whether the given RMI exception indicates a connect failure.
boolean isPrepared()
Return whether this client interceptor has already been prepared, i.e.
Object performJaxRpcCall(MethodInvocation invocation, Service service)
Perform a JAX-RPC dynamic call for the given AOP method invocation.
void postProcessJaxRpcCall(Call call, MethodInvocation invocation)
Post-process the given JAX-RPC call.
void postProcessPortStub(Stub stub)
Post-process the given JAX-RPC port stub.
void prepareJaxRpcCall(Call call)
Prepare the given JAX-RPC call, applying properties to it.
void preparePortStub(Stub stub)
Prepare the given JAX-RPC port stub, applying properties to it.
void reset()
Reset the prepared service of this interceptor, allowing for reinitialization on next access.
[Expand]
Inherited Methods
From class org.springframework.remoting.jaxrpc.LocalJaxRpcServiceFactory
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean

Public Constructors

public JaxRpcPortClientInterceptor ()

Public Methods

public void addCustomProperty (String name, Object value)

Add a custom property to this JAX-RPC Stub/Call.

Parameters
name the name of the attribute to expose
value the attribute value to expose

public void afterPropertiesSet ()

Prepares the JAX-RPC service and port if the "lookupServiceOnStartup" is turned on (which it is by default).

public Map<StringObject> getCustomPropertyMap ()

Allow Map access to the custom properties to be set on the stub or call, with the option to add or override specific entries.

Useful for specifying entries directly, for example via "customPropertyMap[myKey]". This is particularly useful for adding or overriding entries in child bean definitions.

public String getEndpointAddress ()

Return the endpoint address to specify on the stub or call.

public Service getJaxRpcService ()

Return a reference to an existing JAX-RPC Service instance, if any.

public String getPassword ()

Return the password to specify on the stub or call.

public Class getPortInterface ()

Return the JAX-RPC port interface to use.

public String getPortName ()

Return the name of the port.

public Class getServiceInterface ()

Return the interface of the service that this factory should create a proxy for.

public String getUsername ()

Return the username to specify on the stub or call.

public Object invoke (MethodInvocation invocation)

Translates the method invocation into a JAX-RPC service invocation.

Prepares the service on the fly, if necessary, in case of lazy lookup or a connect failure having happened.

Throws
Throwable

public boolean isMaintainSession ()

Return the maintain session flag to specify on the stub or call.

public void prepare ()

Create and initialize the JAX-RPC service for the specified port.

Prepares a JAX-RPC stub if possible (if an RMI interface is available); falls back to JAX-RPC dynamic calls else. Using dynamic calls can be enforced through overriding alwaysUseJaxRpcCall() to return true.

postProcessJaxRpcService(Service) and postProcessPortStub(Stub) hooks are available for customization in subclasses. When using dynamic calls, each can be post-processed via postProcessJaxRpcCall(Call, MethodInvocation).

Throws
RemoteLookupFailureException if service initialization or port stub creation failed

public void setCustomProperties (Properties customProperties)

Set custom properties to be set on the stub or call.

Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions.

public void setCustomPropertyMap (Map<StringObject> customProperties)

Set custom properties to be set on the stub or call.

Can be populated with a "map" or "props" element in XML bean definitions.

public void setEndpointAddress (String endpointAddress)

Set the endpoint address to specify on the stub or call.

public void setJaxRpcService (Service jaxRpcService)

Set a reference to an existing JAX-RPC Service instance, for example obtained via JndiObjectFactoryBean. If not set, LocalJaxRpcServiceFactory's properties have to be specified.

public void setLookupServiceOnStartup (boolean lookupServiceOnStartup)

Set whether to look up the JAX-RPC service on startup.

Default is "true". Turn this flag off to allow for late start of the target server. In this case, the JAX-RPC service will be lazily fetched on first access.

public void setMaintainSession (boolean maintainSession)

Set the maintain session flag to specify on the stub or call.

public void setPassword (String password)

Set the password to specify on the stub or call.

public void setPortInterface (Class portInterface)

Set the JAX-RPC port interface to use. Only needs to be set if a JAX-RPC port stub should be used instead of the dynamic call mechanism. See the javadoc of the "serviceInterface" property for more details.

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

NOTE: Check whether your JAX-RPC provider returns thread-safe port stubs. If not, use the dynamic call mechanism instead, which will always be thread-safe. In particular, do not use JAX-RPC port stubs with Apache Axis, whose port stubs are known to be non-thread-safe.

public void setPortName (String portName)

Set the name of the port. Corresponds to the "wsdl:port" name.

public void setRefreshServiceAfterConnectFailure (boolean refreshServiceAfterConnectFailure)

Set whether to refresh the JAX-RPC service on connect failure, that is, whenever a JAX-RPC invocation throws a RemoteException.

Default is "false", keeping a reference to the JAX-RPC service in any case, retrying the next invocation on the same service even in case of failure. Turn this flag on to reinitialize the entire service in case of connect failures.

public void setServiceInterface (Class serviceInterface)

Set the interface of the service that this factory should create a proxy for. This will typically be a non-RMI business interface, although you can also use an RMI port interface as recommended by JAX-RPC here.

Calls on the specified service interface will either be translated to the underlying RMI port interface (in case of a "portInterface" being specified) or to dynamic calls (using the JAX-RPC Dynamic Invocation Interface).

The dynamic call mechanism has the advantage that you don't need to maintain an RMI port interface in addition to an existing non-RMI business interface. In terms of configuration, specifying the business interface as "serviceInterface" will be enough; this interceptor will automatically use dynamic calls in such a scenario.

public void setUsername (String username)

Set the username to specify on the stub or call.

Protected Methods

protected boolean alwaysUseJaxRpcCall ()

Return whether to always use JAX-RPC dynamic calls. Called by afterPropertiesSet.

Default is "false"; if an RMI interface is specified as "portInterface" or "serviceInterface", it will be used to create a JAX-RPC port stub.

Can be overridden to enforce the use of the JAX-RPC Call API, for example if there is a need to customize at the Call level. This just necessary if you you want to use an RMI interface as "serviceInterface", though; in case of only a non-RMI interface being available, this interceptor will fall back to the Call API anyway.

protected Object doInvoke (MethodInvocation invocation, Remote portStub)

Perform a JAX-RPC service invocation on the given port stub.

Parameters
invocation the AOP method invocation
portStub the RMI port stub to invoke
Returns
  • the invocation result, if any
Throws
Throwable in case of invocation failure
See Also

protected Object doInvoke (MethodInvocation invocation)

Perform a JAX-RPC service invocation based on the given method invocation.

Uses traditional RMI stub invocation if a JAX-RPC port stub is available; falls back to JAX-RPC dynamic calls else.

Parameters
invocation the AOP method invocation
Returns
  • the invocation result, if any
Throws
Throwable in case of invocation failure
See Also
  • getPortStub()
  • #doInvoke(org.aopalliance.intercept.MethodInvocation, java.rmi.Remote)
  • #performJaxRpcCall(org.aopalliance.intercept.MethodInvocation, javax.xml.rpc.Service)

protected final QName getPortQName ()

Return the prepared QName for the port.

protected Remote getPortStub ()

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

protected Throwable handleRemoteException (Method method, RemoteException ex)

Handle the given RemoteException that was thrown from a JAX-RPC port stub or JAX-RPC call invocation.

Parameters
method the service interface method that we invoked
ex the original RemoteException
Returns
  • the exception to rethrow (may be the original RemoteException or an extracted/wrapped exception, but never null)

protected boolean isConnectFailure (RemoteException ex)

Determine whether the given RMI exception indicates a connect failure.

The default implementation returns true unless the exception class name (or exception superclass name) contains the term "Fault" (e.g. "AxisFault"), assuming that the JAX-RPC provider only throws RemoteException in case of WSDL faults and connect failures.

Parameters
ex the RMI exception to check
Returns
  • whether the exception should be treated as connect failure

protected boolean isPrepared ()

Return whether this client interceptor has already been prepared, i.e. has already looked up the JAX-RPC service and port.

protected Object performJaxRpcCall (MethodInvocation invocation, Service service)

Perform a JAX-RPC dynamic call for the given AOP method invocation. Delegates to prepareJaxRpcCall(Call) and postProcessJaxRpcCall(Call, MethodInvocation) for setting up the call object.

The default implementation uses method name as JAX-RPC operation name and method arguments as arguments for the JAX-RPC call. Can be overridden in subclasses for custom operation names and/or arguments.

Parameters
invocation the current AOP MethodInvocation that should be converted to a JAX-RPC call
service the JAX-RPC Service to use for the call
Returns
  • the return value of the invocation, if any
Throws
Throwable the exception thrown by the invocation, if any

protected void postProcessJaxRpcCall (Call call, MethodInvocation invocation)

Post-process the given JAX-RPC call. Called by invoke(MethodInvocation).

The default implementation is empty.

Just applied when actually using JAX-RPC dynamic calls, i.e. if no compliant port interface was specified. Else, a JAX-RPC port stub will be used.

Parameters
call the current JAX-RPC call object (can be cast to an implementation-specific class if necessary)
invocation the current AOP MethodInvocation that the call was created for (can be used to check method name, method parameters and/or passed-in arguments)

protected void postProcessPortStub (Stub stub)

Post-process the given JAX-RPC port stub. Called by prepare().

The default implementation is empty.

Just applied when actually creating a JAX-RPC port stub, in case of a compliant port interface. Else, JAX-RPC dynamic calls will be used.

Parameters
stub the current JAX-RPC port stub (can be cast to an implementation-specific class if necessary)

protected void prepareJaxRpcCall (Call call)

Prepare the given JAX-RPC call, applying properties to it. Called by invoke(MethodInvocation).

Just applied when actually using JAX-RPC dynamic calls, i.e. if no compliant port interface was specified. Else, a JAX-RPC port stub will be used.

Parameters
call the current JAX-RPC call object

protected void preparePortStub (Stub stub)

Prepare the given JAX-RPC port stub, applying properties to it. Called by prepare().

Just applied when actually creating a JAX-RPC port stub, in case of a compliant port interface. Else, JAX-RPC dynamic calls will be used.

Parameters
stub the current JAX-RPC port stub

protected void reset ()

Reset the prepared service of this interceptor, allowing for reinitialization on next access.