Class DefaultAggregatorFactory
- java.lang.Object
-
- com.tangosol.coherence.rest.util.aggregator.DefaultAggregatorFactory
-
- All Implemented Interfaces:
AggregatorFactory
public class DefaultAggregatorFactory extends Object implements AggregatorFactory
The default implementation ofAggregatorFactory
.This
AggregatorFactory
implementation is used for aggregators that accept a singleValueExtractor
argument in the constructor and require no additional configuration.- Author:
- vp 2011.07.07, ic 2011.07.14
-
-
Constructor Summary
Constructors Constructor Description DefaultAggregatorFactory(Class clzAggr)
Construct a DefaultAggregatorFactory instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected InvocableMap.EntryAggregator
createAggregator(ValueExtractor extractor)
Create and initialize a new aggregator instance.InvocableMap.EntryAggregator
getAggregator(String... asArgs)
Return an aggregator instantiated by calling an aggregator class constructor.protected Constructor
getConstructor(Constructor[] aCtors)
Search the given constructors for a constructor that accepts a singleValueExtractor
parameter.
-
-
-
Constructor Detail
-
DefaultAggregatorFactory
public DefaultAggregatorFactory(Class clzAggr)
Construct a DefaultAggregatorFactory instance.- Parameters:
clzAggr
- the aggregator class
-
-
Method Detail
-
getAggregator
public InvocableMap.EntryAggregator getAggregator(String... asArgs)
Return an aggregator instantiated by calling an aggregator class constructor. The invoked constructor is matched using the following rules:- If the argument array is empty and a constructor that accepts a
single
ValueExtractor
parameter exists, it will be invoked with anIdentityExtractor
instance. - If the argument array is empty and a constructor that accepts a
single
ValueExtractor
parameter does not exists, the default constructor is invoked. - If the argument array size is 1 and a constructor that accepts a
single
ValueExtractor
parameter exists, it will be invoked with an MVEL-based ValueExtractor implementation. - If none of the above rules are matched, an exception is thrown.
- Specified by:
getAggregator
in interfaceAggregatorFactory
- Parameters:
asArgs
- aggregator configuration arguments- Returns:
- an aggregator instance
- Throws:
IllegalArgumentException
- if an appropriate constructor cannot be found
- If the argument array is empty and a constructor that accepts a
single
-
createAggregator
protected InvocableMap.EntryAggregator createAggregator(ValueExtractor extractor)
Create and initialize a new aggregator instance.- Parameters:
extractor
-ValueExtractor
to use for a constructor parameter- Returns:
- an aggregator instance
-
getConstructor
protected Constructor getConstructor(Constructor[] aCtors)
Search the given constructors for a constructor that accepts a singleValueExtractor
parameter. If found, return the constructor; otherwise return the public default constructor, if available.- Parameters:
aCtors
- constructor array- Returns:
- constructor that accepts a single ValueExtractor parameter or, if such a constructor is not found, the public default constructor if available
-
-