public class MoskitoInvokationProxy<S extends IStats>
extends java.lang.Object
implements java.lang.reflect.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(java.lang.Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory<S> factory,
java.lang.String producerId,
java.lang.String category,
java.lang.String subsystem,
java.lang.Class<?>... interfaces)
Creates a new MoskitoInvocationProxy with given implementation, handler and stats factory, and interfaces to monitor.
|
MoskitoInvokationProxy(java.lang.Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory factory,
java.lang.Class<?>... interfaces)
Creates a new MoskitoInvokationProxy.
|
MoskitoInvokationProxy(java.lang.Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory factory,
java.lang.String category,
java.lang.String subsystem,
java.lang.Class<?>... interfaces)
Creates a new MoskitoInvokationProxy.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
createProxy()
Creates the actual proxy object.
|
java.lang.Object |
createProxy(java.lang.ClassLoader classLoader)
Creates the proxy with the submitted classloader.
|
java.lang.Object |
getImplementation()
Returns the internally used implementation of the interfaces.
|
IStatsProducer |
getProducer()
Returns the producer.
|
java.lang.Object |
invoke(java.lang.Object aProxy,
java.lang.reflect.Method aMethod,
java.lang.Object[] args) |
public MoskitoInvokationProxy(java.lang.Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory<S> factory,
java.lang.String producerId,
java.lang.String category,
java.lang.String subsystem,
java.lang.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(java.lang.Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory factory,
java.lang.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(java.lang.Object anImplementation,
IOnDemandCallHandler aHandler,
IOnDemandStatsFactory factory,
java.lang.String category,
java.lang.String subsystem,
java.lang.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 java.lang.Object invoke(java.lang.Object aProxy,
java.lang.reflect.Method aMethod,
java.lang.Object[] args)
throws java.lang.Throwable
invoke in interface java.lang.reflect.InvocationHandlerjava.lang.Throwablepublic java.lang.Object createProxy()
public java.lang.Object createProxy(java.lang.ClassLoader classLoader)
classLoader - public java.lang.Object getImplementation()
public IStatsProducer getProducer()
Copyright © 2010-2020 anotheria.net. All Rights Reserved.