Package jadex.bridge.service.component
Class BasicServiceInvocationHandler
- java.lang.Object
- 
- jadex.bridge.service.component.BasicServiceInvocationHandler
 
- 
- All Implemented Interfaces:
- ISwitchCall,- java.lang.reflect.InvocationHandler
 
 public class BasicServiceInvocationHandler extends java.lang.Object implements java.lang.reflect.InvocationHandler, ISwitchCall Basic service invocation interceptor. It has a multi collection of interceptors per method. Executes the list of interceptors one by one. In case no handler can be found a fallback handler is used.
- 
- 
Field SummaryFields Modifier and Type Field Description protected IInternalAccesscompThe internal access.protected java.util.List<IServiceInvocationInterceptor>interceptorsThe list of interceptors.protected java.util.logging.LoggerloggerThe logger for errors/warnings.protected static java.util.Map<java.lang.Object,IService>pojoproxiesThe pojo service map (pojo -> proxy).static java.lang.StringPROXYTYPE_DECOUPLEDThe (default) decoupled proxy type (decouples from caller thread to component thread).static java.lang.StringPROXYTYPE_DIRECTThe direct proxy type (supports custom interceptors, but uses caller thread).static java.lang.StringPROXYTYPE_RAWThe raw proxy type (i.e.protected booleanrequiredThe flag if the proxy is required (provided otherwise).protected java.lang.ObjectserviceThe service.protected IServiceIdentifiersidThe service identifier.protected booleanswitchcallThe flag if a switchcall should be done.
 - 
Constructor SummaryConstructors Constructor Description BasicServiceInvocationHandler(IInternalAccess comp, ServiceInfo service, java.util.logging.Logger logger)Create a new invocation handler.BasicServiceInvocationHandler(IInternalAccess comp, IServiceIdentifier sid, java.util.logging.Logger logger, boolean required)Create a new invocation handler.BasicServiceInvocationHandler(IInternalAccess comp, IService service, java.util.logging.Logger logger, boolean required)Create a new invocation handler.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFirstServiceInterceptor(IServiceInvocationInterceptor interceptor)Add an interceptor.static voidaddPojoServiceProxy(java.lang.Object pojo, IService proxy)Add a service proxy.protected static voidaddProvidedInterceptors(BasicServiceInvocationHandler handler, java.lang.Object service, IServiceInvocationInterceptor[] ics, IInternalAccess ia, java.lang.String proxytype, boolean monitoring, IServiceIdentifier sid)Add the standard and custom interceptors.voidaddServiceInterceptor(IServiceInvocationInterceptor interceptor)Add an interceptor.voidaddServiceInterceptor(IServiceInvocationInterceptor interceptor, int pos)Add an interceptor.static IInternalServicecreateDelegationProvidedServiceProxy(IInternalAccess ia, IServiceIdentifier sid, RequiredServiceInfo info, RequiredServiceBinding binding, java.lang.ClassLoader classloader, boolean realtime)Static method for creating a delegation service proxy for provided service that is not offered by the component itself.protected static BasicServiceInvocationHandlercreateProvidedHandler(java.lang.String name, IInternalAccess ia, java.lang.Class<?> type, java.lang.Object service, ProvidedServiceInfo info, ServiceScope scope)Create a basic invocation handler for a provided service.static IInternalServicecreateProvidedServiceProxy(IInternalAccess ia, java.lang.Object service, java.lang.String name, java.lang.Class<?> type, java.lang.String proxytype, IServiceInvocationInterceptor[] ics, boolean monitoring, ProvidedServiceInfo info, ServiceScope scope)Static method for creating a standard service proxy for a provided service.static IServicecreateRequiredServiceProxy(IInternalAccess ia, IService service, IRequiredServiceFetcher fetcher, RequiredServiceInfo info, RequiredServiceBinding binding, boolean realtime)Static method for creating a standard service proxy for a required service.booleanequals(java.lang.Object obj)Test if two objects are equal.java.lang.ObjectgetDomainService()Get the domain service.IServiceInvocationInterceptor[]getInterceptors()Get interceptors.static IServicegetPojoServiceProxy(java.lang.Object pojo)Get the proxy of a pojo service.java.lang.ObjectgetService()Get the service.IServiceIdentifiergetServiceIdentifier()Get the sid.inthashCode()Return the hash code.java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)A proxy method has been invoked.static booleanisProvidedServiceProxy(java.lang.Object service)Test if a service is a provided service proxy.booleanisRequired()Check if the handler is for a required service proxy.static booleanisRequiredServiceProxy(java.lang.Object service)Test if a service is a required service proxy.booleanisSwitchCall()Check if a switch call should be done.static voidremovePojoServiceProxy(IServiceIdentifier sid)Remove a pojo - proxy pair.voidremoveServiceInterceptor(IServiceInvocationInterceptor interceptor)Remove an interceptor.java.lang.StringtoString()Get a string representation.
 
