/** * Set the PersistenceProvider implementation class to use for creating the * EntityManagerFactory. If not specified, the persistence provider will be * taken from the JpaVendorAdapter (if any) or retrieved through scanning * (as far as possible). * @see JpaVendorAdapter#getPersistenceProvider() * @see javax.persistence.spi.PersistenceProvider * @see javax.persistence.Persistence */ public void setPersistenceProviderClass(Class<? extends PersistenceProvider> persistenceProviderClass) { this.persistenceProvider = BeanUtils.instantiateClass(persistenceProviderClass); }
/** * Specify the JDBC Driver implementation class to use. * <p>An instance of this Driver class will be created and held * within the SimpleDriverDataSource. * @see #setDriver */ public void setDriverClass(Class<? extends Driver> driverClass) { this.driver = BeanUtils.instantiateClass(driverClass); }
/** * Create the {@link BeanDefinitionDocumentReader} to use for actually * reading bean definitions from an XML document. * <p>The default implementation instantiates the specified "documentReaderClass". * @see #setDocumentReaderClass */ protected BeanDefinitionDocumentReader createBeanDefinitionDocumentReader() { return BeanUtils.instantiateClass(this.documentReaderClass); }
/** * Specify the target JCA ResourceAdapter as class, to be instantiated * with its default configuration. * <p>Alternatively, specify a pre-configured ResourceAdapter instance * through the "resourceAdapter" property. * @see #setResourceAdapter */ public void setResourceAdapterClass(Class<? extends ResourceAdapter> resourceAdapterClass) { this.resourceAdapter = BeanUtils.instantiateClass(resourceAdapterClass); }
@Override public Object autowire(Class<?> beanClass, int autowireMode, boolean dependencyCheck) { return BeanUtils.instantiateClass(beanClass); }
@Override public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { return BeanUtils.instantiateClass(clazz); }
private static List<Object> instantiateIfNecessary(Object[] specified) { List<Object> instances = new ArrayList<>(specified.length); for (Object obj : specified) { instances.add(obj instanceof Class ? BeanUtils.instantiateClass((Class<?>) obj) : obj); } return instances; }
private static List<Object> instantiateIfNecessary(Object[] specified) { List<Object> instances = new ArrayList<>(specified.length); for (Object obj : specified) { instances.add(obj instanceof Class ? BeanUtils.instantiateClass((Class<?>) obj) : obj); } return instances; }
@SuppressWarnings("unchecked") public static <T extends CodecConfigurer> T create(Class<T> ifc) { Class<?> impl = defaultCodecConfigurers.get(ifc); if (impl == null) { throw new IllegalStateException("No default codec configurer found for " + ifc); } return (T) BeanUtils.instantiateClass(impl); }
@Override @SuppressWarnings("unchecked") protected RowMapper<T> newRowMapper(@Nullable Object[] parameters, @Nullable Map<?, ?> context) { if (this.rowMapper != null) { return this.rowMapper; } else { Assert.state(this.rowMapperClass != null, "No RowMapper set"); return BeanUtils.instantiateClass(this.rowMapperClass); } }
private Group createGroup(@Nullable Class<? extends Group> type) { Class<? extends Group> effectiveType = (type != null ? type : DefaultDeferredImportSelectorGroup.class); Group group = BeanUtils.instantiateClass(effectiveType); ParserStrategyUtils.invokeAwareMethods(group, ConfigurationClassParser.this.environment, ConfigurationClassParser.this.resourceLoader, ConfigurationClassParser.this.registry); return group; }
@Override protected PreparerFactory createPreparerFactory(ApplicationContext context) { if (preparerFactoryClass != null) { return BeanUtils.instantiateClass(preparerFactoryClass); } else { return super.createPreparerFactory(context); } }
public T getHandler() { if (this.beanFactory != null) { return this.beanFactory.createBean(this.handlerType); } else { return BeanUtils.instantiateClass(this.handlerType); } }
@Nullable private static <T> T copyPropertiesToBean(@Nullable Annotation ann, Class<T> beanClass) { if (ann == null) { return null; } T bean = BeanUtils.instantiateClass(beanClass); AnnotationBeanUtils.copyPropertiesToBean(ann, bean); return bean; }
@SuppressWarnings("unchecked") public JtaTransactionManagerFactoryBean() { String className = resolveJtaTransactionManagerClassName(); try { Class<? extends JtaTransactionManager> clazz = (Class<? extends JtaTransactionManager>) ClassUtils.forName(className, JtaTransactionManagerFactoryBean.class.getClassLoader()); this.transactionManager = BeanUtils.instantiateClass(clazz); } catch (ClassNotFoundException ex) { throw new IllegalStateException("Failed to load JtaTransactionManager class: " + className, ex); } }
private Condition getCondition(String conditionClassName, @Nullable ClassLoader classloader) { Class<?> conditionClass = ClassUtils.resolveClassName(conditionClassName, classloader); return (Condition) BeanUtils.instantiateClass(conditionClass); }
/** * Create a new accessor, wrapping a new instance of the specified class. * @param clazz class to instantiate and wrap */ protected AbstractNestablePropertyAccessor(Class<?> clazz) { registerDefaultEditors(); setWrappedInstance(BeanUtils.instantiateClass(clazz)); }
private void assertBeforeTestMethodWithTransactionalTestMethod(Class<? extends Invocable> clazz, boolean invokedInTx) throws Exception { BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); Invocable instance = BeanUtils.instantiateClass(clazz); given(testContext.getTestInstance()).willReturn(instance); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("transactionalTest")); assertFalse("callback should not have been invoked", instance.invoked()); TransactionContextHolder.removeCurrentTransactionContext(); listener.beforeTestMethod(testContext); assertEquals(invokedInTx, instance.invoked()); }
private void assertBeforeTestMethodWithNonTransactionalTestMethod(Class<? extends Invocable> clazz) throws Exception { BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); Invocable instance = BeanUtils.instantiateClass(clazz); given(testContext.getTestInstance()).willReturn(instance); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("nonTransactionalTest")); assertFalse("callback should not have been invoked", instance.invoked()); TransactionContextHolder.removeCurrentTransactionContext(); listener.beforeTestMethod(testContext); assertFalse("callback should not have been invoked", instance.invoked()); }
private void assertAfterTestMethodWithNonTransactionalTestMethod(Class<? extends Invocable> clazz) throws Exception { BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz); Invocable instance = BeanUtils.instantiateClass(clazz); given(testContext.getTestInstance()).willReturn(instance); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("nonTransactionalTest")); assertFalse("callback should not have been invoked", instance.invoked()); TransactionContextHolder.removeCurrentTransactionContext(); listener.beforeTestMethod(testContext); listener.afterTestMethod(testContext); assertFalse("callback should not have been invoked", instance.invoked()); }