Class BasicService

    • Field Detail

      • idcnt

        protected static long idcnt
        The id counter.
      • internalaccess

        protected IInternalAccess internalaccess
        Internal access to its component.
      • started

        protected volatile boolean started
        The started state.
      • shutdowned

        protected volatile boolean shutdowned
        The shutdowned state.
      • type

        protected java.lang.Class<?> type
      • impltype

        protected java.lang.Class<?> impltype
    • Constructor Detail

      • BasicService

        public BasicService​(IComponentIdentifier providerid,
                            java.lang.Class<?> type,
                            java.util.Map<java.lang.String,​java.lang.Object> properties)
        Create a new service.
      • BasicService

        public 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

      • isValid

        public IFuture<java.lang.Boolean> isValid()
        Test if the service is valid.
        Specified by:
        isValid in interface IService
        Returns:
        True, if service can be used.
      • invokeMethod

        public IFuture<java.lang.Object> invokeMethod​(java.lang.String methodname,
                                                      ClassInfo[] argtypes,
                                                      java.lang.Object[] args,
                                                      ClassInfo rettype)
        Invoke a method reflectively.
        Specified by:
        invokeMethod in 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.
      • getMethodInfos

        public IFuture<MethodInfo[]> getMethodInfos()
        Get reflective info about the service methods, args, return types.
        Specified by:
        getMethodInfos in interface IService
        Returns:
        The method infos.
      • getInvokeMethod

        public 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.
      • getProviderId

        public IComponentIdentifier getProviderId()
        Get the providerid.
        Returns:
        the providerid.
      • initNFProperties

        protected IFuture<java.lang.Void> initNFProperties()
        Init the non-functional properties (todo: move to other location?)
      • getPropertyMap

        public java.util.Map<java.lang.String,​java.lang.Object> getPropertyMap()
        Get a service property.
        Specified by:
        getPropertyMap in interface IService
        Returns:
        The service property (if any).
      • setPropertyMap

        public void setPropertyMap​(java.util.Map<java.lang.String,​java.lang.Object> properties)
        Set the properties.
        Parameters:
        properties - The properties to set.
      • startService

        public IFuture<java.lang.Void> startService()
        Start the service.
        Specified by:
        startService in interface IInternalService
        Returns:
        A future that is done when the service has completed starting.
      • shutdownService

        public IFuture<java.lang.Void> shutdownService()
        Shutdown the service.
        Specified by:
        shutdownService in interface IInternalService
        Returns:
        A future that is done when the service has completed its shutdown.
      • generateServiceName

        public static java.lang.String generateServiceName​(java.lang.Class<?> service)
        Generate a unique name.
        Parameters:
        The - calling service class.
      • getInternalAccess

        public IInternalAccess getInternalAccess()
        Get the internal access.
      • equals

        public boolean equals​(java.lang.Object obj)
        Check if the service is equal. The service is considered equal if the service identifiers match.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - Object of comparison.
        Returns:
        True, if the object is a service with a matching service identifier.
      • hashCode

        public int hashCode()
        Get the hashcode.
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Get a string representation.
        Overrides:
        toString in class java.lang.Object
      • getMethodTimeout

        public static long getMethodTimeout​(java.lang.Class<?>[] interfaces,
                                            java.lang.reflect.Method method,
                                            boolean remote)
        Get the default timeout for a method.
      • getInterfaceType

        public java.lang.Class<?> getInterfaceType()
        Get the interface type.
        Returns:
        The interface type.