Package org.glassfish.hk2.extras
Class ExtrasUtilities
- java.lang.Object
-
- org.glassfish.hk2.extras.ExtrasUtilities
-
public class ExtrasUtilities extends java.lang.Object
These are utilities for the extra features of hk2. Generally they allow for
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
BRIDGE_NAME_POSTFIX
private static java.lang.String
BRIDGE_NAME_PREFIX
private static java.lang.String
COMMA
static java.lang.String
HK2BRIDGE_LOCATOR_ID
This will be put into the metadata of a descriptor that is bridged from another service locator.static java.lang.String
HK2BRIDGE_SERVICE_ID
This will be put into the metadata of a descriptor that is bridged from another service locator.
-
Constructor Summary
Constructors Constructor Description ExtrasUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
bridgeServiceLocator(ServiceLocator into, ServiceLocator from)
This method will bridge all non-local services from the from ServiceLocator into the into ServiceLocator.private static void
checkParentage(ServiceLocator a, ServiceLocator b)
static void
enableDefaultInterceptorServiceImplementation(ServiceLocator locator)
This method adds in a default implementation of theInterceptionService
which uses annotations to denote which services should intercept other services.static void
enableOperations(ServiceLocator locator)
This method adds in the infrastructure necessary to enable HK2 Operations support.static void
enableTopicDistribution(ServiceLocator locator)
This method will enable the default topic distribution service.private static java.lang.String
getBridgeName(ServiceLocator into, ServiceLocator from)
private static boolean
isDupException(MultiException me)
static void
unbridgeServiceLocator(ServiceLocator into, ServiceLocator from)
This method will remove all non-local services from the from ServiceLocator into the into ServiceLocator.
-
-
-
Field Detail
-
HK2BRIDGE_LOCATOR_ID
public static final java.lang.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:
- Constant Field Values
-
HK2BRIDGE_SERVICE_ID
public static final java.lang.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:
- Constant Field Values
-
BRIDGE_NAME_PREFIX
private static final java.lang.String BRIDGE_NAME_PREFIX
- See Also:
- Constant Field Values
-
COMMA
private static final java.lang.String COMMA
- See Also:
- Constant Field Values
-
BRIDGE_NAME_POSTFIX
private static final java.lang.String BRIDGE_NAME_POSTFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
enableDefaultInterceptorServiceImplementation
public static void enableDefaultInterceptorServiceImplementation(ServiceLocator locator)
This method adds in a default implementation of theInterceptionService
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 seeOperationManager
. 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 java.lang.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 ServiceLocatorfrom
- 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 ServiceLocatorfrom
- 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)
-
-