Package jadex.bridge.service
Class BasicService
- java.lang.Object
- 
- jadex.bridge.service.BasicService
 
- 
- All Implemented Interfaces:
- IInternalService,- IService
 - Direct Known Subclasses:
- BDIAgentFactory,- BDIXComponentFactory,- BpmnFactory,- MicroAgentFactory,- MicroserviceFactory
 
 public class BasicService extends java.lang.Object implements IInternalService Basic service provide a simple default isValid() implementation that returns true after start service and false afterwards.
- 
- 
Field SummaryFields Modifier and Type Field Description protected static longidcntThe id counter.protected java.lang.Class<?>impltypeprotected IInternalAccessinternalaccessInternal access to its component.protected IComponentIdentifierprovideridThe provider id.protected booleanshutdownedThe shutdowned state.protected IServiceIdentifiersidThe service id.protected booleanstartedThe started state.protected java.lang.Class<?>type- 
Fields inherited from interface jadex.bridge.service.IServiceEMPTY_SERVICES
 
- 
 - 
Constructor SummaryConstructors Constructor Description BasicService(IComponentIdentifier providerid, java.lang.Class<?> type, java.lang.Class<?> impltype, java.util.Map<java.lang.String,java.lang.Object> properties)Create a new service.BasicService(IComponentIdentifier providerid, java.lang.Class<?> type, java.util.Map<java.lang.String,java.lang.Object> properties)Create a new service.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ServiceIdentifiercreateServiceIdentifier(IComponentIdentifier providerid, ClassInfo type, ClassInfo[] supertypes, java.lang.String servicename, IResourceIdentifier rid, ServiceScope scope, java.util.Set<java.lang.String> networknames, boolean unrestricted)Create a new service identifier for a potentially remote component.static IServiceIdentifiercreateServiceIdentifier(IInternalAccess provider, java.lang.String servicename, java.lang.Class<?> servicetype, java.lang.Class<?> serviceimpl, IResourceIdentifier rid, ServiceScope scope)Create a new service identifier for the own component.booleanequals(java.lang.Object obj)Check if the service is equal.static java.lang.StringgenerateServiceName(java.lang.Class<?> service)Generate a unique name.java.lang.Class<?>getInterfaceType()Get the interface type.IInternalAccessgetInternalAccess()Get the internal access.static java.lang.reflect.MethodgetInvokeMethod(java.lang.Class<?> target, java.lang.ClassLoader cl, java.lang.String methodname, ClassInfo[] argtypes)Get method that should be invoked on target object.IFuture<MethodInfo[]>getMethodInfos()Get reflective info about the service methods, args, return types.static longgetMethodTimeout(java.lang.Class<?>[] interfaces, java.lang.reflect.Method method, boolean remote)Get the default timeout for a method.java.util.Map<java.lang.String,java.lang.Object>getPropertyMap()Get a service property.IComponentIdentifiergetProviderId()Get the providerid.IServiceIdentifiergetServiceId()Get the service id.inthashCode()Get the hashcode.protected IFuture<java.lang.Void>initNFProperties()Init the non-functional properties (todo: move to other location?)IFuture<java.lang.Object>invokeMethod(java.lang.String methodname, ClassInfo[] argtypes, java.lang.Object[] args, ClassInfo rettype)Invoke a method reflectively.IFuture<java.lang.Boolean>isValid()Test if the service is valid.IFuture<java.lang.Void>setComponentAccess(IInternalAccess access)Sets the access for the component.voidsetPropertyMap(java.util.Map<java.lang.String,java.lang.Object> properties)Set the properties.voidsetServiceIdentifier(IServiceIdentifier sid)Set the service identifier.IFuture<java.lang.Void>shutdownService()Shutdown the service.IFuture<java.lang.Void>startService()Start the service.java.lang.StringtoString()Get a string representation.
 
- 
- 
- 
Field Detail- 
idcntprotected static long idcnt The id counter.
 - 
internalaccessprotected IInternalAccess internalaccess Internal access to its component.
 - 
startedprotected volatile boolean started The started state.
 - 
shutdownedprotected volatile boolean shutdowned The shutdowned state.
 - 
sidprotected IServiceIdentifier sid The service id.
 - 
provideridprotected IComponentIdentifier providerid The provider id.
 - 
typeprotected java.lang.Class<?> type 
 - 
impltypeprotected java.lang.Class<?> impltype 
 
- 
 - 
Constructor Detail- 
BasicServicepublic BasicService(IComponentIdentifier providerid, java.lang.Class<?> type, java.util.Map<java.lang.String,java.lang.Object> properties) Create a new service.
 - 
