Class ServiceRegistry

java.lang.Object
org.apache.felix.framework.ServiceRegistry

public class ServiceRegistry extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • getRegisteredServices

      public ServiceReference<?>[] getRegisteredServices(Bundle bundle)
      Get all service references for a bundle
      Parameters:
      bundle -
      Returns:
      List with all valid service references or null.
    • registerService

      public ServiceRegistration<?> registerService(Bundle bundle, String[] classNames, Object svcObj, Dictionary<?,?> dict)
      Register a new service Caller must fire service event as this method is not doing it!
      Parameters:
      bundle - The bundle registering the service
      classNames - The service class names
      svcObj - The service object
      dict - Optional service properties
      Returns:
      Service registration
    • unregisterService

      public void unregisterService(Bundle bundle, ServiceRegistration<?> reg)
      Unregister a service
      Parameters:
      bundle - The bundle unregistering the service
      reg - The service registration
    • ungetServices

      private void ungetServices(ServiceReference<?> ref)
    • unregisterServices

      public void unregisterServices(Bundle bundle)
      This method retrieves all services registrations for the specified bundle and invokes ServiceRegistration.unregister() on each one. This method is only called be the framework to clean up after a stopped bundle.
      Parameters:
      bundle - the bundle whose services should be unregistered.
    • getServiceReferences

      public Collection<ServiceReference<?>> getServiceReferences(String className, SimpleFilter filter)
    • getServicesInUse

      public ServiceReference<?>[] getServicesInUse(Bundle bundle)
    • getService

      public <S> S getService(Bundle bundle, ServiceReference<S> ref, boolean isServiceObjects)
    • incrementToPositiveValue

      private void incrementToPositiveValue(AtomicLong al)
    • checkCountOverflow

      private void checkCountOverflow(long c)
    • ungetService

      public boolean ungetService(Bundle bundle, ServiceReference<?> ref, Object svcObj)
    • ungetServices

      public void ungetServices(Bundle bundle)
      This is a utility method to release all services being used by the specified bundle.
      Parameters:
      bundle - the bundle whose services are to be released.
    • getUsingBundles

      public Bundle[] getUsingBundles(ServiceReference<?> ref)
    • servicePropertiesModified

      void servicePropertiesModified(ServiceRegistration<?> reg, Dictionary<String,?> oldProps)
    • getLogger

      public Logger getLogger()
    • obtainUsageCount

      ServiceRegistry.UsageCount obtainUsageCount(Bundle bundle, ServiceReference<?> ref, Object svcObj, Boolean isPrototype)
      Obtain a UsageCount object, by looking for an existing one or creating a new one (if possible). This method tries to find a UsageCount object in the m_inUseMap. If one is found then this is returned, otherwise a UsageCount object will be created, but this can only be done if the isPrototype parameter is not null. If isPrototype is TRUE then a new UsageCount object will always be created.
      Parameters:
      bundle - The bundle using the service.
      ref - The Service Reference.
      svcObj - A Service Object, if applicable.
      isPrototype - TRUE if we know that this is a prototype, invalid input: '{@' FALSE} if we know that it isn't. There are cases where we don't know (the pure lookup case), in that case use null.
      Returns:
      The UsageCount object if it could be obtained, or null otherwise.
    • flushUsageCount

      void flushUsageCount(Bundle bundle, ServiceReference<?> ref, ServiceRegistry.UsageCount uc)
      Utility method to flush the specified bundle's usage count for the specified service reference. This should be called to completely remove the associated usage count object for the specified service reference. If the goal is to simply decrement the usage, then get the usage count and decrement its counter. This method will also remove the specified bundle from the "in use" map if it has no more usage counts after removing the usage count for the specified service reference.
      Parameters:
      bundle - The bundle whose usage count should be removed.
      ref - The service reference whose usage count should be removed.
    • getHookRegistry

      public HookRegistry getHookRegistry()