Class RequiredServicesComponentFeature

    • Constructor Detail

      • RequiredServicesComponentFeature

        public RequiredServicesComponentFeature​(IInternalAccess component,
                                                ComponentCreationInfo cinfo)
        Factory method constructor for instance level.
    • Method Detail

      • init

        public IFuture<java.lang.Void> init()
        Init the required services
        Specified by:
        init in interface IComponentFeature
        Overrides:
        init in class jadex.bridge.component.impl.AbstractComponentFeature
      • hasUserBody

        public boolean hasUserBody()
        Check if the feature potentially executed user code in body. Allows blocking operations in user bodies by using separate steps for each feature. Non-user-body-features are directly executed for speed. If unsure just return true. ;-)
        Specified by:
        hasUserBody in interface IComponentFeature
        Overrides:
        hasUserBody in class jadex.bridge.component.impl.AbstractComponentFeature
      • shutdown

        public IFuture<java.lang.Void> shutdown()
        Called when the feature is shutdowned.
        Specified by:
        shutdown in interface IComponentFeature
        Overrides:
        shutdown in class jadex.bridge.component.impl.AbstractComponentFeature
      • addRequiredServiceInfos

        protected void addRequiredServiceInfos​(RequiredServiceInfo[] requiredservices)
        Add required services for a given prefix.
        Parameters:
        prefix - The name prefix to use.
        required - services The required services to set.
      • getService

        public <T> IFuture<T> getService​(java.lang.String name)
        Resolve a declared required service of a given name. Asynchronous method for locally as well as remotely available services.
        Specified by:
        getService in interface IRequiredServicesFeature
        Parameters:
        name - The service name.
        Returns:
        The service.
      • getService

        public <T> IFuture<T> getService​(java.lang.Class<T> type)
        Resolve a required service of a given type. Asynchronous method for locally as well as remotely available services.
        Specified by:
        getService in interface IRequiredServicesFeature
        Parameters:
        type - The service type.
        Returns:
        The service.
      • getServices

        public <T> ITerminableIntermediateFuture<T> getServices​(java.lang.String name)
        Resolve a required services of a given name. Asynchronous method for locally as well as remotely available services.
        Specified by:
        getServices in interface IRequiredServicesFeature
        Parameters:
        name - The services name.
        Returns:
        Each service as an intermediate result and a collection of services as final result.
      • getServices

        public <T> ITerminableIntermediateFuture<T> getServices​(java.lang.Class<T> type)
        Resolve a required services of a given type. Asynchronous method for locally as well as remotely available services.
        Specified by:
        getServices in interface IRequiredServicesFeature
        Parameters:
        type - The services type.
        Returns:
        Each service as an intermediate result and a collection of services as final result.
      • getLocalService

        public <T> T getLocalService​(java.lang.String name)
        Resolve a declared required service of a given name. Synchronous method only for locally available services.
        Specified by:
        getLocalService in interface IRequiredServicesFeature
        Parameters:
        name - The service name.
        Returns:
        The service.
      • getLocalService

        public <T> T getLocalService​(java.lang.Class<T> type)
        Resolve a required service of a given type. Synchronous method only for locally available services.
        Specified by:
        getLocalService in interface IRequiredServicesFeature
        Parameters:
        type - The service type.
        Returns:
        The service.
      • getLocalService0

        public <T> T getLocalService0​(java.lang.Class<T> type)
        Resolve a required service of a given type. Synchronous method only for locally available services.
        Specified by:
        getLocalService0 in interface IRequiredServicesFeature
        Parameters:
        type - The service type.
        Returns:
        The service.
      • getLocalServices

        public <T> java.util.Collection<T> getLocalServices​(java.lang.String name)
        Resolve a required services of a given name. Synchronous method only for locally available services.
        Specified by:
        getLocalServices in interface IRequiredServicesFeature
        Parameters:
        name - The services name.
        Returns:
        Each service as an intermediate result and a collection of services as final result.
      • getLocalServices

        public <T> java.util.Collection<T> getLocalServices​(java.lang.Class<T> type)
        Resolve a required services of a given type. Synchronous method only for locally available services.
        Specified by:
        getLocalServices in interface IRequiredServicesFeature
        Parameters:
        type - The services type.
        Returns:
        Each service as an intermediate result and a collection of services as final result.
      • searchService

        public <T> IFuture<T> searchService​(ServiceQuery<T> query)
        Search for matching services and provide first result.
        Specified by:
        searchService in interface IExternalRequiredServicesFeature
        Parameters:
        query - The search query.
        Returns:
        Future providing the corresponding service or ServiceNotFoundException when not found.
      • getLocalService

        public <T> T getLocalService​(ServiceQuery<T> query)
        Search for matching services and provide first result. Synchronous method only for locally available services.
        Specified by:
        getLocalService in interface IRequiredServicesFeature
        Parameters:
        query - The search query.
        Returns:
        Future providing the corresponding service or ServiceNotFoundException when not found.
      • getLocalServices

        public <T> java.util.Collection<T> getLocalServices​(ServiceQuery<T> query)
        Search for all matching services. Synchronous method only for locally available services.
        Specified by:
        getLocalServices in interface IRequiredServicesFeature
        Parameters:
        query - The search query.
        Returns:
        Future providing the corresponding services or ServiceNotFoundException when not found.
      • searchService

        public <T> IFuture<T> searchService​(ServiceQuery<T> query,
                                            long timeout)
        Performs a sustained search for a service. Attempts to find a service for a maximum duration until timeout occurs.
        Specified by:
        searchService in interface IRequiredServicesFeature
        Parameters:
        query - The search query.
        timeout - Maximum time period to search, -1 for no wait.
        Returns:
        Service matching the query, exception if service is not found.
      • addQuery

        public <T> ISubscriptionIntermediateFuture<T> addQuery​(ServiceQuery<T> query,
                                                               long timeout)
        Add a query for a declared required service. Continuously searches for matching services.
        Specified by:
        addQuery in interface IRequiredServicesFeature
        Parameters:
        name - The name of the required service declaration.
        Returns:
        Future providing the corresponding services as intermediate results.
      • addQuery

        public <T> ISubscriptionIntermediateFuture<T> addQuery​(java.lang.String name)
        Add a query for a declared required service. Continuously searches for matching services.
        Specified by:
        addQuery in interface IRequiredServicesFeature
        Parameters:
        name - The name of the required service declaration.
        Returns:
        Future providing the corresponding services as intermediate results.
      • addQuery

        public <T> ISubscriptionIntermediateFuture<T> addQuery​(java.lang.Class<T> type)
        Add a query for a declared required service. Continuously searches for matching services.
        Specified by:
        addQuery in interface IRequiredServicesFeature
        Parameters:
        type - The type of the required service declaration.
        Returns:
        Future providing the corresponding services as intermediate results.
      • getRawService

        public <T> T getRawService​(java.lang.Class<T> type)
        Get a service raw (i.e. w/o required proxy).
        Specified by:
        getRawService in interface IInternalRequiredServicesFeature
        Returns:
        null when not found.
      • processResult

        protected java.lang.Object processResult​(java.lang.Object result,
                                                 RequiredServiceInfo info)
        Parameters:
        result -
        info -
        Returns:
      • resolveLocalService

        public <T> T resolveLocalService​(ServiceQuery<T> query,
                                         RequiredServiceInfo info)
        Search for matching services and provide first result. Synchronous method only for locally available services.
        Specified by:
        resolveLocalService in interface IInternalRequiredServicesFeature
        Parameters:
        query - The search query.
        info - Used for required service proxy configuration -> null for no proxy.
        Returns:
        Future providing the corresponding service or ServiceNotFoundException when not found.
      • resolveLocalServices

        public <T> java.util.Collection<T> resolveLocalServices​(ServiceQuery<T> query,
                                                                RequiredServiceInfo info)
        Search for all matching services. Synchronous method only for locally available services.
        Specified by:
        resolveLocalServices in interface IInternalRequiredServicesFeature
        Parameters:
        query - The search query.
        info - Used for required service proxy configuration -> null for no proxy.
        Returns:
        Future providing the corresponding services or ServiceNotFoundException when not found.
      • getServiceQuery

        public <T> ServiceQuery<T> getServiceQuery​(RequiredServiceInfo info)
        When searching for declared service -> map required service declaration to service query.
      • getServiceInfo

        protected RequiredServiceInfo getServiceInfo​(java.lang.Class<?> type)
        Get the required service info for a type.
        Parameters:
        type - The required service type.
      • enhanceQuery

        protected <T> void enhanceQuery​(ServiceQuery<T> query,
                                        boolean multi)
        Enhance a query before processing. Does some necessary preprocessing and needs to be called at least once before processing the query.
        Parameters:
        query - The query to be enhanced.
      • isRemote

        public boolean isRemote​(ServiceQuery<?> query)
        Check if a query is potentially remote.
        Returns:
        True, if scope is set to a remote scope (e.g. global or network).
      • getServiceQuery

        public ServiceQuery<?> getServiceQuery​(java.lang.String name)
        Get a service query for a required service info (as defined in the agent under that name).
        Specified by:
        getServiceQuery in interface IRequiredServicesFeature
        Parameters:
        name - The name.
        Returns:
        The service query.