- 
- 
- 
Field Detail- 
PROXYTYPE_RAWpublic static final java.lang.String PROXYTYPE_RAW The raw proxy type (i.e. no proxy).- See Also:
- Constant Field Values
 
 - 
PROXYTYPE_DIRECTpublic static final java.lang.String PROXYTYPE_DIRECT The direct proxy type (supports custom interceptors, but uses caller thread).- See Also:
- Constant Field Values
 
 - 
PROXYTYPE_DECOUPLEDpublic static final java.lang.String PROXYTYPE_DECOUPLED The (default) decoupled proxy type (decouples from caller thread to component thread).- See Also:
- Constant Field Values
 
 - 
compprotected IInternalAccess comp The internal access.
 - 
sidprotected IServiceIdentifier sid The service identifier.
 - 
serviceprotected java.lang.Object service The service.
 - 
loggerprotected java.util.logging.Logger logger The logger for errors/warnings.
 - 
interceptorsprotected java.util.List<IServiceInvocationInterceptor> interceptors The list of interceptors.
 - 
requiredprotected boolean required The flag if the proxy is required (provided otherwise).
 - 
switchcallprotected boolean switchcall The flag if a switchcall should be done.
 - 
pojoproxiesprotected static java.util.Map<java.lang.Object,IService> pojoproxies The pojo service map (pojo -> proxy).
 
- 
 - 
Constructor Detail- 
BasicServiceInvocationHandlerpublic BasicServiceInvocationHandler(IInternalAccess comp, IServiceIdentifier sid, java.util.logging.Logger logger, boolean required) Create a new invocation handler.
 - 
BasicServiceInvocationHandlerpublic BasicServiceInvocationHandler(IInternalAccess comp, IService service, java.util.logging.Logger logger, boolean required) Create a new invocation handler.
 - 
BasicServiceInvocationHandlerpublic BasicServiceInvocationHandler(IInternalAccess comp, ServiceInfo service, java.util.logging.Logger logger) Create a new invocation handler.
 
- 
 - 
Method Detail- 
invokepublic java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.ThrowableA proxy method has been invoked.- Specified by:
- invokein interface- java.lang.reflect.InvocationHandler
- Throws:
- java.lang.Throwable
 
 - 
getServiceIdentifierpublic IServiceIdentifier getServiceIdentifier() Get the sid.- Returns:
- the sid.
 
 - 
getServicepublic java.lang.Object getService() Get the service.- Returns:
- The service.
 
 - 
getDomainServicepublic java.lang.Object getDomainService() Get the domain service.- Returns:
- The domain service.
 
 - 
addFirstServiceInterceptorpublic void addFirstServiceInterceptor(IServiceInvocationInterceptor interceptor) Add an interceptor. Must be synchronized as invoke() is called from arbitrary threads.
 - 
addServiceInterceptorpublic void addServiceInterceptor(IServiceInvocationInterceptor interceptor, int pos) Add an interceptor. Must be synchronized as invoke() is called from arbitrary threads.
 - 
