use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator in project ignite-3 by apache.
the class ConfigurationExtension method beforeEach.
/**
* {@inheritDoc}
*/
@Override
public void beforeEach(ExtensionContext context) throws Exception {
ConfigurationAsmGenerator cgen = new ConfigurationAsmGenerator();
context.getStore(NAMESPACE).put(CGEN_KEY, cgen);
Object testInstance = context.getRequiredTestInstance();
ExecutorService pool = context.getStore(NAMESPACE).get(POOL_KEY, ExecutorService.class);
StorageRevisionListenerHolderImpl revisionListenerHolder = new StorageRevisionListenerHolderImpl();
context.getStore(NAMESPACE).put(REVISION_LISTENER_HOLDER_KEY, revisionListenerHolder);
for (Field field : getInjectConfigurationFields(testInstance.getClass())) {
field.setAccessible(true);
InjectConfiguration annotation = field.getAnnotation(InjectConfiguration.class);
field.set(testInstance, cfgValue(field.getType(), annotation, cgen, pool, revisionListenerHolder));
}
for (Field field : getInjectRevisionListenerHolderFields(testInstance.getClass())) {
field.setAccessible(true);
field.set(testInstance, revisionListenerHolder);
}
}
use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator in project ignite-3 by apache.
the class ConfigurationExtension method resolveParameter.
/**
* {@inheritDoc}
*/
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
if (parameterContext.isAnnotated(InjectConfiguration.class)) {
Parameter parameter = parameterContext.getParameter();
ConfigurationAsmGenerator cgen = extensionContext.getStore(NAMESPACE).get(CGEN_KEY, ConfigurationAsmGenerator.class);
StorageRevisionListenerHolderImpl revisionListenerHolder = extensionContext.getStore(NAMESPACE).get(REVISION_LISTENER_HOLDER_KEY, StorageRevisionListenerHolderImpl.class);
try {
ExecutorService pool = extensionContext.getStore(NAMESPACE).get(POOL_KEY, ExecutorService.class);
return cfgValue(parameter.getType(), parameter.getAnnotation(InjectConfiguration.class), cgen, pool, revisionListenerHolder);
} catch (ClassNotFoundException classNotFoundException) {
throw new ParameterResolutionException("Cannot find a configuration schema class that matches " + parameter.getType().getCanonicalName(), classNotFoundException);
}
} else if (parameterContext.isAnnotated(InjectRevisionListenerHolder.class)) {
return extensionContext.getStore(NAMESPACE).get(REVISION_LISTENER_HOLDER_KEY, StorageRevisionListenerHolderImpl.class);
} else {
throw new ParameterResolutionException("Unknown parametr:" + parameterContext.getParameter());
}
}
use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator in project ignite-3 by apache.
the class TraversableTreeNodeTest method beforeAll.
/**
* Before all.
*/
@BeforeAll
public static void beforeAll() {
cgen = new ConfigurationAsmGenerator();
cgen.compileRootSchema(ParentConfigurationSchema.class, Map.of(), Map.of());
}
use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator in project ignite-3 by apache.
the class ConfigurationUtilTest method testGetInternalConfigs.
@Test
void testGetInternalConfigs() {
Map<Class<?>, Set<Class<?>>> internalExtensions = internalSchemaExtensions(List.of(InternalFirstRootConfigurationSchema.class, InternalSecondRootConfigurationSchema.class, InternalFirstConfigurationSchema.class, InternalSecondConfigurationSchema.class));
ConfigurationAsmGenerator generator = new ConfigurationAsmGenerator();
generator.compileRootSchema(InternalRootConfigurationSchema.class, internalExtensions, Map.of());
InnerNode innerNode = generator.instantiateNode(InternalRootConfigurationSchema.class);
addDefaults(innerNode);
Map<String, Object> config = (Map<String, Object>) innerNode.accept(null, new ConverterToMapVisitor(false));
// Check that no internal configuration will be received.
assertEquals(4, config.size());
assertNull(config.get("str0"));
assertEquals("foo", config.get("str1"));
assertNotNull(config.get("subCfg"));
assertNotNull(config.get("namedCfg"));
Map<String, Object> subConfig = (Map<String, Object>) config.get("subCfg");
assertEquals(1, subConfig.size());
assertEquals("foo", subConfig.get("str00"));
// Check that no internal configuration will be received.
config = (Map<String, Object>) innerNode.accept(null, new ConverterToMapVisitor(true));
assertEquals(7, config.size());
assertNull(config.get("str0"));
assertNull(config.get("str2"));
assertEquals("foo", config.get("str1"));
assertEquals("foo", config.get("str3"));
assertNotNull(config.get("subCfg"));
assertNotNull(config.get("subCfg1"));
assertNotNull(config.get("namedCfg"));
subConfig = (Map<String, Object>) config.get("subCfg");
assertEquals(3, subConfig.size());
assertEquals("foo", subConfig.get("str00"));
assertEquals("foo", subConfig.get("str01"));
assertEquals("foo", subConfig.get("str02"));
subConfig = (Map<String, Object>) config.get("subCfg1");
assertEquals(3, subConfig.size());
assertEquals("foo", subConfig.get("str00"));
assertEquals("foo", subConfig.get("str01"));
assertEquals("foo", subConfig.get("str02"));
}
use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator in project ignite-3 by apache.
the class ValidationUtilTest method beforeAll.
/**
* Before all.
*/
@BeforeAll
public static void beforeAll() {
cgen = new ConfigurationAsmGenerator();
cgen.compileRootSchema(ValidatedRootConfigurationSchema.class, Map.of(), Map.of());
}
Aggregations