Class BasicService
java.lang.Object
jadex.providedservice.impl.service.BasicService
- All Implemented Interfaces:
IInternalService
,IService
Basic service provide a simple default isValid() implementation
that returns true after start service and false afterwards.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Security
protected static long
The id counter.protected Class
<?> protected jadex.core.impl.Component
Internal access to its component.protected jadex.core.ComponentIdentifier
The provider id.protected boolean
The shutdowned state.protected IServiceIdentifier
The service id.protected boolean
The started state.protected Class
<?> Fields inherited from interface jadex.providedservice.IService
EMPTY_SERVICES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IServiceIdentifier
createServiceIdentifier
(jadex.core.impl.Component provider, String servicename, Class<?> servicetype, Class<?> serviceimpl, ProvidedServiceInfo info) Create a new service identifier for the own component.boolean
Check if the service is equal.static String
generateServiceName
(Class<?> service) Generate a unique name.Class
<?> Get the interface type.jadex.core.impl.Component
Get the internal access.static Method
getInvokeMethod
(Class<?> target, ClassLoader cl, String methodname, jadex.common.ClassInfo[] argtypes) Get method that should be invoked on target object.jadex.future.IFuture
<jadex.common.MethodInfo[]> Get reflective info about the service methods, args, return types.static jadex.future.IFuture
<jadex.common.MethodInfo[]> getMethodInfos
(IServiceIdentifier sid, ClassLoader cl) Get reflective info about the service methods, args, return types.static long
getMethodTimeout
(Class<?>[] interfaces, Method method, boolean remote) Get the default timeout for a method.jadex.core.ComponentIdentifier
Get the providerid.static Security
getSecurityLevel
(jadex.core.impl.Component access, ProvidedServiceInfo info, Class<?> implclass, Class<?> type, Method method, IServiceIdentifier sid) Find the most specific security setting.Get the service id.int
hashCode()
Get the hashcode.jadex.future.IFuture
<Object> invokeMethod
(String methodname, jadex.common.ClassInfo[] argtypes, Object[] args, jadex.common.ClassInfo rettype) Invoke a method reflectively.static jadex.future.IFuture
<Boolean> isUnrestricted
(IServiceIdentifier sid, jadex.core.IComponent component, Method method) todo: move to some security class Check if a service method is unrestricted.jadex.future.IFuture
<Boolean> isValid()
Test if the service is valid.jadex.future.IFuture
<Void> setComponentAccess
(jadex.core.impl.Component access) Sets the access for the component.void
setPropertyMap
(Map<String, Object> properties) Set the properties.void
Set the service identifier.jadex.future.IFuture
<Void> Shutdown the service.jadex.future.IFuture
<Void> Start the service.toString()
Get a string representation.
-
Field Details
-
idcnt
protected static long idcntThe id counter. -
internalaccess
protected jadex.core.impl.Component internalaccessInternal access to its component. -
started
protected volatile boolean startedThe started state. -
shutdowned
protected volatile boolean shutdownedThe shutdowned state. -
sid
The service id. -
providerid
protected jadex.core.ComponentIdentifier provideridThe provider id. -
type
-
impltype
-
DEFAULT_SYSTEM_SECURITY
-
-
Constructor Details
-
BasicService
public BasicService(jadex.core.ComponentIdentifier providerid, Class<?> type, Map<String, Object> properties) Create a new service. -
BasicService
public BasicService(jadex.core.ComponentIdentifier providerid, Class<?> type, Class<?> impltype, Map<String, Object> properties) Create a new service.
-
-
Method Details
-
isValid
Test if the service is valid.- Returns:
- True, if service can be used.
-
setServiceIdentifier
Set the service identifier.- Specified by:
setServiceIdentifier
in interfaceIInternalService
-
getServiceId
Get the service id.- Specified by:
getServiceId
in interfaceIService
- Returns:
- The service id.
-
invokeMethod
public jadex.future.IFuture<Object> invokeMethod(String methodname, jadex.common.ClassInfo[] argtypes, Object[] args, jadex.common.ClassInfo rettype) Invoke a method reflectively.- Specified by:
invokeMethod
in interfaceIService
- Parameters:
methodname
- The method name.argtypes
- The argument types (can be null if method exists only once).args
- The arguments.rettype
- The future return type if it is a specific future.- Returns:
- The result.
-
getMethodInfos
public static jadex.future.IFuture<jadex.common.MethodInfo[]> getMethodInfos(IServiceIdentifier sid, ClassLoader cl) Get reflective info about the service methods, args, return types.- Returns:
- The method infos.
-
getMethodInfos
public jadex.future.IFuture<jadex.common.MethodInfo[]> getMethodInfos()Get reflective info about the service methods, args, return types.- Specified by:
getMethodInfos
in interfaceIService
- Returns:
- The method infos.
-
getInvokeMethod
public static Method getInvokeMethod(Class<?> target, ClassLoader cl, String methodname, jadex.common.ClassInfo[] argtypes) Get method that should be invoked on target object. -
getProviderId
public jadex.core.ComponentIdentifier getProviderId()Get the providerid.- Returns:
- the providerid.
-
setComponentAccess
Sets the access for the component.- Specified by:
setComponentAccess
in interfaceIInternalService
- Parameters:
access
- Component access.
-
setPropertyMap
Set the properties.- Parameters:
properties
- The properties to set.
-
startService
Start the service.- Specified by:
startService
in interfaceIInternalService
- Returns:
- A future that is done when the service has completed starting.
-
shutdownService
Shutdown the service.- Specified by:
shutdownService
in interfaceIInternalService
- Returns:
- A future that is done when the service has completed its shutdown.
-
generateServiceName
Generate a unique name.- Parameters:
The
- calling service class.
-
createServiceIdentifier
public static IServiceIdentifier createServiceIdentifier(jadex.core.impl.Component provider, String servicename, Class<?> servicetype, Class<?> serviceimpl, ProvidedServiceInfo info) Create a new service identifier for the own component. -
getInternalAccess
public jadex.core.impl.Component getInternalAccess()Get the internal access. -
equals
Check if the service is equal. The service is considered equal if the service identifiers match. -
hashCode
public int hashCode()Get the hashcode. -
toString
Get a string representation. -
getMethodTimeout
Get the default timeout for a method. -
getInterfaceType
Get the interface type.- Returns:
- The interface type.
-
isUnrestricted
public static jadex.future.IFuture<Boolean> isUnrestricted(IServiceIdentifier sid, jadex.core.IComponent component, Method method) todo: move to some security class Check if a service method is unrestricted. Schedules on component to check this.- Parameters:
sid
- The service id.component
- The internal access.mi
- The method info.- Returns:
- True, if is unrestricted.
-
getSecurityLevel
public static Security getSecurityLevel(jadex.core.impl.Component access, ProvidedServiceInfo info, Class<?> implclass, Class<?> type, Method method, IServiceIdentifier sid) Find the most specific security setting.
-