Class ServiceRegistry

  • All Implemented Interfaces:
    IServiceRegistry

    public class ServiceRegistry
    extends java.lang.Object
    implements IServiceRegistry
    Local service registry. - Search fetches services by types and excludes some according to the scope. - Allows for adding persistent queries.
    • Field Detail

      • rwlock

        protected java.util.concurrent.locks.ReadWriteLock rwlock
        Read-Write Lock
      • proxyrwlock

        protected java.util.concurrent.locks.ReadWriteLock proxyrwlock
        Read-Write Lock for proxy map.
      • localserviceproxies

        protected java.util.Map<IServiceIdentifier,​IService> localserviceproxies
        Map for looking up local services using the service identifier.
    • Constructor Detail

      • ServiceRegistry

        public ServiceRegistry()
        Create a new registry.
    • Method Detail

      • addLocalService

        public void addLocalService​(IService service)
        Add a local service to the registry.
        Specified by:
        addLocalService in interface IServiceRegistry
        Parameters:
        service - The local service.
      • updateService

        public void updateService​(IServiceIdentifier service,
                                  java.lang.String propname)
        Updates a service if the service meta-information has changes.
        Parameters:
        service - The service (null = all).
      • getLocalService

        public IService getLocalService​(IServiceIdentifier serviceid)
        Returns the service proxy of a local service identified by service ID.
        Specified by:
        getLocalService in interface IServiceRegistry
        Parameters:
        serviceid - The service ID.
        Returns:
        The service proxy.
      • getLock

        public java.util.concurrent.locks.ReadWriteLock getLock()
        Returns the lock on the registry. Care must be taken to perform proper unlocking to avoid permanently blocking the registry. Note that the lock is reentrant, so operations can be performed while the lock is held.
        Specified by:
        getLock in interface IServiceRegistry
        Returns:
        The registry lock.
      • removeQuery

        public void removeQuery​(ServiceQuery<?> query)
        Remove a service query from the registry.
        Specified by:
        removeQuery in interface IServiceRegistry
        Parameters:
        query - ServiceQuery.
      • removeQueriesOfPlatform

        public void removeQueriesOfPlatform​(IComponentIdentifier platform)
        Remove all service queries of a specific platform from the registry.
        Specified by:
        removeQueriesOfPlatform in interface IServiceRegistry
        Parameters:
        platform - The platform from which the query owner comes.
      • checkLifecycleVisibility

        protected boolean checkLifecycleVisibility​(ServiceQuery<?> query,
                                                   IServiceIdentifier ser)
        Test if a service is visible, i.e. visible after init for all components or visible for subcomponents also during init.
        Parameters:
        query - The query.
        ser - The service.
        Returns:
        True if is included.
      • checkQueries

        protected IFuture<java.lang.Void> checkQueries​(IServiceIdentifier ser,
                                                       int eventtype)
        Check the persistent queries for a new service.
        Parameters:
        ser - The service.
        removed - Indicates if the query was removed.
      • checkRestrictions

        protected boolean checkRestrictions​(ServiceQuery<?> query,
                                            IServiceIdentifier ser)
        Check the services according additional restrictions like scope.
        Parameters:
        query - The query.
        ser - The service.
        Returns:
        True, if service passes tests.
      • checkSearchScope

        protected boolean checkSearchScope​(ServiceQuery<?> query,
                                           IServiceIdentifier ser)
        Check if service is ok with respect to search scope of caller.
      • checkPublicationScope

        protected boolean checkPublicationScope​(ServiceQuery<?> query,
                                                IServiceIdentifier ser)
        Check if service is ok with respect to publication scope.
      • getServices

        protected java.util.Set<IServiceIdentifier> getServices()
        Get all services.
        Returns:
        The services.
      • getServices

        protected java.util.Set<IServiceIdentifier> getServices​(ServiceQuery<?> query)
        Get services per query. Uses not the full query spec and does not check scope and filter.
        Parameters:
        query - The query.
        Returns:
        First matching service or null.
      • getApplicationName

        public static java.lang.String getApplicationName​(IComponentIdentifier cid)
        Get the application name. Equals the local component name in case it is a child of the platform. broadcast@awa.plat1 -> awa
        Returns:
        The application name.
      • getSubcomponentName

        public static java.lang.String getSubcomponentName​(IComponentIdentifier cid)
        Get the subcomponent name.
        Parameters:
        cid - The component id.
        Returns:
        The subcomponent name.
      • getDotName

        public static java.lang.String getDotName​(IComponentIdentifier cid)
        Get the name without @ replaced by dot.