@SuppressWarnings("unchecked") private static <I extends Renderable, O> Renderer<I, O> instantiate(final RendererBeanDescriptor<?> descriptor) { final Class<? extends Renderer<?, ?>> componentClass = descriptor.getComponentClass(); final Renderer<?, ?> renderer = ReflectionUtils.newInstance(componentClass); return (Renderer<I, O>) renderer; }
@Initialize public void init() { final ClassLoader parent = getClass().getClassLoader(); _groovyClassLoader = new GroovyClassLoader(parent); logger.debug("Compiling Groovy code:\n{}", code); final Class<?> groovyClass = _groovyClassLoader.parseClass(code); _groovyObject = (GroovyObject) ReflectionUtils.newInstance(groovyClass); }
@Initialize public void init() { final ClassLoader parent = getClass().getClassLoader(); _groovyClassLoader = new GroovyClassLoader(parent); logger.debug("Compiling Groovy code:\n{}", code); final Class<?> groovyClass = _groovyClassLoader.parseClass(code); _groovyObject = (GroovyObject) ReflectionUtils.newInstance(groovyClass); }
@Override public Set<ComponentCategory> getComponentCategories() { final Categorized categorized = getAnnotation(Categorized.class); if (categorized == null) { return Collections.emptySet(); } final Class<? extends ComponentCategory>[] value = categorized.value(); if (value == null || value.length == 0) { return Collections.emptySet(); } final Set<ComponentCategory> result = new HashSet<>(); for (final Class<? extends ComponentCategory> categoryClass : value) { if (categoryClass != ComponentCategory.class) { final ComponentCategory category = ReflectionUtils.newInstance(categoryClass); result.add(category); } } return result; }
@Initialize public void init() { final ClassLoader parent = getClass().getClassLoader(); _groovyClassLoader = new GroovyClassLoader(parent); logger.debug("Compiling Groovy code:\n{}", code); final Class<?> groovyClass = _groovyClassLoader.parseClass(code); _groovyObject = (GroovyObject) ReflectionUtils.newInstance(groovyClass); _groovyObject.invokeMethod("initialize", new Object[] {}); }
@Initialize public void init() { final ClassLoader parent = getClass().getClassLoader(); _groovyClassLoader = new GroovyClassLoader(parent); logger.debug("Compiling Groovy code:\n{}", code); final Class<?> groovyClass = _groovyClassLoader.parseClass(code); _groovyObject = (GroovyObject) ReflectionUtils.newInstance(groovyClass); _groovyObject.invokeMethod("initialize", new Object[] {}); }
public UserDatabaseDriver loadDriver() throws IllegalStateException { if (!_loaded) { final ClassLoader driverClassLoader = ClassLoaderUtils.createClassLoader(_files); final Class<?> loadedClass; try { loadedClass = Class.forName(_driverClassName, true, driverClassLoader); } catch (final Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new IllegalStateException("Could not load driver class", e); } logger.info("Loaded class: {}", loadedClass.getName()); if (ReflectionUtils.is(loadedClass, Driver.class)) { _driverInstance = (Driver) ReflectionUtils.newInstance(loadedClass); _registeredDriver = new DriverWrapper(_driverInstance); try { DriverManager.registerDriver(_registeredDriver); } catch (final SQLException e) { throw new IllegalStateException("Could not register driver", e); } } else { throw new IllegalStateException("Class is not a Driver class: " + _driverClassName); } _loaded = true; } return this; }
@Override public ComponentSuperCategory getComponentSuperCategory() { final Categorized categorized = getAnnotation(Categorized.class); Class<? extends ComponentSuperCategory> superCategoryClass; if (categorized == null) { superCategoryClass = getDefaultComponentSuperCategoryClass(); } else { superCategoryClass = categorized.superCategory(); if (superCategoryClass == ComponentSuperCategory.class) { superCategoryClass = getDefaultComponentSuperCategoryClass(); } } return ReflectionUtils.newInstance(superCategoryClass); }
final Class<? extends Converter<?>> converterClass = convertable.value(); @SuppressWarnings("unchecked") final Converter<Object> converter = (Converter<Object>) ReflectionUtils.newInstance(converterClass); return SerializationStringEscaper.escape(converter.toString(instance)); } catch (final Exception e) {
private Map<String, String> overrideVariables(VariableProviderDefinition variableProviderDef, JobContext job, ExecutionLog execution, DataCleanerConfiguration configuration) throws ClassNotFoundException { if (variableProviderDef == null) { return null; } final String className = variableProviderDef.getClassName(); if (className == null) { return null; } final LifeCycleHelper lifeCycleHelper = new LifeCycleHelper(configuration, null, true); @SuppressWarnings("unchecked") final Class<? extends VariableProvider> cls = (Class<? extends VariableProvider>) Class.forName(className); final ComponentDescriptor<? extends VariableProvider> descriptor = Descriptors.ofComponent(cls); final VariableProvider variableProvider = ReflectionUtils.newInstance(cls); lifeCycleHelper.assignProvidedProperties(descriptor, variableProvider); lifeCycleHelper.initialize(descriptor, variableProvider); try { final Map<String, String> variableOverrides = variableProvider.provideValues(job, execution); lifeCycleHelper.close(descriptor, variableProvider, true); return variableOverrides; } catch (RuntimeException e) { lifeCycleHelper.close(descriptor, variableProvider, false); throw e; } } }
@SuppressWarnings("unchecked") final E result = ReflectionUtils.newInstance((Class<E>) foundClass);
final Class<? extends Converter<?>> converterClass = convertable.value(); @SuppressWarnings("unchecked") final Converter<Object> converter = (Converter<Object>) ReflectionUtils.newInstance(converterClass); return converter.fromString(type, serializedForm); } catch (final Exception e) {