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)
    • registerService

      public ServiceRegistration<?> registerService(BundleContext context, String[] classNames, Object svcObj, Dictionary dict)
    • unregisterService

      public void unregisterService(Bundle bundle, ServiceRegistration<?> reg)
    • 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 getServiceReferences(String className, SimpleFilter filter)
    • getServicesInUse

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

      public <S> S getService(Bundle bundle, ServiceReference<S> ref, boolean isPrototype)
    • 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 oldProps)
    • getLogger

      public Logger getLogger()
    • addServiceRegistration

      private static ServiceRegistration<?>[] addServiceRegistration(ServiceRegistration<?>[] regs, ServiceRegistration<?> reg)
    • removeServiceRegistration

      private static ServiceRegistration<?>[] removeServiceRegistration(ServiceRegistration<?>[] regs, ServiceRegistration<?> reg)
    • getUsageCount

      private ServiceRegistry.UsageCount getUsageCount(Bundle bundle, ServiceReference<?> ref, Object svcObj)
      Utility method to retrieve the specified bundle's usage count for the specified service reference.
      Parameters:
      bundle - The bundle whose usage counts are being searched.
      ref - The service reference to find in the bundle's usage counts.
      Returns:
      The associated usage count or null if not found.
    • addUsageCount

      private ServiceRegistry.UsageCount addUsageCount(Bundle bundle, ServiceReference<?> ref, boolean isPrototype)
      Utility method to update the specified bundle's usage count array to include the specified service. This method should only be called to add a usage count for a previously unreferenced service. If the service already has a usage count, then the existing usage count counter simply needs to be incremented.
      Parameters:
      bundle - The bundle acquiring the service.
      ref - The service reference of the acquired service.
      svcObj - The service object of the acquired service.
    • flushUsageCount

      private 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.
    • isHookBlackListed

      boolean isHookBlackListed(ServiceReference<?> sr)
    • blackListHook

      void blackListHook(ServiceReference<?> sr)
    • isHook

      static boolean isHook(String[] classNames, Class<?> hookClass, Object svcObj)
    • addHooks

      private void addHooks(String[] classNames, Object svcObj, ServiceReference<?> ref)
    • updateHook

      private void updateHook(ServiceReference<?> ref)
    • removeHook

      private void removeHook(ServiceReference<?> ref)
    • getHooks

      public <S> Set<ServiceReference<S>> getHooks(Class<S> hookClass)
    • asTypedSortedSet

      private static <S> SortedSet<ServiceReference<S>> asTypedSortedSet(SortedSet<ServiceReference<?>> ss)