Spring Framework

org.springframework.remoting.jaxws
Class JaxWsPortClientInterceptor

java.lang.Object
  extended by org.springframework.remoting.jaxws.LocalJaxWsServiceFactory
      extended by org.springframework.remoting.jaxws.JaxWsPortClientInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, Aware, BeanClassLoaderAware, InitializingBean
Direct Known Subclasses:
JaxWsPortProxyFactoryBean

public class JaxWsPortClientInterceptor
extends LocalJaxWsServiceFactory
implements org.aopalliance.intercept.MethodInterceptor, BeanClassLoaderAware, InitializingBean

MethodInterceptor for accessing a specific port of a JAX-WS service. Compatible with JAX-WS 2.0, 2.1 and 2.2.

Uses either LocalJaxWsServiceFactory's facilities underneath, or takes an explicit reference to an existing JAX-WS Service instance (e.g. obtained via JndiObjectFactoryBean).

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

Constructor Summary
JaxWsPortClientInterceptor()
           
 
Method Summary
 void addCustomProperty(java.lang.String name, java.lang.Object value)
          Add a custom property to this JAX-WS BindingProvider.
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
protected  void applyDefaultsFromAnnotation(javax.jws.WebService ann)
          Initialize this client interceptor's properties from the given WebService annotation, if necessary and possible (i.e.
protected  java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation invocation)
          Perform a JAX-WS service invocation based on the given method invocation.
protected  java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation invocation, java.lang.Object portStub)
          Perform a JAX-WS service invocation on the given port stub.
protected  java.lang.ClassLoader getBeanClassLoader()
          Return the bean ClassLoader to use for this interceptor.
 java.util.Map<java.lang.String,java.lang.Object> getCustomProperties()
          Allow Map access to the custom properties to be set on the stub, with the option to add or override specific entries.
 java.lang.String getEndpointAddress()
          Return the endpoint address to specify on the stub.
 javax.xml.ws.Service getJaxWsService()
          Return a reference to an existing JAX-WS Service instance, if any.
 java.lang.String getPassword()
          Return the password to specify on the stub.
 java.lang.String getPortName()
          Return the name of the port.
protected  javax.xml.namespace.QName getPortQName()
          Return the prepared QName for the port.
protected  java.lang.Object getPortStub()
          Return the underlying JAX-WS port stub that this interceptor delegates to for each method invocation on the proxy.
protected  java.lang.Object getPortStub(javax.xml.ws.Service service, javax.xml.namespace.QName portQName)
          Obtain the port stub from the given JAX-WS Service.
 java.lang.Class<?> getServiceInterface()
          Return the interface of the service that this factory should create a proxy for.
 java.lang.String getSoapActionUri()
          Return the SOAP action URI to specify on the stub.
 java.lang.String getUsername()
          Return the username to specify on the stub.
 java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
           
 boolean isMaintainSession()
          Return the "session.maintain" flag to specify on the stub.
protected  boolean isPrepared()
          Return whether this client interceptor has already been prepared, i.e.
 boolean isUseSoapAction()
          Return the "soapaction.use" flag to specify on the stub.
 void prepare()
          Initialize the JAX-WS port for this interceptor.