addServiceInterceptorpublic void addServiceInterceptor(IServiceInvocationInterceptor interceptor) Add an interceptor. Must be synchronized as invoke() is called from arbitrary threads.
 - 
removeServiceInterceptorpublic void removeServiceInterceptor(IServiceInvocationInterceptor interceptor) Remove an interceptor. Must be synchronized as invoke() is called from arbitrary threads.
 - 
getInterceptorspublic IServiceInvocationInterceptor[] getInterceptors() Get interceptors. Must be synchronized as invoke() is called from arbitrary threads.
 - 
hashCodepublic int hashCode() Return the hash code.- Overrides:
- hashCodein class- java.lang.Object
 
 - 
equalspublic boolean equals(java.lang.Object obj) Test if two objects are equal.- Overrides:
- equalsin class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() Get a string representation.- Overrides:
- toStringin class- java.lang.Object
 
 - 
createProvidedServiceProxypublic static IInternalService createProvidedServiceProxy(IInternalAccess ia, java.lang.Object service, java.lang.String name, java.lang.Class<?> type, java.lang.String proxytype, IServiceInvocationInterceptor[] ics, boolean monitoring, ProvidedServiceInfo info, ServiceScope scope) Static method for creating a standard service proxy for a provided service.
 - 
createProvidedHandlerprotected static BasicServiceInvocationHandler createProvidedHandler(java.lang.String name, IInternalAccess ia, java.lang.Class<?> type, java.lang.Object service, ProvidedServiceInfo info, ServiceScope scope) Create a basic invocation handler for a provided service.
 - 
addProvidedInterceptorsprotected static void addProvidedInterceptors(BasicServiceInvocationHandler handler, java.lang.Object service, IServiceInvocationInterceptor[] ics, IInternalAccess ia, java.lang.String proxytype, boolean monitoring, IServiceIdentifier sid) Add the standard and custom interceptors.
 - 
createDelegationProvidedServiceProxypublic static IInternalService createDelegationProvidedServiceProxy(IInternalAccess ia, IServiceIdentifier sid, RequiredServiceInfo info, RequiredServiceBinding binding, java.lang.ClassLoader classloader, boolean realtime) Static method for creating a delegation service proxy for provided service that is not offered by the component itself.
 - 
createRequiredServiceProxypublic static IService createRequiredServiceProxy(IInternalAccess ia, IService service, IRequiredServiceFetcher fetcher, RequiredServiceInfo info, RequiredServiceBinding binding, boolean realtime) Static method for creating a standard service proxy for a required service.
 - 
addPojoServiceProxypublic static void addPojoServiceProxy(java.lang.Object pojo, IService proxy)Add a service proxy.- Parameters:
- pojo- The pojo.
- proxy- The proxy.
 
 - 
removePojoServiceProxypublic static void removePojoServiceProxy(IServiceIdentifier sid) Remove a pojo - proxy pair.- Parameters:
- sid- The service identifier.
 
 - 
getPojoServiceProxypublic static IService getPojoServiceProxy(java.lang.Object pojo) Get the proxy of a pojo service.- Parameters:
- pojo- The pojo service.
- Returns:
- The proxy of the service.
 
 - 
isSwitchCallpublic boolean isSwitchCall() Check if a switch call should be done.- Specified by:
- isSwitchCallin interface- ISwitchCall
- Returns:
- True, if switch should be done.
 
 - 
isRequiredpublic boolean isRequired() Check if the handler is for a required service proxy.
 - 
isRequiredServiceProxypublic static boolean isRequiredServiceProxy(java.lang.Object service) Test if a service is a required service proxy.- Parameters:
- service- The service.
- Returns:
- True, if is required service proxy.
 
 - 
isProvidedServiceProxypublic static boolean isProvidedServiceProxy(java.lang.Object service) Test if a service is a provided service proxy.- Parameters:
- service- The service.
- Returns:
- True, if is provided service proxy.
 
 
- 
 
-