Package org.apache.maven.impl.model
Class DefaultModelObjectPool
java.lang.Object
org.apache.maven.impl.model.DefaultModelObjectPool
- All Implemented Interfaces:
ModelObjectProcessor
Default implementation of ModelObjectProcessor that provides memory optimization
through object pooling and interning.
This implementation can pool any model object type based on configuration.
By default, it pools Dependency objects, which are frequently duplicated
in large Maven projects. Other model objects are passed through unchanged unless
explicitly configured for pooling.
The pool uses configurable reference types and provides thread-safe access through ConcurrentHashMap-based caches.
- Since:
- 4.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGet statistics for all pooled object types.static StringgetStatistics(Class<?> objectType) Get statistics for a specific object type.<T> Tprocess(T object) Process a model object, potentially returning a pooled or optimized version.
-
Constructor Details
-
DefaultModelObjectPool
public DefaultModelObjectPool()
-
-
Method Details
-
process
public <T> T process(T object) Description copied from interface:ModelObjectProcessorProcess a model object, potentially returning a pooled or optimized version.This method is called during model building for various model objects. Implementations can:
- Return the same object if no processing is desired
- Return a pooled equivalent object to reduce memory usage
- Return a modified or optimized version of the object
The implementation must ensure that the returned object is functionally equivalent to the input object from the perspective of the Maven model.
- Specified by:
processin interfaceModelObjectProcessor- Type Parameters:
T- the type of the model object- Parameters:
object- the model object to process- Returns:
- the processed object (may be the same instance, a pooled instance, or a modified instance)
-
getStatistics
Get statistics for a specific object type. Useful for monitoring and debugging. -
getAllStatistics
Get statistics for all pooled object types.
-