protected  void preparePortStub(java.lang.Object stub)
          Prepare the given JAX-WS port stub, applying properties to it.
 void setBeanClassLoader(java.lang.ClassLoader classLoader)
          Set the bean ClassLoader to use for this interceptor: for resolving WebServiceFeature class names as specified through setWebServiceFeatures(java.lang.Object[]), and also for building a client proxy in the JaxWsPortProxyFactoryBean subclass.
 void setCustomProperties(java.util.Map<java.lang.String,java.lang.Object> customProperties)
          Set custom properties to be set on the stub.
 void setEndpointAddress(java.lang.String endpointAddress)
          Set the endpoint address to specify on the stub.
 void setJaxWsService(javax.xml.ws.Service jaxWsService)
          Set a reference to an existing JAX-WS Service instance, for example obtained via JndiObjectFactoryBean.
 void setLookupServiceOnStartup(boolean lookupServiceOnStartup)
          Set whether to look up the JAX-WS service on startup.
 void setMaintainSession(boolean maintainSession)
          Set the "session.maintain" flag to specify on the stub.
 void setPassword(java.lang.String password)
          Set the password to specify on the stub.
 void setPortName(java.lang.String portName)
          Set the name of the port.
 void setServiceInterface(java.lang.Class<?> serviceInterface)
          Set the interface of the service that this factory should create a proxy for.
 void setSoapActionUri(java.lang.String soapActionUri)
          Set the SOAP action URI to specify on the stub.
 void setUsername(java.lang.String username)
          Set the username to specify on the stub.
 void setUseSoapAction(boolean useSoapAction)
          Set the "soapaction.use" flag to specify on the stub.
 void setWebServiceFeatures(java.lang.Object[] webServiceFeatures)
          Allows for providing JAX-WS 2.1 WebServiceFeature specifications: in the form of actual WebServiceFeature objects, WebServiceFeature Class references, or WebServiceFeature class names.
 
Methods inherited from class org.springframework.remoting.jaxws.LocalJaxWsServiceFactory
createJaxWsService, getNamespaceUri, getQName, getServiceName, getWsdlDocumentUrl, setExecutor, setHandlerResolver, setNamespaceUri, setServiceName, setWsdlDocumentUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxWsPortClientInterceptor

public JaxWsPortClientInterceptor()
Method Detail

setJaxWsService

public void setJaxWsService(javax.xml.ws.Service jaxWsService)
Set a reference to an existing JAX-WS Service instance, for example obtained via JndiObjectFactoryBean. If not set, LocalJaxWsServiceFactory's properties have to be specified.

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

getJaxWsService

public javax.xml.ws.Service getJaxWsService()
Return a reference to an existing JAX-WS Service instance, if any.


setPortName

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


getPortName

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


setUsername

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

See Also:
BindingProvider.USERNAME_PROPERTY

getUsername

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


setPassword

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

See Also:
BindingProvider.PASSWORD_PROPERTY

getPassword

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


setEndpointAddress

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

See Also:
BindingProvider.ENDPOINT_ADDRESS_PROPERTY

getEndpointAddress

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


setMaintainSession

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

See Also:
BindingProvider.SESSION_MAINTAIN_PROPERTY

isMaintainSession

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


setUseSoapAction

public void setUseSoapAction(boolean useSoapAction)
Set the "soapaction.use" flag to specify on the stub.

See Also:
BindingProvider.SOAPACTION_USE_PROPERTY

isUseSoapAction

public boolean isUseSoapAction()
Return the "soapaction.use" flag to specify on the stub.


setSoapActionUri

public void setSoapActionUri(java.lang.String soapActionUri)
Set the SOAP action URI to specify on the stub.

See Also:
BindingProvider.SOAPACTION_URI_PROPERTY

getSoapActionUri

public java.lang.String getSoapActionUri()
Return the SOAP action URI to specify on the stub.


setCustomProperties

public void setCustomProperties(java.util.Map<java.lang.String,java.lang.Object> customProperties)
Set custom properties to be set on the stub.

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

See Also:
BindingProvider.getRequestContext()

getCustomProperties

public java.util.Map<java.lang.String,java.lang.Object> getCustomProperties()
Allow Map access to the custom properties to be set on the stub, with the option to add or override specific entries.

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


addCustomProperty

public void addCustomProperty(java.lang.String name,
                              java.lang.Object value)
Add a custom property to this JAX-WS BindingProvider.

Parameters:
name - the name of the attribute to expose
value - the attribute value to expose
See Also:
BindingProvider.getRequestContext()

setWebServiceFeatures

