net.sourceforge.hiveutils.service.impl
Class AdapterProxyFactoryHelper
java.lang.Object
net.sourceforge.hiveutils.service.impl.AdapterProxyFactoryHelper
public final class AdapterProxyFactoryHelper
- extends java.lang.Object
Utility class to create a proxy object around a service implementation, in
order to catch any exception thrown by the implementation and throw
another exception, according to application developer-supplied rules.
As a matter of fact, such proxy creation also enables to make a POJO service
implementation with no service interface usable by Hivemind, by just creating
an interface with all public methods of the POJO.
- Author:
- Jean-Francois Poilpret
Method Summary |
static java.lang.Object |
createProxy(java.lang.Class serviceInterface,
java.lang.Object service,
java.util.Map methodsMapping,
ExceptionMapper exceptionMapper)
Creates a proxy of type serviceInterface , wrapping
service implementation class, and translating any
exception thrown by service into another exception through
mapper . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
createProxy
public static java.lang.Object createProxy(java.lang.Class serviceInterface,
java.lang.Object service,
java.util.Map methodsMapping,
ExceptionMapper exceptionMapper)
- Creates a proxy of type
serviceInterface
, wrapping
service
implementation class, and translating any
exception thrown by service
into another exception through
mapper
.
- Parameters:
serviceInterface
- the interface that the proxy must implement;
service
does not have to implement that interface or any
interface at all.service
- the actual service implementation class to be proxiedmethodsMapping
- a map from serviceInterface
methods to
service
methods to be used to perform the method mapping
from one class to the otherexceptionMapper
- the instance to perform the mappping of any thrown
Throwable
into another one.
- Returns:
- the proxied service that implements
serviceInterface
and delegates calls to service