BasicServicepublic BasicService(IComponentIdentifier providerid, java.lang.Class<?> type, java.lang.Class<?> impltype, java.util.Map<java.lang.String,java.lang.Object> properties) Create a new service.
 
- 
 - 
Method Detail- 
isValidpublic IFuture<java.lang.Boolean> isValid() Test if the service is valid.
 - 
setServiceIdentifierpublic void setServiceIdentifier(IServiceIdentifier sid) Set the service identifier.- Specified by:
- setServiceIdentifierin interface- IInternalService
 
 - 
getServiceIdpublic IServiceIdentifier getServiceId() Get the service id.- Specified by:
- getServiceIdin interface- IService
- Returns:
- The service id.
 
 - 
invokeMethodpublic IFuture<java.lang.Object> invokeMethod(java.lang.String methodname, ClassInfo[] argtypes, java.lang.Object[] args, ClassInfo rettype) Invoke a method reflectively.- Specified by:
- invokeMethodin interface- IService
- 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.
 
 - 
getMethodInfospublic IFuture<MethodInfo[]> getMethodInfos() Get reflective info about the service methods, args, return types.- Specified by:
- getMethodInfosin interface- IService
- Returns:
- The method infos.
 
 - 
getInvokeMethodpublic static java.lang.reflect.Method getInvokeMethod(java.lang.Class<?> target, java.lang.ClassLoader cl, java.lang.String methodname, ClassInfo[] argtypes)Get method that should be invoked on target object.
 - 
getProviderIdpublic IComponentIdentifier getProviderId() Get the providerid.- Returns:
- the providerid.
 
 - 
setComponentAccesspublic IFuture<java.lang.Void> setComponentAccess(IInternalAccess access) Sets the access for the component.- Specified by:
- setComponentAccessin interface- IInternalService
- Parameters:
- access- Component access.
 
 - 
initNFPropertiesprotected IFuture<java.lang.Void> initNFProperties() Init the non-functional properties (todo: move to other location?)
 - 
getPropertyMappublic java.util.Map<java.lang.String,java.lang.Object> getPropertyMap() Get a service property.- Specified by:
- getPropertyMapin interface- IService
- Returns:
- The service property (if any).
 
 - 
setPropertyMappublic void setPropertyMap(java.util.Map<java.lang.String,java.lang.Object> properties) Set the properties.- Parameters:
- properties- The properties to set.
 
 - 
startServicepublic IFuture<java.lang.Void> startService() Start the service.- Specified by:
- startServicein interface- IInternalService
- Returns:
- A future that is done when the service has completed starting.
 
 - 
shutdownServicepublic IFuture<java.lang.Void> shutdownService() Shutdown the service.- Specified by:
- shutdownServicein interface- IInternalService
- Returns:
- A future that is done when the service has completed its shutdown.
 
 - 
generateServiceNamepublic static java.lang.String generateServiceName(java.lang.Class<?> service) Generate a unique name.- Parameters:
- The- calling service class.
 
 - 
createServiceIdentifierpublic static IServiceIdentifier createServiceIdentifier(IInternalAccess provider, java.lang.String servicename, java.lang.Class<?> servicetype, java.lang.Class<?> serviceimpl, IResourceIdentifier rid, ServiceScope scope) Create a new service identifier for the own component.
 - 
createServiceIdentifierpublic static ServiceIdentifier createServiceIdentifier(IComponentIdentifier providerid, ClassInfo type, ClassInfo[] supertypes, java.lang.String servicename, IResourceIdentifier rid, ServiceScope scope, java.util.Set<java.lang.String> networknames, boolean unrestricted) Create a new service identifier for a potentially remote component.
 - 
getInternalAccesspublic IInternalAccess getInternalAccess() Get the internal access.
 - 
equalspublic boolean equals(java.lang.Object obj) Check if the service is equal. The service is considered equal if the service identifiers match.- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- obj- Object of comparison.
- Returns:
- True, if the object is a service with a matching service identifier.
 
 - 
hashCodepublic int hashCode() Get the hashcode.- Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() Get a string representation.- Overrides:
- toStringin class- java.lang.Object
 
 - 
getMethodTimeoutpublic static long getMethodTimeout(java.lang.Class<?>[] interfaces, java.lang.reflect.Method method, boolean remote)Get the default timeout for a method.
 - 
getInterfaceTypepublic java.lang.Class<?> getInterfaceType() Get the interface type.- Returns:
- The interface type.
 
 
- 
 
-