public void setWebServiceFeatures(java.lang.Object[] webServiceFeatures)
Allows for providing JAX-WS 2.1 WebServiceFeature specifications: in the form of actual WebServiceFeature objects, WebServiceFeature Class references, or WebServiceFeature class names.


setServiceInterface

public void setServiceInterface(java.lang.Class<?> serviceInterface)
Set the interface of the service that this factory should create a proxy for.


getServiceInterface

public java.lang.Class<?> getServiceInterface()
Return the interface of the service that this factory should create a proxy for.


setLookupServiceOnStartup

public void setLookupServiceOnStartup(boolean lookupServiceOnStartup)
Set whether to look up the JAX-WS service on startup.

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


setBeanClassLoader

public void setBeanClassLoader(java.lang.ClassLoader classLoader)
Set the bean ClassLoader to use for this interceptor: for resolving WebServiceFeature class names as specified through setWebServiceFeatures(java.lang.Object[]), and also for building a client proxy in the JaxWsPortProxyFactoryBean subclass.

Specified by:
setBeanClassLoader in interface BeanClassLoaderAware
Parameters:
classLoader - the owning class loader; may be null in which case a default ClassLoader must be used, for example the ClassLoader obtained via ClassUtils.getDefaultClassLoader()

getBeanClassLoader

protected java.lang.ClassLoader getBeanClassLoader()
Return the bean ClassLoader to use for this interceptor.


afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean

prepare

public void prepare()
Initialize the JAX-WS port for this interceptor.


applyDefaultsFromAnnotation

protected void applyDefaultsFromAnnotation(javax.jws.WebService ann)
Initialize this client interceptor's properties from the given WebService annotation, if necessary and possible (i.e. if "wsdlDocumentUrl", "namespaceUri", "serviceName" and "portName" haven't been set but corresponding values are declared at the annotation level of the specified service interface).

Parameters:
ann - the WebService annotation found on the specified service interface

isPrepared

protected boolean isPrepared()
Return whether this client interceptor has already been prepared, i.e. has already looked up the JAX-WS service and port.


getPortQName

protected final javax.xml.namespace.QName getPortQName()
Return the prepared QName for the port.

See Also:
setPortName(java.lang.String), LocalJaxWsServiceFactory.getQName(java.lang.String)

getPortStub

protected java.lang.Object getPortStub(javax.xml.ws.Service service,
                                       javax.xml.namespace.QName portQName)
Obtain the port stub from the given JAX-WS Service.

Parameters:
service - the Service object to obtain the port from
portQName - the name of the desired port, if specified
Returns:
the corresponding port object as returned from Service.getPort(...)

preparePortStub

protected void preparePortStub(java.lang.Object stub)
Prepare the given JAX-WS port stub, applying properties to it. Called by prepare().

Parameters:
stub - the current JAX-WS port stub
See Also:
setUsername(java.lang.String), setPassword(java.lang.String), setEndpointAddress(java.lang.String), setMaintainSession(boolean), setCustomProperties(java.util.Map)

getPortStub

protected java.lang.Object getPortStub()
Return the underlying JAX-WS port stub that this interceptor delegates to for each method invocation on the proxy.


invoke

public java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
                        throws java.lang.Throwable
Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Throws:
java.lang.Throwable

doInvoke

protected java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation invocation)
                             throws java.lang.Throwable
Perform a JAX-WS service invocation based on the given method invocation.

Parameters:
invocation - the AOP method invocation
Returns:
the invocation result, if any
Throws:
java.lang.Throwable - in case of invocation failure
See Also:
getPortStub(), doInvoke(org.aopalliance.intercept.MethodInvocation, Object)

doInvoke

protected java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation invocation,
                                    java.lang.Object portStub)
                             throws java.lang.Throwable
Perform a JAX-WS 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:
java.lang.Throwable - in case of invocation failure
See Also:
getPortStub()

Spring Framework