Here are the examples of the java api org.springframework.beans.BeanUtils.instantiateClass() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
127 Examples
19
View Source File : MockServerRestTemplateCustomizer.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
protected RequestExpectationManager createExpectationManager() {
return BeanUtils.instantiateClreplaced(this.expectationManager);
}
19
View Source File : XADataSourceAutoConfiguration.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private XADataSource createXaDataSourceInstance(String clreplacedName) {
try {
Clreplaced<?> dataSourceClreplaced = ClreplacedUtils.forName(clreplacedName, this.clreplacedLoader);
Object instance = BeanUtils.instantiateClreplaced(dataSourceClreplaced);
replacedert.isInstanceOf(XADataSource.clreplaced, instance);
return (XADataSource) instance;
} catch (Exception ex) {
throw new IllegalStateException("Unable to create XADataSource instance from '" + clreplacedName + "'");
}
}
19
View Source File : WebServiceTemplateBuilder.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Build a new {@link WebServiceTemplate} instance of the specified type and configure
* it using this builder.
* @param <T> the type of web service template
* @param webServiceTemplateClreplaced the template type to create
* @return a configured {@link WebServiceTemplate} instance.
* @see WebServiceTemplateBuilder#build()
* @see #configure(WebServiceTemplate)
*/
public <T extends WebServiceTemplate> T build(Clreplaced<T> webServiceTemplateClreplaced) {
replacedert.notNull(webServiceTemplateClreplaced, "WebServiceTemplateClreplaced must not be null");
return configure(BeanUtils.instantiateClreplaced(webServiceTemplateClreplaced));
}
19
View Source File : TomcatErrorPage.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private Object createNativePage() {
try {
if (ClreplacedUtils.isPresent(ERROR_PAGE_CLreplaced, null)) {
return BeanUtils.instantiateClreplaced(ClreplacedUtils.forName(ERROR_PAGE_CLreplaced, null));
}
} catch (ClreplacedNotFoundException | LinkageError ex) {
// Swallow and continue
}
return null;
}
19
View Source File : RestTemplateBuilder.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Build a new {@link RestTemplate} instance of the specified type and configure it
* using this builder.
* @param <T> the type of rest template
* @param restTemplateClreplaced the template type to create
* @return a configured {@link RestTemplate} instance.
* @see RestTemplateBuilder#build()
* @see #configure(RestTemplate)
*/
public <T extends RestTemplate> T build(Clreplaced<T> restTemplateClreplaced) {
return configure(BeanUtils.instantiateClreplaced(restTemplateClreplaced));
}
19
View Source File : TaskExecutorBuilder.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Build a new {@link ThreadPoolTaskExecutor} instance of the specified type and
* configure it using this builder.
* @param <T> the type of task executor
* @param taskExecutorClreplaced the template type to create
* @return a configured {@link ThreadPoolTaskExecutor} instance.
* @see #build()
* @see #configure(ThreadPoolTaskExecutor)
*/
public <T extends ThreadPoolTaskExecutor> T build(Clreplaced<T> taskExecutorClreplaced) {
return configure(BeanUtils.instantiateClreplaced(taskExecutorClreplaced));
}
19
View Source File : BeanDefinitionLoader.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private int load(Clreplaced<?> source) {
if (isGroovyPresent() && GroovyBeanDefinitionSource.clreplaced.isreplacedignableFrom(source)) {
// Any GroovyLoaders added in beans{} DSL can contribute beans here
GroovyBeanDefinitionSource loader = BeanUtils.instantiateClreplaced(source, GroovyBeanDefinitionSource.clreplaced);
load(loader);
}
if (isComponent(source)) {
this.annotatedReader.register(source);
return 1;
}
return 0;
}
19
View Source File : BaseSimpleTreeService.java
License : Apache License 2.0
Project Creator : Yiuman
License : Apache License 2.0
Project Creator : Yiuman
@Override
public E getRoot() {
// 创建虚拟节点
return BeanUtils.instantiateClreplaced(getEnreplacedyType());
}
19
View Source File : BeanCreatingHandlerProvider.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
public T getHandler() {
if (this.beanFactory != null) {
return this.beanFactory.createBean(this.handlerType);
} else {
return BeanUtils.instantiateClreplaced(this.handlerType);
}
}
19
View Source File : MockAsyncContext.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public <T extends AsyncListener> T createListener(Clreplaced<T> clazz) throws ServletException {
return BeanUtils.instantiateClreplaced(clazz);
}
19
View Source File : BootstrapUtils.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Resolve the {@link TestContextBootstrapper} type for the test clreplaced in the
* supplied {@link BootstrapContext}, instantiate it, and provide it a reference
* to the {@link BootstrapContext}.
* <p>If the {@link BootstrapWith @BootstrapWith} annotation is present on
* the test clreplaced, either directly or as a meta-annotation, then its
* {@link BootstrapWith#value value} will be used as the bootstrapper type.
* Otherwise, either the
* {@link org.springframework.test.context.support.DefaultTestContextBootstrapper
* DefaultTestContextBootstrapper} or the
* {@link org.springframework.test.context.web.WebTestContextBootstrapper
* WebTestContextBootstrapper} will be used, depending on the presence of
* {@link org.springframework.test.context.web.WebAppConfiguration @WebAppConfiguration}.
* @param bootstrapContext the bootstrap context to use
* @return a fully configured {@code TestContextBootstrapper}
*/
static TestContextBootstrapper resolveTestContextBootstrapper(BootstrapContext bootstrapContext) {
Clreplaced<?> testClreplaced = bootstrapContext.getTestClreplaced();
Clreplaced<?> clazz = null;
try {
clazz = resolveExplicitTestContextBootstrapper(testClreplaced);
if (clazz == null) {
clazz = resolveDefaultTestContextBootstrapper(testClreplaced);
}
if (logger.isDebugEnabled()) {
logger.debug(String.format("Instantiating TestContextBootstrapper for test clreplaced [%s] from clreplaced [%s]", testClreplaced.getName(), clazz.getName()));
}
TestContextBootstrapper testContextBootstrapper = BeanUtils.instantiateClreplaced(clazz, TestContextBootstrapper.clreplaced);
testContextBootstrapper.setBootstrapContext(bootstrapContext);
return testContextBootstrapper;
} catch (IllegalStateException ex) {
throw ex;
} catch (Throwable ex) {
throw new IllegalStateException("Could not load TestContextBootstrapper [" + clazz + "]. Specify @BootstrapWith's 'value' attribute or make the default bootstrapper clreplaced available.", ex);
}
}
19
View Source File : DefaultJCacheOperationSource.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected <T> T getBean(Clreplaced<T> type) {
replacedert.state(this.beanFactory != null, () -> "BeanFactory required for resolution of [" + type + "]");
try {
return this.beanFactory.getBean(type);
} catch (NoUniqueBeanDefinitionException ex) {
throw new IllegalStateException("No unique [" + type.getName() + "] bean found in application context - " + "mark one as primary, or declare a more specific implementation type for your cache", ex);
} catch (NoSuchBeanDefinitionException ex) {
if (logger.isDebugEnabled()) {
logger.debug("No bean of type [" + type.getName() + "] found in application context", ex);
}
return BeanUtils.instantiateClreplaced(type);
}
}
19
View Source File : XmlBeanDefinitionReader.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Create the {@link BeanDefinitionDoreplacedentReader} to use for actually
* reading bean definitions from an XML doreplacedent.
* <p>The default implementation instantiates the specified "doreplacedentReaderClreplaced".
* @see #setDoreplacedentReaderClreplaced
*/
protected BeanDefinitionDoreplacedentReader createBeanDefinitionDoreplacedentReader() {
return BeanUtils.instantiateClreplaced(this.doreplacedentReaderClreplaced);
}
19
View Source File : ServiceLocatorFactoryBean.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Create a service locator exception for the given cause.
* Only called in case of a custom service locator exception.
* <p>The default implementation can handle all variations of
* message and exception arguments.
* @param exceptionConstructor the constructor to use
* @param cause the cause of the service lookup failure
* @return the service locator exception to throw
* @see #setServiceLocatorExceptionClreplaced
*/
protected Exception createServiceLocatorException(Constructor<Exception> exceptionConstructor, BeansException cause) {
Clreplaced<?>[] paramTypes = exceptionConstructor.getParameterTypes();
Object[] args = new Object[paramTypes.length];
for (int i = 0; i < paramTypes.length; i++) {
if (String.clreplaced == paramTypes[i]) {
args[i] = cause.getMessage();
} else if (paramTypes[i].isInstance(cause)) {
args[i] = cause;
}
}
return BeanUtils.instantiateClreplaced(exceptionConstructor, args);
}
19
View Source File : DynamicJndiContextFactoryBuilder.java
License : Apache License 2.0
Project Creator : thomasdarimont
License : Apache License 2.0
Project Creator : thomasdarimont
/**
* Create a new {@link InitialContextFactory} based on the given {@code environment}.
* <p>
* If the lookup environment is empty, we return a JndiContextFactory that returns a InitialContext which supports a lookups against a fixed set of Spring beans.
* If the environment is not empty, we try to use the provided java.naming.factory.initial clreplacedname to create a JndiContextFactory and
* delegate further lookups to this instance. Otherwise we simply return {@literal null}.
* @param environment
* @return
*/
@Override
public InitialContextFactory createInitialContextFactory(Hashtable<?, ?> environment) {
if (environment == null || environment.isEmpty()) {
return env -> fixedInitialContext;
}
String factoryClreplacedName = (String) environment.get("java.naming.factory.initial");
if (factoryClreplacedName != null) {
try {
// factoryClreplacedName -> com.sun.jndi.ldap.LdapCtxFactory
Clreplaced<?> factoryClreplaced = Thread.currentThread().getContextClreplacedLoader().loadClreplaced(factoryClreplacedName);
return BeanUtils.instantiateClreplaced(factoryClreplaced, InitialContextFactory.clreplaced);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
}
}
return null;
}
19
View Source File : CopyUtil.java
License : GNU Affero General Public License v3.0
Project Creator : stategen
License : GNU Affero General Public License v3.0
Project Creator : stategen
public static <T> List<T> copy(List<?> sourceList, Clreplaced<T> targetCls, String... ignoreProperties) {
if (sourceList == null) {
return null;
}
if (CollectionUtil.isNotEmpty(sourceList)) {
List<T> targetList = new ArrayList<T>(sourceList.size());
for (Object o : sourceList) {
T targetObj = BeanUtils.instantiateClreplaced(targetCls);
BeanUtils.copyProperties(o, targetObj, ignoreProperties);
targetList.add(targetObj);
}
return targetList;
}
return new ArrayList<T>(0);
}
19
View Source File : CopyUtil.java
License : GNU Affero General Public License v3.0
Project Creator : stategen
License : GNU Affero General Public License v3.0
Project Creator : stategen
public static <T> T copy(Object source, Clreplaced<T> targetCls, String... ignoreProperties) {
if (targetCls == null) {
return null;
}
T instance = BeanUtils.instantiateClreplaced(targetCls);
return copy(source, instance, ignoreProperties);
}
19
View Source File : AbstractGrayDecisionFactory.java
License : Apache License 2.0
Project Creator : SpringCloud
License : Apache License 2.0
Project Creator : SpringCloud
public C newConfig() {
return BeanUtils.instantiateClreplaced(getConfigClreplaced());
}
19
View Source File : FeignClientFactoryBean.java
License : Apache License 2.0
Project Creator : spring-cloud
License : Apache License 2.0
Project Creator : spring-cloud
private <T> T getOrInstantiate(Clreplaced<T> tClreplaced) {
try {
return beanFactory != null ? beanFactory.getBean(tClreplaced) : applicationContext.getBean(tClreplaced);
} catch (NoSuchBeanDefinitionException e) {
return BeanUtils.instantiateClreplaced(tClreplaced);
}
}
19
View Source File : AbstractConfigurable.java
License : Apache License 2.0
Project Creator : spring-cloud
License : Apache License 2.0
Project Creator : spring-cloud
@Override
public C newConfig() {
return BeanUtils.instantiateClreplaced(this.configClreplaced);
}
19
View Source File : EnhancedRequestParamMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : penggle
License : Apache License 2.0
Project Creator : penggle
/**
* 实例化一个@RequestParam注解参数的实例
* @param parameter
* @return
*/
protected Object instantiateParameter(MethodParameter parameter) {
return BeanUtils.instantiateClreplaced(parameter.getNestedParameterType());
}
19
View Source File : DefaultAnswerMockSettings.java
License : MIT License
Project Creator : pchudzik
License : MIT License
Project Creator : pchudzik
private Answer createAnswerInstance() {
return BeanUtils.instantiateClreplaced(answerClreplaced);
}
19
View Source File : NewInstanceDoubleFactoryCreator.java
License : MIT License
Project Creator : pchudzik
License : MIT License
Project Creator : pchudzik
@Override
public DoubleFactory createDoubleFactory() {
return BeanUtils.instantiateClreplaced(doubleFactoryClreplaced);
}
19
View Source File : ConfigurableJasperReportsView.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
/**
* Returns a new instance of the specified {@link net.sf.jasperreports.engine.JRExporter} clreplaced.
* @see #setExporterClreplaced(Clreplaced)
* @see BeanUtils#instantiateClreplaced(Clreplaced)
*/
@Override
protected net.sf.jasperreports.engine.JRExporter createExporter() {
return BeanUtils.instantiateClreplaced(this.exporterClreplaced);
}
19
View Source File : MultiActionController.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
/**
* Create a new command object of the given clreplaced.
* <p>This implementation uses {@code BeanUtils.instantiateClreplaced},
* so commands need to have public no-arg constructors.
* Subclreplacedes can override this implementation if desired.
* @throws Exception if the command object could not be instantiated
* @see org.springframework.beans.BeanUtils#instantiateClreplaced(Clreplaced)
*/
protected Object newCommandObject(Clreplaced<?> clazz) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Creating new command of clreplaced [" + clazz.getName() + "]");
}
return BeanUtils.instantiateClreplaced(clazz);
}
19
View Source File : LocalSessionFactoryBean.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
/**
* Subclreplacedes can override this method to perform custom initialization
* of the Configuration instance used for SessionFactory creation.
* The properties of this LocalSessionFactoryBean will be applied to
* the Configuration object that gets returned here.
* <p>The default implementation creates a new Configuration instance.
* A custom implementation could prepare the instance in a specific way,
* or use a custom Configuration subclreplaced.
* @return the Configuration instance
* @throws HibernateException in case of Hibernate initialization errors
* @see org.hibernate.cfg.Configuration#Configuration()
*/
protected Configuration newConfiguration() throws HibernateException {
return BeanUtils.instantiateClreplaced(this.configurationClreplaced);
}
19
View Source File : SchedulerFactoryBean.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
// ---------------------------------------------------------------------
// Implementation of InitializingBean interface
// ---------------------------------------------------------------------
@Override
public void afterPropertiesSet() throws Exception {
if (this.dataSource == null && this.nonTransactionalDataSource != null) {
this.dataSource = this.nonTransactionalDataSource;
}
if (this.applicationContext != null && this.resourceLoader == null) {
this.resourceLoader = this.applicationContext;
}
// Create SchedulerFactory instance...
SchedulerFactory schedulerFactory = BeanUtils.instantiateClreplaced(this.schedulerFactoryClreplaced);
initSchedulerFactory(schedulerFactory);
if (this.resourceLoader != null) {
// Make given ResourceLoader available for SchedulerFactory configuration.
configTimeResourceLoaderHolder.set(this.resourceLoader);
}
if (this.taskExecutor != null) {
// Make given TaskExecutor available for SchedulerFactory configuration.
configTimeTaskExecutorHolder.set(this.taskExecutor);
}
if (this.dataSource != null) {
// Make given DataSource available for SchedulerFactory configuration.
configTimeDataSourceHolder.set(this.dataSource);
}
if (this.nonTransactionalDataSource != null) {
// Make given non-transactional DataSource available for SchedulerFactory configuration.
configTimeNonTransactionalDataSourceHolder.set(this.nonTransactionalDataSource);
}
// Get Scheduler instance from SchedulerFactory.
try {
this.scheduler = createScheduler(schedulerFactory, this.schedulerName);
populateSchedulerContext();
if (!this.jobFactorySet && !(this.scheduler instanceof RemoteScheduler)) {
// Use AdaptableJobFactory as default for a local Scheduler, unless when
// explicitly given a null value through the "jobFactory" bean property.
this.jobFactory = new AdaptableJobFactory();
}
if (this.jobFactory != null) {
if (this.jobFactory instanceof SchedulerContextAware) {
((SchedulerContextAware) this.jobFactory).setSchedulerContext(this.scheduler.getContext());
}
this.scheduler.setJobFactory(this.jobFactory);
}
} finally {
if (this.resourceLoader != null) {
configTimeResourceLoaderHolder.remove();
}
if (this.taskExecutor != null) {
configTimeTaskExecutorHolder.remove();
}
if (this.dataSource != null) {
configTimeDataSourceHolder.remove();
}
if (this.nonTransactionalDataSource != null) {
configTimeNonTransactionalDataSourceHolder.remove();
}
}
registerListeners();
registerJobsAndTriggers();
}
19
View Source File : DefaultJCacheOperationSource.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Override
protected <T> T getBean(Clreplaced<T> type) {
try {
return this.beanFactory.getBean(type);
} catch (NoUniqueBeanDefinitionException ex) {
throw new IllegalStateException("No unique [" + type.getName() + "] bean found in application context - " + "mark one as primary, or declare a more specific implementation type for your cache", ex);
} catch (NoSuchBeanDefinitionException ex) {
if (logger.isDebugEnabled()) {
logger.debug("No bean of type [" + type.getName() + "] found in application context", ex);
}
return BeanUtils.instantiateClreplaced(type);
}
}
19
View Source File : ConfigurationClassParser.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
private void processImports(ConfigurationClreplaced configClreplaced, SourceClreplaced currentSourceClreplaced, Collection<SourceClreplaced> importCandidates, boolean checkForCircularImports) throws IOException {
if (importCandidates.isEmpty()) {
return;
}
if (checkForCircularImports && this.importStack.contains(configClreplaced)) {
this.problemReporter.error(new CircularImportProblem(configClreplaced, this.importStack));
} else {
this.importStack.push(configClreplaced);
try {
for (SourceClreplaced candidate : importCandidates) {
if (candidate.isreplacedignable(ImportSelector.clreplaced)) {
// Candidate clreplaced is an ImportSelector -> delegate to it to determine imports
Clreplaced<?> candidateClreplaced = candidate.loadClreplaced();
ImportSelector selector = BeanUtils.instantiateClreplaced(candidateClreplaced, ImportSelector.clreplaced);
invokeAwareMethods(selector);
if (this.deferredImportSelectors != null && selector instanceof DeferredImportSelector) {
this.deferredImportSelectors.add(new DeferredImportSelectorHolder(configClreplaced, (DeferredImportSelector) selector));
} else {
String[] importClreplacedNames = selector.selectImports(currentSourceClreplaced.getMetadata());
Collection<SourceClreplaced> importSourceClreplacedes = replacedourceClreplacedes(importClreplacedNames);
processImports(configClreplaced, currentSourceClreplaced, importSourceClreplacedes, false);
}
} else if (candidate.isreplacedignable(ImportBeanDefinitionRegistrar.clreplaced)) {
// Candidate clreplaced is an ImportBeanDefinitionRegistrar ->
// delegate to it to register additional bean definitions
Clreplaced<?> candidateClreplaced = candidate.loadClreplaced();
ImportBeanDefinitionRegistrar registrar = BeanUtils.instantiateClreplaced(candidateClreplaced, ImportBeanDefinitionRegistrar.clreplaced);
invokeAwareMethods(registrar);
configClreplaced.addImportBeanDefinitionRegistrar(registrar, currentSourceClreplaced.getMetadata());
} else {
// Candidate clreplaced not an ImportSelector or ImportBeanDefinitionRegistrar ->
// process it as an @Configuration clreplaced
this.importStack.registerImport(currentSourceClreplaced.getMetadata(), candidate.getMetadata().getClreplacedName());
processConfigurationClreplaced(candidate.asConfigClreplaced(configClreplaced));
}
}
} catch (BeanDefinitionStoreException ex) {
throw ex;
} catch (Exception ex) {
throw new BeanDefinitionStoreException("Failed to process import candidates for configuration clreplaced [" + configClreplaced.getMetadata().getClreplacedName() + "]", ex);
} finally {
this.importStack.pop();
}
}
}
19
View Source File : ComponentScanAnnotationParser.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
private List<TypeFilter> typeFiltersFor(AnnotationAttributes filterAttributes) {
List<TypeFilter> typeFilters = new ArrayList<TypeFilter>();
FilterType filterType = filterAttributes.getEnum("type");
for (Clreplaced<?> filterClreplaced : filterAttributes.getAliasedClreplacedArray("clreplacedes", ComponentScan.Filter.clreplaced, null)) {
switch(filterType) {
case ANNOTATION:
replacedert.isreplacedignable(Annotation.clreplaced, filterClreplaced, "An error occured while processing a @ComponentScan ANNOTATION type filter: ");
@SuppressWarnings("unchecked")
Clreplaced<Annotation> annotationType = (Clreplaced<Annotation>) filterClreplaced;
typeFilters.add(new AnnotationTypeFilter(annotationType));
break;
case replacedIGNABLE_TYPE:
typeFilters.add(new replacedignableTypeFilter(filterClreplaced));
break;
case CUSTOM:
replacedert.isreplacedignable(TypeFilter.clreplaced, filterClreplaced, "An error occured while processing a @ComponentScan CUSTOM type filter: ");
typeFilters.add(BeanUtils.instantiateClreplaced(filterClreplaced, TypeFilter.clreplaced));
break;
default:
throw new IllegalArgumentException("Filter type not supported with Clreplaced value: " + filterType);
}
}
for (String expression : filterAttributes.getStringArray("pattern")) {
switch(filterType) {
case ASPECTJ:
typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClreplacedLoader()));
break;
case REGEX:
typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
break;
default:
throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
}
}
return typeFilters;
}
19
View Source File : XmlBeanDefinitionReader.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
/**
* Create the {@link BeanDefinitionDoreplacedentReader} to use for actually
* reading bean definitions from an XML doreplacedent.
* <p>The default implementation instantiates the specified "doreplacedentReaderClreplaced".
* @see #setDoreplacedentReaderClreplaced
*/
protected BeanDefinitionDoreplacedentReader createBeanDefinitionDoreplacedentReader() {
return BeanDefinitionDoreplacedentReader.clreplaced.cast(BeanUtils.instantiateClreplaced(this.doreplacedentReaderClreplaced));
}
19
View Source File : RestTemplateBuilder.java
License : Apache License 2.0
Project Creator : hello-shf
License : Apache License 2.0
Project Creator : hello-shf
/**
* Build a new {@link RestTemplate} instance of the specified type and configure it
* using this builder.
*
* @param <T> the type of rest template
* @param restTemplateClreplaced the template type to create
* @return a configured {@link RestTemplate} instance.
* @see RestTemplateBuilder#build()
* @see #configure(RestTemplate)
*/
public <T extends RestTemplate> T build(Clreplaced<T> restTemplateClreplaced) {
return configure(BeanUtils.instantiateClreplaced(restTemplateClreplaced));
}
19
View Source File : BeanDefinitionLoader.java
License : Apache License 2.0
Project Creator : hello-shf
License : Apache License 2.0
Project Creator : hello-shf
private int load(Clreplaced<?> source) {
if (isGroovyPresent() && GroovyBeanDefinitionSource.clreplaced.isreplacedignableFrom(source)) {
// Any GroovyLoaders added in beans{} DSL can contribute beans here
GroovyBeanDefinitionSource loader = BeanUtils.instantiateClreplaced(source, GroovyBeanDefinitionSource.clreplaced);
load(loader);
}
if (isComponent(source)) {
// 将 启动类的 BeanDefinition注册进 beanDefinitionMap
this.annotatedReader.register(source);
return 1;
}
return 0;
}
19
View Source File : WxRequestBody.java
License : Apache License 2.0
Project Creator : FastBootWeixin
License : Apache License 2.0
Project Creator : FastBootWeixin
/**
* 类型声明写泛型上
*
* @param clazz
* @param <T>
* @return the result
*/
public static <T extends WxRequestBody> T of(Clreplaced<T> clazz, WxRequest.Body body) {
WxRequestBody wxRequestBody = BeanUtils.instantiateClreplaced(clazz);
return (T) wxRequestBody.of(body);
}
19
View Source File : AbstractEntityMapper.java
License : Apache License 2.0
Project Creator : cybozu
License : Apache License 2.0
Project Creator : cybozu
@Override
public T createInstance() {
return BeanUtils.instantiateClreplaced(mappedClreplaced);
}
19
View Source File : AbstractNameValueExpressionTest.java
License : Apache License 2.0
Project Creator : alibaba
License : Apache License 2.0
Project Creator : alibaba
protected T createExpression(String expression) {
ResolvableType resolvableType = ResolvableType.forType(getClreplaced().getGenericSuperclreplaced());
Clreplaced<T> firstGenericType = (Clreplaced<T>) resolvableType.resolveGeneric(0);
Constructor<T> constructor = null;
try {
constructor = firstGenericType.getDeclaredConstructor(String.clreplaced);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
return BeanUtils.instantiateClreplaced(constructor, expression);
}
18
View Source File : BaseQueryForm.java
License : Apache License 2.0
Project Creator : zhoutaoo
License : Apache License 2.0
Project Creator : zhoutaoo
/**
* Form转化为Param
*
* @param clazz
* @return
*/
public P toParam(Clreplaced<P> clazz) {
P p = BeanUtils.instantiateClreplaced(clazz);
BeanUtils.copyProperties(this, p);
return p;
}
18
View Source File : BaseForm.java
License : Apache License 2.0
Project Creator : zhoutaoo
License : Apache License 2.0
Project Creator : zhoutaoo
/**
* From转化为Po,进行后续业务处理
*
* @param clazz
* @return
*/
public T toPo(Clreplaced<T> clazz) {
T t = BeanUtils.instantiateClreplaced(clazz);
BeanUtils.copyProperties(this, t);
return t;
}
18
View Source File : BaseForm.java
License : Apache License 2.0
Project Creator : zhoutaoo
License : Apache License 2.0
Project Creator : zhoutaoo
/**
* From转化为Po,进行后续业务处理
*
* @param id
* @param clazz
* @return
*/
public T toPo(String id, Clreplaced<T> clazz) {
T t = BeanUtils.instantiateClreplaced(clazz);
t.setId(id);
BeanUtils.copyProperties(this, t);
return t;
}
18
View Source File : FilterAnnotations.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@SuppressWarnings("unchecked")
private TypeFilter createTypeFilter(FilterType filterType, Clreplaced<?> filterClreplaced) {
switch(filterType) {
case ANNOTATION:
replacedert.isreplacedignable(Annotation.clreplaced, filterClreplaced, "An error occurred while processing an ANNOTATION type filter: ");
return new AnnotationTypeFilter((Clreplaced<Annotation>) filterClreplaced);
case replacedIGNABLE_TYPE:
return new replacedignableTypeFilter(filterClreplaced);
case CUSTOM:
replacedert.isreplacedignable(TypeFilter.clreplaced, filterClreplaced, "An error occurred while processing a CUSTOM type filter: ");
return BeanUtils.instantiateClreplaced(filterClreplaced, TypeFilter.clreplaced);
}
throw new IllegalArgumentException("Filter type not supported with Clreplaced value: " + filterType);
}
18
View Source File : MessageInterpolatorFactory.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private MessageInterpolator getFallback(String fallback) {
Clreplaced<?> interpolatorClreplaced = ClreplacedUtils.resolveClreplacedName(fallback, null);
Object interpolator = BeanUtils.instantiateClreplaced(interpolatorClreplaced);
return (MessageInterpolator) interpolator;
}
18
View Source File : DataSourceBuilder.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@SuppressWarnings("unchecked")
public T build() {
Clreplaced<? extends DataSource> type = getType();
DataSource result = BeanUtils.instantiateClreplaced(type);
maybeGetDriverClreplacedName();
bind(result);
return (T) result;
}
18
View Source File : WebUtils.java
License : Apache License 2.0
Project Creator : Yiuman
License : Apache License 2.0
Project Creator : Yiuman
/**
* 类型绑定请求数据
*
* @param objectClreplaced 绑定的数据类型Clreplaced
* @param request 当前请求
* @param force 是否强制生成
* @return 已经处理好的绑定数据
* @throws Exception 反射异常
*/
public static <T> T requestDataBind(Clreplaced<T> objectClreplaced, HttpServletRequest request, boolean force) throws Exception {
if (objectClreplaced == null || request == null) {
return null;
}
// 若是get请求或者是form-data则先检验下有没参数
boolean hasParameterRequest = request instanceof AbstractMultipartHttpServletRequest || request.getMethod().equals(HttpMethod.GET.name());
if (!force && hasParameterRequest && CollectionUtils.isEmpty(request.getParameterMap())) {
return null;
}
// 构造实体
T t = BeanUtils.instantiateClreplaced(objectClreplaced);
requestDataBind(t, request);
return t;
}
18
View Source File : BootstrapUtils.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Create the {@code BootstrapContext} for the specified {@linkplain Clreplaced test clreplaced}.
* <p>Uses reflection to create a {@link org.springframework.test.context.support.DefaultBootstrapContext}
* that uses a {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate}.
* @param testClreplaced the test clreplaced for which the bootstrap context should be created
* @return a new {@code BootstrapContext}; never {@code null}
*/
@SuppressWarnings("unchecked")
static BootstrapContext createBootstrapContext(Clreplaced<?> testClreplaced) {
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = createCacheAwareContextLoaderDelegate();
Clreplaced<? extends BootstrapContext> clazz = null;
try {
clazz = (Clreplaced<? extends BootstrapContext>) ClreplacedUtils.forName(DEFAULT_BOOTSTRAP_CONTEXT_CLreplaced_NAME, BootstrapUtils.clreplaced.getClreplacedLoader());
Constructor<? extends BootstrapContext> constructor = clazz.getConstructor(Clreplaced.clreplaced, CacheAwareContextLoaderDelegate.clreplaced);
if (logger.isDebugEnabled()) {
logger.debug(String.format("Instantiating BootstrapContext using constructor [%s]", constructor));
}
return BeanUtils.instantiateClreplaced(constructor, testClreplaced, cacheAwareContextLoaderDelegate);
} catch (Throwable ex) {
throw new IllegalStateException("Could not load BootstrapContext [" + clazz + "]", ex);
}
}
18
View Source File : BootstrapUtils.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@SuppressWarnings("unchecked")
private static CacheAwareContextLoaderDelegate createCacheAwareContextLoaderDelegate() {
Clreplaced<? extends CacheAwareContextLoaderDelegate> clazz = null;
try {
clazz = (Clreplaced<? extends CacheAwareContextLoaderDelegate>) ClreplacedUtils.forName(DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLreplaced_NAME, BootstrapUtils.clreplaced.getClreplacedLoader());
if (logger.isDebugEnabled()) {
logger.debug(String.format("Instantiating CacheAwareContextLoaderDelegate from clreplaced [%s]", clazz.getName()));
}
return BeanUtils.instantiateClreplaced(clazz, CacheAwareContextLoaderDelegate.clreplaced);
} catch (Throwable ex) {
throw new IllegalStateException("Could not load CacheAwareContextLoaderDelegate [" + clazz + "]", ex);
}
}
18
View Source File : GenericSqlQuery.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
@SuppressWarnings("unchecked")
protected RowMapper<T> newRowMapper(@Nullable Object[] parameters, @Nullable Map<?, ?> context) {
if (this.rowMapper != null) {
return this.rowMapper;
} else {
replacedert.state(this.rowMapperClreplaced != null, "No RowMapper set");
return BeanUtils.instantiateClreplaced(this.rowMapperClreplaced);
}
}
18
View Source File : ConfigurationClassParser.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private void processImports(ConfigurationClreplaced configClreplaced, SourceClreplaced currentSourceClreplaced, Collection<SourceClreplaced> importCandidates, boolean checkForCircularImports) {
if (importCandidates.isEmpty()) {
return;
}
if (checkForCircularImports && isChainedImportOnStack(configClreplaced)) {
this.problemReporter.error(new CircularImportProblem(configClreplaced, this.importStack));
} else {
this.importStack.push(configClreplaced);
try {
for (SourceClreplaced candidate : importCandidates) {
if (candidate.isreplacedignable(ImportSelector.clreplaced)) {
// Candidate clreplaced is an ImportSelector -> delegate to it to determine imports
Clreplaced<?> candidateClreplaced = candidate.loadClreplaced();
ImportSelector selector = BeanUtils.instantiateClreplaced(candidateClreplaced, ImportSelector.clreplaced);
ParserStrategyUtils.invokeAwareMethods(selector, this.environment, this.resourceLoader, this.registry);
if (selector instanceof DeferredImportSelector) {
this.deferredImportSelectorHandler.handle(configClreplaced, (DeferredImportSelector) selector);
} else {
String[] importClreplacedNames = selector.selectImports(currentSourceClreplaced.getMetadata());
Collection<SourceClreplaced> importSourceClreplacedes = replacedourceClreplacedes(importClreplacedNames);
processImports(configClreplaced, currentSourceClreplaced, importSourceClreplacedes, false);
}
} else if (candidate.isreplacedignable(ImportBeanDefinitionRegistrar.clreplaced)) {
// Candidate clreplaced is an ImportBeanDefinitionRegistrar ->
// delegate to it to register additional bean definitions
Clreplaced<?> candidateClreplaced = candidate.loadClreplaced();
ImportBeanDefinitionRegistrar registrar = BeanUtils.instantiateClreplaced(candidateClreplaced, ImportBeanDefinitionRegistrar.clreplaced);
ParserStrategyUtils.invokeAwareMethods(registrar, this.environment, this.resourceLoader, this.registry);
configClreplaced.addImportBeanDefinitionRegistrar(registrar, currentSourceClreplaced.getMetadata());
} else {
// Candidate clreplaced not an ImportSelector or ImportBeanDefinitionRegistrar ->
// process it as an @Configuration clreplaced
this.importStack.registerImport(currentSourceClreplaced.getMetadata(), candidate.getMetadata().getClreplacedName());
processConfigurationClreplaced(candidate.asConfigClreplaced(configClreplaced));
}
}
} catch (BeanDefinitionStoreException ex) {
throw ex;
} catch (Throwable ex) {
throw new BeanDefinitionStoreException("Failed to process import candidates for configuration clreplaced [" + configClreplaced.getMetadata().getClreplacedName() + "]", ex);
} finally {
this.importStack.pop();
}
}
}
18
View Source File : ComponentScanAnnotationParser.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private List<TypeFilter> typeFiltersFor(AnnotationAttributes filterAttributes) {
List<TypeFilter> typeFilters = new ArrayList<>();
FilterType filterType = filterAttributes.getEnum("type");
for (Clreplaced<?> filterClreplaced : filterAttributes.getClreplacedArray("clreplacedes")) {
switch(filterType) {
case ANNOTATION:
replacedert.isreplacedignable(Annotation.clreplaced, filterClreplaced, "@ComponentScan ANNOTATION type filter requires an annotation type");
@SuppressWarnings("unchecked")
Clreplaced<Annotation> annotationType = (Clreplaced<Annotation>) filterClreplaced;
typeFilters.add(new AnnotationTypeFilter(annotationType));
break;
case replacedIGNABLE_TYPE:
typeFilters.add(new replacedignableTypeFilter(filterClreplaced));
break;
case CUSTOM:
replacedert.isreplacedignable(TypeFilter.clreplaced, filterClreplaced, "@ComponentScan CUSTOM type filter requires a TypeFilter implementation");
TypeFilter filter = BeanUtils.instantiateClreplaced(filterClreplaced, TypeFilter.clreplaced);
ParserStrategyUtils.invokeAwareMethods(filter, this.environment, this.resourceLoader, this.registry);
typeFilters.add(filter);
break;
default:
throw new IllegalArgumentException("Filter type not supported with Clreplaced value: " + filterType);
}
}
for (String expression : filterAttributes.getStringArray("pattern")) {
switch(filterType) {
case ASPECTJ:
typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClreplacedLoader()));
break;
case REGEX:
typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
break;
default:
throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
}
}
return typeFilters;
}
18
View Source File : SimpleInstantiationStrategy.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner, final Constructor<?> ctor, Object... args) {
if (!bd.hasMethodOverrides()) {
if (System.getSecurityManager() != null) {
// use own privileged to change accessibility (when security is on)
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
ReflectionUtils.makeAccessible(ctor);
return null;
});
}
return BeanUtils.instantiateClreplaced(ctor, args);
} else {
return instantiateWithMethodInjection(bd, beanName, owner, ctor, args);
}
}
18
View Source File : SimpleInstantiationStrategy.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner) {
// Don't override the clreplaced with CGLIB if no overrides.
if (!bd.hasMethodOverrides()) {
Constructor<?> constructorToUse;
synchronized (bd.constructorArgumentLock) {
constructorToUse = (Constructor<?>) bd.resolvedConstructorOrFactoryMethod;
if (constructorToUse == null) {
final Clreplaced<?> clazz = bd.getBeanClreplaced();
if (clazz.isInterface()) {
throw new BeanInstantiationException(clazz, "Specified clreplaced is an interface");
}
try {
if (System.getSecurityManager() != null) {
constructorToUse = AccessController.doPrivileged((PrivilegedExceptionAction<Constructor<?>>) clazz::getDeclaredConstructor);
} else {
constructorToUse = clazz.getDeclaredConstructor();
}
bd.resolvedConstructorOrFactoryMethod = constructorToUse;
} catch (Throwable ex) {
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
}
}
}
return BeanUtils.instantiateClreplaced(constructorToUse);
} else {
// Must generate CGLIB subclreplaced.
return instantiateWithMethodInjection(bd, beanName, owner);
}
}
See More Examples