List of usage examples for org.springframework.beans BeanUtils instantiate
@Deprecated public static <T> T instantiate(Class<T> clazz) throws BeanInstantiationException
From source file:eu.openanalytics.rsb.stats.JobStatisticsHandlerFactory.java
public static JobStatisticsHandler create(final Class<? extends JobStatisticsHandler> clazz, final Map<String, Object> configuration) { if (clazz == null) { return NoopJobStatisticsHandler.INSTANCE; }//from w w w.j a v a2s . c om final JobStatisticsHandler jobStatisticsHandler = BeanUtils.instantiate(clazz); jobStatisticsHandler.setConfiguration(configuration); return jobStatisticsHandler; }
From source file:com.teradata.benchto.driver.utils.PropertiesUtils.java
public static <T> T resolveEnvironmentProperties(ConfigurableEnvironment environment, Class<T> clazz, String prefix) {//from w w w . j av a 2 s. co m try { T properties = BeanUtils.instantiate(clazz); PropertiesConfigurationFactory<T> factory = new PropertiesConfigurationFactory<T>(properties); factory.setTargetName(prefix); factory.setPropertySources(environment.getPropertySources()); factory.setConversionService(environment.getConversionService()); factory.bindPropertiesToTarget(); return properties; } catch (BindException ex) { throw new FatalBeanException("Could not bind " + clazz + " properties", ex); } }
From source file:org.grails.datastore.mapping.config.AbstractGormMappingFactory.java
@SuppressWarnings("unchecked") @Override//w ww . j a v a 2 s.c o m public R createMappedForm(PersistentEntity entity) { ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(entity.getJavaClass()); R family = BeanUtils.instantiate(getEntityMappedFormType()); MappingConfigurationBuilder builder = new MappingConfigurationBuilder(family, getPropertyMappedFormType()); Closure value = cpf.getStaticPropertyValue(GormProperties.MAPPING, Closure.class); if (value != null) { builder.evaluate(value); } value = cpf.getStaticPropertyValue(GormProperties.CONSTRAINTS, Closure.class); if (value != null) { builder.evaluate(value); } entityToPropertyMap.put(entity, builder.getProperties()); return family; }
From source file:runkoserver.integration.SeleniumTestExecutionListener.java
@Override public void prepareTestInstance(TestContext testContext) throws Exception { if (webDriver != null) { return;// www . j a v a2 s .c o m } ApplicationContext context = testContext.getApplicationContext(); if (context instanceof ConfigurableApplicationContext) { SeleniumTest annotation = findAnnotation(testContext.getTestClass(), SeleniumTest.class); webDriver = BeanUtils.instantiate(annotation.driver()); ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) context; ConfigurableListableBeanFactory bf = configurableApplicationContext.getBeanFactory(); bf.registerResolvableDependency(WebDriver.class, webDriver); } }
From source file:org.jdal.vaadin.data.ConfigurableFieldFactory.java
/** * {@inheritDoc}//from w w w .j a va2 s . co m */ public Field createField(Item item, Object propertyId, Component uiContext) { Class<Field> clazz = fieldMap.get(propertyId); if (clazz != null) { try { return BeanUtils.instantiate(clazz); } catch (BeanInstantiationException bie) { log.error(bie); } } return null; }
From source file:de.tudarmstadt.ukp.csniper.webapp.support.orm.EntityModel.java
@Override protected T load() { if (id == null || id.longValue() == 0) { return BeanUtils.instantiate(entityClass); } else {/*from w w w .jav a 2 s . c o m*/ T entity = getEntityManager().find(entityClass, id); return entity; } }
From source file:cn.fh.starter.shiro.autoconfigure.ShiroAutoConfiguration.java
@Bean(name = "realm") @DependsOn("lifecycleBeanPostProcessor") @ConditionalOnMissingBean// w w w. java 2 s. c o m public Realm realm() { Class<?> relmClass = properties.getRealm(); return (Realm) BeanUtils.instantiate(relmClass); }
From source file:org.codehaus.griffon.commons.ClassPropertyFetcher.java
public static ClassPropertyFetcher forClass(final Class<?> c, ReferenceInstanceCallback callback) { ClassPropertyFetcher cpf = cachedClassPropertyFetchers.get(c); if (cpf == null) { if (callback == null) { callback = new ReferenceInstanceCallback() { private Object o; public Object getReferenceInstance() { if (o == null) { o = BeanUtils.instantiate(c); }// ww w . j a v a2 s . c o m return o; } }; } cpf = new ClassPropertyFetcher(c, callback); cachedClassPropertyFetchers.put(c, cpf); } return cpf; }
From source file:de.tudarmstadt.ukp.clarin.webanno.support.EntityModel.java
@Override protected T load() { if (entityClass == null) { return null; }//from ww w . j a v a 2s.co m if (id == null || id.longValue() == 0) { return BeanUtils.instantiate(entityClass); } else { T entity = getEntityManager().find(entityClass, id); return entity; } }
From source file:org.appcomponents.platform.test.loader.PlatformContextLoader.java
@SuppressWarnings("unchecked") @Override/*from w w w . j a v a 2 s . com*/ protected SpringApplication getSpringApplication() { StandardAnnotationMetadata annotationMetadata = new StandardAnnotationMetadata(this.config.getTestClass()); Map<String, Object> annotationAttributes = annotationMetadata .getAnnotationAttributes(PlatformTest.class.getName()); Assert.notNull(annotationAttributes, "No PlatformTest is specified"); Class<? extends PlatformFactory> platformFactoryClass = (Class<? extends PlatformFactory>) annotationAttributes .get("platformFactory"); PlatformFactory platformFactory = BeanUtils.instantiate(platformFactoryClass); return platformFactory.build(); }