Package org.glassfish.hk2.utilities
Class DuplicatePostProcessor
- java.lang.Object
-
- org.glassfish.hk2.utilities.DuplicatePostProcessor
-
- All Implemented Interfaces:
PopulatorPostProcessor
- Direct Known Subclasses:
ContextDuplicatePostProcessor
@PerLookup public class DuplicatePostProcessor extends java.lang.Object implements PopulatorPostProcessor
This post-processor removes duplicate descriptors from the set of descriptors being added to the service registry.It is often the case when using a classpath that the same jar file can appear on the path more than once. For example this is often done when patching. However, if this jar contains HK2 descriptor files in it, that can mean duplicate services that are not intended to be duplicated. This service removes all duplicate descriptors from the set to be added to HK2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DuplicatePostProcessor.ImplOnlyKey
Key use for implementation only (along with descriptor type, otherwise factories eliminate themselves)
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashSet<DuplicatePostProcessor.ImplOnlyKey>
implOnlyDupSet
private DuplicatePostProcessorMode
mode
private java.util.HashSet<DescriptorImpl>
strictDupSet
-
Constructor Summary
Constructors Constructor Description DuplicatePostProcessor()
Creates a DuplicatePostProcessor with the STRICT mode for determining duplicatesDuplicatePostProcessor(DuplicatePostProcessorMode mode)
Creates a DuplicatePostProcessor with the
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DuplicatePostProcessorMode
getMode()
Returns the mode of this DuplicatePostProcessorMode of this processorprivate DescriptorImpl
implementationOnly(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl)
DescriptorImpl
process(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl)
This method can be used to alter the descriptor read in.private DescriptorImpl
strict(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl)
java.lang.String
toString()
-
-
-
Field Detail
-
mode
private final DuplicatePostProcessorMode mode
-
strictDupSet
private final java.util.HashSet<DescriptorImpl> strictDupSet
-
implOnlyDupSet
private final java.util.HashSet<DuplicatePostProcessor.ImplOnlyKey> implOnlyDupSet
-
-
Constructor Detail
-
DuplicatePostProcessor
public DuplicatePostProcessor()
Creates a DuplicatePostProcessor with the STRICT mode for determining duplicates
-
DuplicatePostProcessor
public DuplicatePostProcessor(DuplicatePostProcessorMode mode)
Creates a DuplicatePostProcessor with the- Parameters:
mode
-
-
-
Method Detail
-
getMode
public DuplicatePostProcessorMode getMode()
Returns the mode of this DuplicatePostProcessorMode of this processor- Returns:
- The mode
-
process
public DescriptorImpl process(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl)
Description copied from interface:PopulatorPostProcessor
This method can be used to alter the descriptor read in. It can also add descriptors, or remove the descriptor (by returning null). Any alterations made to the descriptor passed in will remain in effect.- Specified by:
process
in interfacePopulatorPostProcessor
- Parameters:
serviceLocator
- the ServiceLocator being populated. Will not be nulldescriptorImpl
- The descriptorImpl read from some external source. This processor can modify this descriptor fully- Returns:
- The descriptor to be added to the system. If this returns null then the descriptorImpl passed in will NOT be added to the system. Implementations may return the descriptor passed in, but do not have to. The descriptor added to the system will be the one returned from this method
-
implementationOnly
private DescriptorImpl implementationOnly(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl)
-
strict
private DescriptorImpl strict(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-