The Spring Framework

org.springframework.remoting.support
Class RemoteExporter

java.lang.Object
  extended by org.springframework.remoting.support.RemoteExporter
All Implemented Interfaces:
BeanClassLoaderAware
Direct Known Subclasses:
BurlapExporter, HessianExporter, RemoteInvocationBasedExporter

public abstract class RemoteExporter
extends Object
implements BeanClassLoaderAware

Abstract base class for classes that export a remote service. Provides "service" and "serviceInterface" bean properties.

Note that the service interface being used will show some signs of remotability, like the granularity of method calls that it offers. Furthermore, it has to have serializable arguments etc.

Since:
26.12.2003
Author:
Juergen Hoeller

Field Summary
protected  Log logger
          Logger available to subclasses
 
Constructor Summary
RemoteExporter()
           
 
Method Summary
protected  void checkService()
          Check whether the service reference has been set.
protected  void checkServiceInterface()
          Check whether a service reference has been set, and whether it matches the specified service.
protected  ClassLoader getBeanClassLoader()
          Return the environment's bean ClassLoader, if available.
protected  String getExporterName()
          Return a short name for this exporter.
protected  Object getProxyForService()
          Get a proxy for the given service object, implementing the specified service interface.
 Object getService()
          Return the service to export.
 Class getServiceInterface()
          Return the interface of the service to export.
protected  boolean isRegisterTraceInterceptor()
          Return whether to register a RemoteInvocationTraceInterceptor for exported services.
protected  ClassLoader overrideThreadContextClassLoader()
          Override the thread context ClassLoader with the environment's bean ClassLoader if necessary, i.e. if the bean ClassLoader is not equivalent to the thread context ClassLoader already.
protected  void resetThreadContextClassLoader(ClassLoader original)
          Reset the original thread context ClassLoader if necessary.
 void setBeanClassLoader(ClassLoader classLoader)
          Callback that supplies the bean class loader to a bean instance.
 void setRegisterTraceInterceptor(boolean registerTraceInterceptor)
          Set whether to register a RemoteInvocationTraceInterceptor for exported services.
 void setService(Object service)
          Set the service to export.
 void setServiceInterface(Class serviceInterface)
          Set the interface of the service to export.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses

Constructor Detail

RemoteExporter

public RemoteExporter()
Method Detail

setService

public void setService(Object service)
Set the service to export. Typically populated via a bean reference.


getService

public Object getService()
Return the service to export.


setServiceInterface

public void setServiceInterface(Class serviceInterface)
Set the interface of the service to export. The interface must be suitable for the particular service and remoting strategy.


getServiceInterface

public Class getServiceInterface()
Return the interface of the service to export.


setRegisterTraceInterceptor

public void setRegisterTraceInterceptor(boolean registerTraceInterceptor)
Set whether to register a RemoteInvocationTraceInterceptor for exported services. Only applied when a subclass uses getProxyForService for creating the proxy to expose.

Default is "true". RemoteInvocationTraceInterceptor's most important value is that it logs exception stacktraces on the server, before propagating an exception to the client.

See Also:
getProxyForService(), RemoteInvocationTraceInterceptor

isRegisterTraceInterceptor

protected boolean isRegisterTraceInterceptor()
Return whether to register a RemoteInvocationTraceInterceptor for exported services.


setBeanClassLoader

public void setBeanClassLoader(ClassLoader classLoader)
Description copied from interface: BeanClassLoaderAware
Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean.afterPropertiesSet() method or a custom init-method.

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 ClassLoader getBeanClassLoader()
Return the environment's bean ClassLoader, if available.


checkService

protected void checkService()
                     throws IllegalArgumentException
Check whether the service reference has been set.

Throws:
IllegalArgumentException
See Also:
setService(java.lang.Object)

checkServiceInterface

protected void checkServiceInterface()
                              throws IllegalArgumentException
Check whether a service reference has been set, and whether it matches the specified service.

Throws:
IllegalArgumentException
See Also:
setServiceInterface(java.lang.Class), setService(java.lang.Object)

getProxyForService

protected Object getProxyForService()
Get a proxy for the given service object, implementing the specified service interface.

Used to export a proxy that does not expose any internals but just a specific interface intended for remote access. Furthermore, a RemoteInvocationTraceInterceptor will be registered (by default).

Returns:
the proxy
See Also:
setServiceInterface(java.lang.Class), setRegisterTraceInterceptor(boolean), RemoteInvocationTraceInterceptor

getExporterName

protected String getExporterName()
Return a short name for this exporter. Used for tracing of remote invocations.

Default is the unqualified class name (without package). Can be overridden in subclasses.

See Also:
getProxyForService(), RemoteInvocationTraceInterceptor, ClassUtils.getShortName(java.lang.String)

overrideThreadContextClassLoader

protected ClassLoader overrideThreadContextClassLoader()
Override the thread context ClassLoader with the environment's bean ClassLoader if necessary, i.e. if the bean ClassLoader is not equivalent to the thread context ClassLoader already.

Returns:
the original thread context ClassLoader, or null if not overridden

resetThreadContextClassLoader

protected void resetThreadContextClassLoader(ClassLoader original)
Reset the original thread context ClassLoader if necessary.

Parameters:
original - the original thread context ClassLoader, or null if not overridden (and hence nothing to reset)

The Spring Framework

Copyright © 2002-2007 The Spring Framework.