use of com.hazelcast.query.extractor.ValueExtractor in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors_withCustomClassLoader.
@Test
public void instantiate_extractors_withCustomClassLoader() {
// GIVEN
MapAttributeConfig iqExtractor = new MapAttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
MapAttributeConfig nameExtractor = new MapAttributeConfig("name", "com.hazelcast.query.impl.getters.ExtractorHelperTest$NameExtractor");
Config config = new Config();
// For other custom class loaders (from OSGi bundles, for example)
ClassLoader customClassLoader = getClass().getClassLoader();
config.setClassLoader(customClassLoader);
// WHEN
Map<String, ValueExtractor> extractors = instantiateExtractors(asList(iqExtractor, nameExtractor));
// THEN
assertThat(extractors.get("iq"), instanceOf(IqExtractor.class));
assertThat(extractors.get("name"), instanceOf(NameExtractor.class));
}
use of com.hazelcast.query.extractor.ValueExtractor in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors.
@Test
public void instantiate_extractors() {
// GIVEN
MapAttributeConfig iqExtractor = new MapAttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
MapAttributeConfig nameExtractor = new MapAttributeConfig("name", "com.hazelcast.query.impl.getters.ExtractorHelperTest$NameExtractor");
// WHEN
Map<String, ValueExtractor> extractors = instantiateExtractors(asList(iqExtractor, nameExtractor));
// THEN
assertThat(extractors.get("iq"), instanceOf(IqExtractor.class));
assertThat(extractors.get("name"), instanceOf(NameExtractor.class));
}
use of com.hazelcast.query.extractor.ValueExtractor in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractor.
@Test
public void instantiate_extractor() {
// GIVEN
MapAttributeConfig config = new MapAttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
// WHEN
ValueExtractor extractor = instantiateExtractor(config);
// THEN
assertThat(extractor, instanceOf(IqExtractor.class));
}
use of com.hazelcast.query.extractor.ValueExtractor in project hazelcast by hazelcast.
the class Extractors method instantiateGetter.
private Getter instantiateGetter(InternalSerializationService serializationService, Object targetObject, String attributeName) {
String attributeNameWithoutArguments = extractAttributeNameNameWithoutArguments(attributeName);
ValueExtractor valueExtractor = extractors.get(attributeNameWithoutArguments);
if (valueExtractor != null) {
Object arguments = argumentsParser.parse(extractArgumentsFromAttributeName(attributeName));
return new ExtractorGetter(serializationService, valueExtractor, arguments);
} else {
if (targetObject instanceof Data) {
if (genericPortableGetter == null) {
// will be initialised a couple of times in the worst case
genericPortableGetter = new PortableGetter(serializationService);
}
return genericPortableGetter;
} else {
return ReflectionHelper.createGetter(targetObject, attributeName);
}
}
}
Aggregations