public class BasicService extends java.lang.Object implements IInternalService
Modifier and Type | Field and Description |
---|---|
protected static long |
idcnt
The id counter.
|
protected java.lang.Class<?> |
impltype |
protected IInternalAccess |
internalaccess
Internal access to its component.
|
protected IComponentIdentifier |
providerid
The provider id.
|
protected boolean |
shutdowned
The shutdowned state.
|
protected IServiceIdentifier |
sid
The service id.
|
protected boolean |
started
The started state.
|
protected java.lang.Class<?> |
type |
EMPTY_SERVICES
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
boolean |
equals(java.lang.Object obj)
Check if the service is equal.
|
static java.lang.String |
generateServiceName(java.lang.Class<?> service)
Generate a unique name.
|
java.lang.Class<?> |
getInterfaceType()
Get the interface type.
|
IInternalAccess |
getInternalAccess()
Get the internal access.
|
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.
|
IFuture<MethodInfo[]> |
getMethodInfos()
Get reflective info about the service methods, args, return types.
|
static long |
getMethodTimeout(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.
|
IComponentIdentifier |
getProviderId()
Get the providerid.
|
IServiceIdentifier |
getServiceId()
Get the service id.
|
int |
hashCode()
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.
|
void |
setPropertyMap(java.util.Map<java.lang.String,java.lang.Object> properties)
Set the properties.
|
void |
setServiceIdentifier(IServiceIdentifier sid)
Set the service identifier.
|
IFuture<java.lang.Void> |
shutdownService()
Shutdown the service.
|
IFuture<java.lang.Void> |
startService()
Start the service.
|
java.lang.String |
toString()
Get a string representation.
|
protected static long idcnt
protected IInternalAccess internalaccess
protected volatile boolean started
protected volatile boolean shutdowned
protected IServiceIdentifier sid
protected IComponentIdentifier providerid
protected java.lang.Class<?> type
protected java.lang.Class<?> impltype
public BasicService(IComponentIdentifier providerid, java.lang.Class<?> type, java.util.Map<java.lang.String,java.lang.Object> properties)
public BasicService(IComponentIdentifier providerid, java.lang.Class<?> type, java.lang.Class<?> impltype, java.util.Map<java.lang.String,java.lang.Object> properties)
public IFuture<java.lang.Boolean> isValid()
public void setServiceIdentifier(IServiceIdentifier sid)
setServiceIdentifier
in interface IInternalService
public IServiceIdentifier getServiceId()
getServiceId
in interface IService
public IFuture<java.lang.Object> invokeMethod(java.lang.String methodname, ClassInfo[] argtypes, java.lang.Object[] args, ClassInfo rettype)
invokeMethod
in interface IService
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.public IFuture<MethodInfo[]> getMethodInfos()
getMethodInfos
in interface IService
public static java.lang.reflect.Method getInvokeMethod(java.lang.Class<?> target, java.lang.ClassLoader cl, java.lang.String methodname, ClassInfo[] argtypes)
public IComponentIdentifier getProviderId()
public IFuture<java.lang.Void> setComponentAccess(IInternalAccess access)
setComponentAccess
in interface IInternalService
access
- Component access.protected IFuture<java.lang.Void> initNFProperties()
public java.util.Map<java.lang.String,java.lang.Object> getPropertyMap()
getPropertyMap
in interface IService
public void setPropertyMap(java.util.Map<java.lang.String,java.lang.Object> properties)
properties
- The properties to set.public IFuture<java.lang.Void> startService()
startService
in interface IInternalService
public IFuture<java.lang.Void> shutdownService()
shutdownService
in interface IInternalService
public static java.lang.String generateServiceName(java.lang.Class<?> service)
The
- calling service class.public static IServiceIdentifier createServiceIdentifier(IInternalAccess provider, java.lang.String servicename, java.lang.Class<?> servicetype, java.lang.Class<?> serviceimpl, IResourceIdentifier rid, ServiceScope scope)
public 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)
public IInternalAccess getInternalAccess()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- Object of comparison.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static long getMethodTimeout(java.lang.Class<?>[] interfaces, java.lang.reflect.Method method, boolean remote)
public java.lang.Class<?> getInterfaceType()