public class MoskitoInvokationProxy<S extends IStats> extends Object implements InvocationHandler
For example if you have an
public interface IImagesService {
List<Image> getImages() throws ImagesServiceException;
}
and an implementation of it : ImageServiceImpl, with whatever implementation details, and you want to monitor all calls to this impl, and you typically have an ImageServiceFactory
all you need to do is (example code):
public class ImagesServiceFactory{
private static AtomicInteger instanceCounter = new AtomicInteger(0);
public static IImagesService createImagesService(){
MoskitoInvokationProxy proxy = new MoskitoInvokationProxy(
createInstance(),
new ServiceStatsCallHandler(),
new ServiceStatsFactory(),
"IImagesService-"+instanceCounter.incrementAndGet(),
"service",
"asg",
IImagesService.class, ASGService.class
);
return (IImagesService) proxy.createProxy();
}
private static IImagesService createInstance(){
return ImagesServiceImpl.getInstance();
}
| Constructor and Description |
|---|
MoskitoInvokationProxy(Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory<S> factory,
String producerId,
String category,
String subsystem,
Class<?>... interfaces)
Creates a new MoskitoInvocationProxy with given implementation, handler and stats factory, and interfaces to monitor.
|
MoskitoInvokationProxy(Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory factory,
Class<?>... interfaces)
Creates a new MoskitoInvokationProxy.
|
MoskitoInvokationProxy(Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory factory,
String category,
String subsystem,
Class<?>... interfaces)
Creates a new MoskitoInvokationProxy.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
createProxy()
Creates the actual proxy object.
|
Object |
createProxy(ClassLoader classLoader)
Creates the proxy with the submitted classloader.
|
Object |
getImplementation()
Returns the internally used implementation of the interfaces.
|
IStatsProducer |
getProducer()
Returns the producer.
|
Object |
invoke(Object aProxy,
Method aMethod,
Object[] args) |
public MoskitoInvokationProxy(Object anImplementation, IOnDemandCallHandler aHandler, IOnDemandStatsFactory<S> factory, String producerId, String category, String subsystem, Class<?>... interfaces)
anImplementation - Implementation object for all interfaces, i.e. MyServiceImplaHandler - the call handler, i.e. net.java.dev.moskito.core.predefined.ServiceStatsCallHandlerfactory - the factory for the stats, i.e. net.java.dev.moskito.core.predefined.ServiceStatsFactoryproducerId - the id of the producer (for ui) i.e. MyService or MyService-1 ...category - the key/name/id for the monitored category i.e. service,api,controller,persistencesubsystem - the key/name/id for the monitored i.e. user,shop,messaginginterfaces - interfaces which can be called from outside, i.e. MyServicepublic MoskitoInvokationProxy(Object anImplementation, IOnDemandCallHandler aHandler, IOnDemandStatsFactory factory, Class<?>... interfaces)
anImplementation - object for monitoring. Should implement the supplied interfaces.aHandler - a handler.factory - factory for stats objects.interfaces - multiple interfaces that should be supported.public MoskitoInvokationProxy(Object anImplementation, IOnDemandCallHandler aHandler, IOnDemandStatsFactory factory, String category, String subsystem, Class<?>... interfaces)
anImplementation - object for monitoring. Should implement the supplied interfaces.aHandler - a handler.factory - factory for stats objects.category - category for presentation.subsystem - subsystem for presentation.interfaces - multiple interfaces that should be supported.public Object invoke(Object aProxy, Method aMethod, Object[] args) throws Throwable
invoke in interface InvocationHandlerThrowablepublic Object createProxy()
public Object createProxy(ClassLoader classLoader)
classLoader - public Object getImplementation()
public IStatsProducer getProducer()
Copyright © 2010-2017 anotheria.net. All Rights Reserved.