Class ExtrasUtilities

java.lang.Object
org.glassfish.hk2.extras.ExtrasUtilities

public class ExtrasUtilities extends Object
These are utilities for the extra features of hk2. Generally they allow for
  • Field Details

    • HK2BRIDGE_LOCATOR_ID

      public static final String HK2BRIDGE_LOCATOR_ID
      This will be put into the metadata of a descriptor that is bridged from another service locator. The value will be the locator id of the service locator from which the service originates
      See Also:
    • HK2BRIDGE_SERVICE_ID

      public static final String HK2BRIDGE_SERVICE_ID
      This will be put into the metadata of a descriptor that is bridged from another service locator. The value will be the service id of the descriptor from which the service originates
      See Also:
    • BRIDGE_NAME_PREFIX

      private static final String BRIDGE_NAME_PREFIX
      See Also:
    • COMMA

      private static final String COMMA
      See Also:
    • BRIDGE_NAME_POSTFIX

      private static final String BRIDGE_NAME_POSTFIX
      See Also:
  • Constructor Details

    • ExtrasUtilities

      public ExtrasUtilities()
  • Method Details

    • enableDefaultInterceptorServiceImplementation

      public static void enableDefaultInterceptorServiceImplementation(ServiceLocator locator)
      This method adds in a default implementation of the InterceptionService which uses annotations to denote which services should intercept other services. For more information see the org.glassfish.hk2.extras.interception package. This method is idempotent, if the service is already available it will not add it
      Parameters:
      locator - The locator to add the default interception service implementation to. May not be null
    • enableOperations

      public static void enableOperations(ServiceLocator locator)
      This method adds in the infrastructure necessary to enable HK2 Operations support. For more information see OperationManager. This method is idempotent, if the service is already available it will not add it
      Parameters:
      locator - The locator to add the infrastructure needed to use the HK2 Operations support
    • getBridgeName

      private static String getBridgeName(ServiceLocator into, ServiceLocator from)
    • checkParentage

      private static void checkParentage(ServiceLocator a, ServiceLocator b)
    • bridgeServiceLocator

      public static void bridgeServiceLocator(ServiceLocator into, ServiceLocator from)
      This method will bridge all non-local services from the from ServiceLocator into the into ServiceLocator. Changes to the set of services in the from ServiceLocator will be reflected in the into ServiceLocator. The two ServiceLocators involved must not have a parent/child relationship
      Parameters:
      into - The non-null ServiceLocator that will have services added to it from the from ServiceLocator
      from - The non-null ServiceLocator that will add services to the into ServiceLocator
    • unbridgeServiceLocator

      public static void unbridgeServiceLocator(ServiceLocator into, ServiceLocator from)
      This method will remove all non-local services from the from ServiceLocator into the into ServiceLocator. The service locator will no longer be related by this bridge The two ServiceLocators involved must not have a parent/child relationship
      Parameters:
      into - The non-null ServiceLocator that will have services added to it from the from ServiceLocator
      from - The non-null ServiceLocator that will add services to the into ServiceLocator
    • enableTopicDistribution

      public static void enableTopicDistribution(ServiceLocator locator)
      This method will enable the default topic distribution service.

      The default distribution service distributes messages on the same thread as the caller of Topic.publish(Object). Objects to be distributed to will be held with SoftReferences, and hence if they go out of scope they will not be distributed to. Only services created AFTER the topic distribution service is enabled will be distributed to.

      This method is idempotent, so that if there is already a TopicDistributionService with the default name is available this method will do nothing

      Parameters:
      locator - The service locator to enable topic distribution on. May not be null
    • isDupException

      private static boolean isDupException(MultiException me)