Here are the examples of the java api org.springframework.context.ApplicationContext.getAutowireCapableBeanFactory() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
65 Examples
19
View Source File : AutowireHelper.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
public static void autowire(Object clreplacedToAutowire, Object... beansToAutowireInClreplaced) {
for (Object bean : beansToAutowireInClreplaced) {
if (bean == null) {
applicationContext.getAutowireCapableBeanFactory().autowireBean(clreplacedToAutowire);
return;
}
}
}
19
View Source File : SpringJobFactory.java
License : Apache License 2.0
Project Creator : xiangxik
License : Apache License 2.0
Project Creator : xiangxik
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler Scheduler) throws SchedulerException {
Job job = super.newJob(bundle, Scheduler);
applicationContext.getAutowireCapableBeanFactory().autowireBean(job);
return job;
}
19
View Source File : AutowireHelper.java
License : Apache License 2.0
Project Creator : viz-centric
License : Apache License 2.0
Project Creator : viz-centric
/**
* Tries to autowire the specified instance of the clreplaced if one of the specified beans which need to be autowired
* are null.
*
* @param clreplacedToAutowire the instance of the clreplaced which holds @Autowire annotations
* @param beansToAutowireInClreplaced the beans which have the @Autowire annotation in the specified {#clreplacedToAutowire}
*/
public static void autowire(Object clreplacedToAutowire, Object... beansToAutowireInClreplaced) {
for (Object bean : beansToAutowireInClreplaced) {
if (bean == null) {
applicationContext.getAutowireCapableBeanFactory().autowireBean(clreplacedToAutowire);
return;
}
}
}
19
View Source File : UrlBasedViewResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Apply the containing {@link ApplicationContext}'s lifecycle methods
* to the given {@link View} instance, if such a context is available.
* @param viewName the name of the view
* @param view the freshly created View instance, pre-configured with
* {@link AbstractUrlBasedView}'s properties
* @return the {@link View} instance to use (either the original one
* or a decorated variant)
* @since 5.0
* @see #getApplicationContext()
* @see ApplicationContext#getAutowireCapableBeanFactory()
* @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#initializeBean
*/
protected View applyLifecycleMethods(String viewName, AbstractUrlBasedView view) {
ApplicationContext context = getApplicationContext();
if (context != null) {
Object initialized = context.getAutowireCapableBeanFactory().initializeBean(view, viewName);
if (initialized instanceof View) {
return (View) initialized;
}
}
return view;
}
19
View Source File : UrlBasedViewResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Apply the containing {@link ApplicationContext}'s lifecycle methods
* to the given {@link View} instance, if such a context is available.
* @param viewName the name of the view
* @param view the freshly created View instance, pre-configured with
* {@link AbstractUrlBasedView}'s properties
* @return the {@link View} instance to use (either the original one
* or a decorated variant)
* @see #getApplicationContext()
* @see ApplicationContext#getAutowireCapableBeanFactory()
* @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#initializeBean
*/
protected View applyLifecycleMethods(String viewName, AbstractUrlBasedView view) {
ApplicationContext context = getApplicationContext();
if (context != null) {
Object initialized = context.getAutowireCapableBeanFactory().initializeBean(view, viewName);
if (initialized instanceof View) {
return (View) initialized;
}
}
return view;
}
19
View Source File : LogSession.java
License : Apache License 2.0
Project Creator : sevdokimov
License : Apache License 2.0
Project Creator : sevdokimov
public static LogSession fromContext(@NonNull SessionAdapter sender, @NonNull ApplicationContext ctx) {
LogSession res = new LogSession(sender);
ctx.getAutowireCapableBeanFactory().autowireBeanProperties(res, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
return res;
}
19
View Source File : LogViewerServlet.java
License : Apache License 2.0
Project Creator : sevdokimov
License : Apache License 2.0
Project Creator : sevdokimov
private static <T> T injectDeps(ApplicationContext logContext, T controller) {
logContext.getAutowireCapableBeanFactory().autowireBeanProperties(controller, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
return controller;
}
19
View Source File : AbstractSpringManagedBeanFactory.java
License : Apache License 2.0
Project Creator : rico-projects
License : Apache License 2.0
Project Creator : rico-projects
@Override
public <T> void destroyDependentInstance(final T instance, final Clreplaced<T> cls) {
replacedert.requireNonNull(instance, "instance");
replacedert.requireNonNull(cls, "cls");
final ApplicationContext context = getContext();
context.getAutowireCapableBeanFactory().destroyBean(instance);
}
19
View Source File : ReportingConfiguration.java
License : Apache License 2.0
Project Creator : reportportal
License : Apache License 2.0
Project Creator : reportportal
private void registerSingleton(String name, Object bean) {
configurableBeanFactory.registerSingleton(name.trim(), bean);
applicationContext.getAutowireCapableBeanFactory().autowireBean(bean);
applicationContext.getAutowireCapableBeanFactory().initializeBean(bean, name);
}
19
View Source File : ParameterAutowireUtils.java
License : MIT License
Project Creator : mindcarver
License : MIT License
Project Creator : mindcarver
/**
* Resolve the dependency for the supplied {@link Parameter} from the
* supplied {@link ApplicationContext}.
* <p>Provides comprehensive autowiring support for individual method parameters
* on par with Spring's dependency injection facilities for autowired fields and
* methods, including support for {@link Autowired @Autowired},
* {@link Qualifier @Qualifier}, and {@link Value @Value} with support for property
* placeholders and SpEL expressions in {@code @Value} declarations.
* <p>The dependency is required unless the parameter is annotated with
* {@link Autowired @Autowired} with the {@link Autowired#required required}
* flag set to {@code false}.
* <p>If an explicit <em>qualifier</em> is not declared, the name of the parameter
* will be used as the qualifier for resolving ambiguities.
* @param parameter the parameter whose dependency should be resolved
* @param parameterIndex the index of the parameter
* @param containingClreplaced the concrete clreplaced that contains the parameter; this may
* differ from the clreplaced that declares the parameter in that it may be a subclreplaced
* thereof, potentially subsreplaceduting type variables
* @param applicationContext the application context from which to resolve the
* dependency
* @return the resolved object, or {@code null} if none found
* @throws BeansException if dependency resolution failed
* @see #isAutowirable
* @see Autowired#required
* @see SynthesizingMethodParameter#forParameter(Parameter)
* @see AutowireCapableBeanFactory#resolveDependency(DependencyDescriptor, String)
*/
@Nullable
static Object resolveDependency(Parameter parameter, int parameterIndex, Clreplaced<?> containingClreplaced, ApplicationContext applicationContext) {
AnnotatedElement annotatedParameter = getEffectiveAnnotatedParameter(parameter, parameterIndex);
Autowired autowired = AnnotatedElementUtils.findMergedAnnotation(annotatedParameter, Autowired.clreplaced);
boolean required = (autowired == null || autowired.required());
MethodParameter methodParameter = SynthesizingMethodParameter.forExecutable(parameter.getDeclaringExecutable(), parameterIndex);
DependencyDescriptor descriptor = new DependencyDescriptor(methodParameter, required);
descriptor.setContainingClreplaced(containingClreplaced);
return applicationContext.getAutowireCapableBeanFactory().resolveDependency(descriptor, null);
}
19
View Source File : SpelOnCircuitBreakerMetadataResolver.java
License : MIT License
Project Creator : ljtfreitas
License : MIT License
Project Creator : ljtfreitas
private Optional<String> beanNameTo(Clreplaced<?> type) {
return Try.of(() -> applicationContext.getAutowireCapableBeanFactory().resolveNamedBean(type)).map(NamedBeanHolder::getBeanName).recover(NoSuchBeanDefinitionException.clreplaced, e -> Try.success(null)).map(Optional::ofNullable).get();
}
19
View Source File : SpringBeanJobFactory.java
License : GNU General Public License v3.0
Project Creator : JuniperBot
License : GNU General Public License v3.0
Project Creator : JuniperBot
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object jobInstance = super.createJobInstance(bundle);
context.getAutowireCapableBeanFactory().autowireBean(jobInstance);
return jobInstance;
}
19
View Source File : JobFactoryService.java
License : Apache License 2.0
Project Creator : jiangzongyao
License : Apache License 2.0
Project Creator : jiangzongyao
/**
* 功能描述:创建JOB实例,并注解相关内容等
*
* @param bundle
* TriggerFiredBundle
* @return Object JOB实例
*/
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object instance = super.createJobInstance(bundle);
context.getAutowireCapableBeanFactory().autowireBean(instance);
return instance;
}
19
View Source File : SpringBeanUtils.java
License : Apache License 2.0
Project Creator : igloo-project
License : Apache License 2.0
Project Creator : igloo-project
/**
* Permet de faire réaliser l'injection de dépendances par Spring sur un bean.
*
* @param applicationContext le contexte d'application Spring
* @param bean un bean Spring
*/
public static void autowireBean(ApplicationContext applicationContext, Object bean) {
applicationContext.getAutowireCapableBeanFactory().autowireBean(bean);
}
19
View Source File : SpringJobFactory.java
License : Apache License 2.0
Project Creator : helloworldtang
License : Apache License 2.0
Project Creator : helloworldtang
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object jobInstance = super.createJobInstance(bundle);
applicationContext.getAutowireCapableBeanFactory().autowireBean(jobInstance);
return jobInstance;
}
19
View Source File : ReporterPluginManagerImpl.java
License : Apache License 2.0
Project Creator : gravitee-io
License : Apache License 2.0
Project Creator : gravitee-io
private <T> T create0(Plugin plugin, Clreplaced<T> auditReporterClreplaced, ReporterConfiguration reporterConfiguration, GraviteeContext context) {
if (auditReporterClreplaced == null) {
return null;
}
try {
T auditReporterObj = createInstance(auditReporterClreplaced);
final Import annImport = auditReporterClreplaced.getAnnotation(Import.clreplaced);
Set<Clreplaced<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext reporterApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Clreplaced<?>> configurations() {
return configurations;
}
@Override
public ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add reporter configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(new ReporterConfigurationBeanFactoryPostProcessor(reporterConfiguration));
// Add gravitee context bean to provide execution context information to the reporter.
// this is useful for some reporter like the file-reporter
if (context != null) {
configurableApplicationContext.addBeanFactoryPostProcessor(new GraviteeContextBeanFactoryPostProcessor(context));
}
return configurableApplicationContext;
}
});
if (auditReporterObj instanceof AbstractService) {
((AbstractService<?>) auditReporterObj).setApplicationContext(reporterApplicationContext);
}
reporterApplicationContext.getAutowireCapableBeanFactory().autowireBean(auditReporterObj);
if (auditReporterObj instanceof InitializingBean) {
((InitializingBean) auditReporterObj).afterPropertiesSet();
}
return auditReporterObj;
} catch (Exception ex) {
logger.error("An unexpected error occurs while loading reporter", ex);
return null;
}
}
19
View Source File : IdentityProviderPluginManagerImpl.java
License : Apache License 2.0
Project Creator : gravitee-io
License : Apache License 2.0
Project Creator : gravitee-io
private <T> T create0(Plugin plugin, Clreplaced<T> idenreplacedyClreplaced, IdenreplacedyProviderConfiguration idenreplacedyProviderConfiguration, IdenreplacedyProviderMapper idenreplacedyProviderMapper, IdenreplacedyProviderRoleMapper idenreplacedyProviderRoleMapper, CertificateManager certificateManager) {
if (idenreplacedyClreplaced == null) {
return null;
}
try {
T idenreplacedyObj = createInstance(idenreplacedyClreplaced);
final Import annImport = idenreplacedyClreplaced.getAnnotation(Import.clreplaced);
Set<Clreplaced<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext idpApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Clreplaced<?>> configurations() {
return configurations;
}
@Override
public ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add gravitee properties
configurableApplicationContext.addBeanFactoryPostProcessor(new PropertiesBeanFactoryPostProcessor(properties));
// Add Vert.x instance
configurableApplicationContext.addBeanFactoryPostProcessor(new VertxBeanFactoryPostProcessor(vertx));
// Add idenreplacedy provider configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(new IdenreplacedyProviderConfigurationBeanFactoryPostProcessor(idenreplacedyProviderConfiguration));
// Add idenreplacedy provider mapper bean
configurableApplicationContext.addBeanFactoryPostProcessor(new IdenreplacedyProviderMapperBeanFactoryPostProcessor(idenreplacedyProviderMapper != null ? idenreplacedyProviderMapper : new NoIdenreplacedyProviderMapper()));
// Add idenreplacedy provider role mapper bean
configurableApplicationContext.addBeanFactoryPostProcessor(new IdenreplacedyProviderRoleMapperBeanFactoryPostProcessor(idenreplacedyProviderRoleMapper != null ? idenreplacedyProviderRoleMapper : new NoIdenreplacedyProviderRoleMapper()));
if (certificateManager != null) {
// Add certificate manager bean
configurableApplicationContext.addBeanFactoryPostProcessor(new CertificateManagerBeanFactoryPostProcessor(certificateManager));
}
return configurableApplicationContext;
}
});
idpApplicationContext.getAutowireCapableBeanFactory().autowireBean(idenreplacedyObj);
if (idenreplacedyObj instanceof InitializingBean) {
((InitializingBean) idenreplacedyObj).afterPropertiesSet();
}
return idenreplacedyObj;
} catch (Exception ex) {
logger.error("An unexpected error occurs while loading idenreplacedy provider", ex);
return null;
}
}
19
View Source File : IdentityProviderPluginManagerImpl.java
License : Apache License 2.0
Project Creator : gravitee-io
License : Apache License 2.0
Project Creator : gravitee-io
private <T> T create0(Plugin plugin, Clreplaced<T> userProvider, IdenreplacedyProviderConfiguration idenreplacedyProviderConfiguration) {
try {
T idenreplacedyObj = createInstance(userProvider);
final Import annImport = userProvider.getAnnotation(Import.clreplaced);
Set<Clreplaced<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext idpApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Clreplaced<?>> configurations() {
return configurations;
}
@Override
public ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add gravitee properties
configurableApplicationContext.addBeanFactoryPostProcessor(new PropertiesBeanFactoryPostProcessor(properties));
// Add Vert.x instance
configurableApplicationContext.addBeanFactoryPostProcessor(new VertxBeanFactoryPostProcessor(vertx));
// Add idenreplacedy provider configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(new IdenreplacedyProviderConfigurationBeanFactoryPostProcessor(idenreplacedyProviderConfiguration));
return configurableApplicationContext;
}
});
idpApplicationContext.getAutowireCapableBeanFactory().autowireBean(idenreplacedyObj);
if (idenreplacedyObj instanceof InitializingBean) {
((InitializingBean) idenreplacedyObj).afterPropertiesSet();
}
return idenreplacedyObj;
} catch (Exception ex) {
logger.error("An unexpected error occurs while loading user provider", ex);
return null;
}
}
19
View Source File : FactorPluginManagerImpl.java
License : Apache License 2.0
Project Creator : gravitee-io
License : Apache License 2.0
Project Creator : gravitee-io
private <T> T create0(Plugin plugin, Clreplaced<T> idenreplacedyClreplaced, FactorConfiguration factorConfiguration) {
if (idenreplacedyClreplaced == null) {
return null;
}
try {
T idenreplacedyObj = createInstance(idenreplacedyClreplaced);
final Import annImport = idenreplacedyClreplaced.getAnnotation(Import.clreplaced);
Set<Clreplaced<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext idpApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Clreplaced<?>> configurations() {
return configurations;
}
@Override
public ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add authenticator configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(new FactorConfigurationBeanFactoryPostProcessor(factorConfiguration));
return configurableApplicationContext;
}
});
idpApplicationContext.getAutowireCapableBeanFactory().autowireBean(idenreplacedyObj);
if (idenreplacedyObj instanceof InitializingBean) {
((InitializingBean) idenreplacedyObj).afterPropertiesSet();
}
return idenreplacedyObj;
} catch (Exception ex) {
logger.error("An unexpected error occurs while loading factor", ex);
return null;
}
}
19
View Source File : ExtensionGrantPluginManagerImpl.java
License : Apache License 2.0
Project Creator : gravitee-io
License : Apache License 2.0
Project Creator : gravitee-io
private <T> T create0(Plugin plugin, Clreplaced<T> extensionGrantClreplaced, ExtensionGrantConfiguration extensionGrantConfiguration, AuthenticationProvider authenticationProvider) {
if (extensionGrantClreplaced == null) {
return null;
}
try {
T extensionGrantObj = createInstance(extensionGrantClreplaced);
final Import annImport = extensionGrantClreplaced.getAnnotation(Import.clreplaced);
Set<Clreplaced<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext extensionGrantApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Clreplaced<?>> configurations() {
return configurations;
}
@Override
public ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add extension grant configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(new ExtensionGrantConfigurationBeanFactoryPostProcessor(extensionGrantConfiguration));
// Add extension grant idenreplacedy provider bean
configurableApplicationContext.addBeanFactoryPostProcessor(new ExtensionGrantIdenreplacedyProviderFactoryPostProcessor(authenticationProvider != null ? authenticationProvider : new NoAuthenticationProvider()));
return configurableApplicationContext;
}
});
extensionGrantApplicationContext.getAutowireCapableBeanFactory().autowireBean(extensionGrantObj);
if (extensionGrantObj instanceof InitializingBean) {
((InitializingBean) extensionGrantObj).afterPropertiesSet();
}
return extensionGrantObj;
} catch (Exception ex) {
logger.error("An unexpected error occurs while loading extension grant", ex);
return null;
}
}
19
View Source File : CertificatePluginManagerImpl.java
License : Apache License 2.0
Project Creator : gravitee-io
License : Apache License 2.0
Project Creator : gravitee-io
private <T> T create0(Plugin plugin, Clreplaced<T> certificateClreplaced, CertificateConfiguration certificateConfiguration, CertificateMetadata metadata) {
if (certificateClreplaced == null) {
return null;
}
try {
T certificateObj = createInstance(certificateClreplaced);
final Import annImport = certificateClreplaced.getAnnotation(Import.clreplaced);
Set<Clreplaced<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext idpApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Clreplaced<?>> configurations() {
return configurations;
}
@Override
public ConfigurableApplicationContext applicationContext() {
ConfigurableApplicationContext configurableApplicationContext = super.applicationContext();
// Add certificate configuration bean
configurableApplicationContext.addBeanFactoryPostProcessor(new CertificateConfigurationBeanFactoryPostProcessor(certificateConfiguration));
// Add certificate metadata bean
configurableApplicationContext.addBeanFactoryPostProcessor(new CertificateMetadataBeanFactoryPostProcessor(metadata));
return configurableApplicationContext;
}
});
idpApplicationContext.getAutowireCapableBeanFactory().autowireBean(certificateObj);
if (certificateObj instanceof InitializingBean) {
((InitializingBean) certificateObj).afterPropertiesSet();
}
return certificateObj;
} catch (Exception ex) {
logger.error("An unexpected error occurs while loading certificate", ex);
return null;
}
}
19
View Source File : AutowireHelper.java
License : MIT License
Project Creator : apssouza22
License : MIT License
Project Creator : apssouza22
/**
* Tries to autowire the specified instance of the clreplaced if one of the
* specified beans which need to be autowired are null.
*
* @param clreplacedToAutowire the instance of the clreplaced which holds @Autowire
* annotations
* @param beansToAutowireInClreplaced the beans which have the @Autowire
* annotation in the specified {#clreplacedToAutowire}
*/
public static void autowire(Object clreplacedToAutowire, Object... beansToAutowireInClreplaced) {
for (Object bean : beansToAutowireInClreplaced) {
if (bean == null) {
applicationContext.getAutowireCapableBeanFactory().autowireBean(clreplacedToAutowire);
return;
}
}
}
19
View Source File : BeanUtils.java
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
public static <T extends SPIOrder & SPIEnabled> void addBeans(Clreplaced<T> cls, List<T> exists) {
if (context == null) {
return;
}
for (T instance : exists) {
context.getAutowireCapableBeanFactory().autowireBean(instance);
}
for (T bean : context.getBeansOfType(cls).values()) {
if (bean.enabled()) {
exists.add(bean);
}
}
exists.sort(Comparator.comparingInt(SPIOrder::getOrder));
}
19
View Source File : DubboConfigBeanDefinitionConflictApplicationListener.java
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
private BeanDefinitionRegistry getBeanDefinitionRegistry(ApplicationContext applicationContext) {
AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
if (beanFactory instanceof BeanDefinitionRegistry) {
return (BeanDefinitionRegistry) beanFactory;
}
throw new IllegalStateException("");
}
19
View Source File : ApplicationUtils.java
License : Apache License 2.0
Project Creator : alibaba
License : Apache License 2.0
Project Creator : alibaba
public static AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
return applicationContext.getAutowireCapableBeanFactory();
}
18
View Source File : SpringExtension.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Resolve a value for the {@link Parameter} in the supplied {@link ParameterContext} by
* retrieving the corresponding dependency from the test's {@link ApplicationContext}.
* <p>Delegates to {@link ParameterResolutionDelegate#resolveDependency}.
* @see #supportsParameter
* @see ParameterResolutionDelegate#resolveDependency
*/
@Override
@Nullable
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
Parameter parameter = parameterContext.getParameter();
int index = parameterContext.getIndex();
Clreplaced<?> testClreplaced = extensionContext.getRequiredTestClreplaced();
ApplicationContext applicationContext = getApplicationContext(extensionContext);
return ParameterResolutionDelegate.resolveDependency(parameter, index, testClreplaced, applicationContext.getAutowireCapableBeanFactory());
}
18
View Source File : ScannerMappingsUpdaterServiceImpl.java
License : Mozilla Public License 2.0
Project Creator : secdec
License : Mozilla Public License 2.0
Project Creator : secdec
private List<Updater> getUpdaters(ApplicationContext applicationContext) {
if (updaters == null) {
updaters = AnnotationLoader.getListOfConcreteClreplaced(MappingsUpdater.clreplaced, "com.denimgroup.threadfix.importer.update.impl", Updater.clreplaced);
if (applicationContext != null) {
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
bpp.setBeanFactory(applicationContext.getAutowireCapableBeanFactory());
for (Updater updater : updaters) {
bpp.processInjection(updater);
}
} else {
replacedert false : "ApplicationContext was null, unable to autowire.";
}
}
Collections.sort(updaters, OrderComparator.INSTANCE);
return updaters;
}
18
View Source File : AbstractSpringManagedBeanFactory.java
License : Apache License 2.0
Project Creator : rico-projects
License : Apache License 2.0
Project Creator : rico-projects
@Override
public <T> T createDependentInstance(final Clreplaced<T> cls, final PostConstructInterceptor<T> interceptor) {
replacedert.requireNonNull(cls, "cls");
replacedert.requireNonNull(interceptor, "interceptor");
final ApplicationContext context = getContext();
final AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
SpringPreInjector.getInstance().prepare(cls, interceptor);
return beanFactory.createBean(cls);
}
18
View Source File : AbstractSpringManagedBeanFactory.java
License : Apache License 2.0
Project Creator : rico-projects
License : Apache License 2.0
Project Creator : rico-projects
@Override
public <T> T createDependentInstance(final Clreplaced<T> cls) {
replacedert.requireNonNull(cls, "cls");
final ApplicationContext context = getContext();
final AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
return beanFactory.createBean(cls);
}
18
View Source File : PicocliSpringFactory.java
License : Apache License 2.0
Project Creator : remkop
License : Apache License 2.0
Project Creator : remkop
private <K> K getBeanOrCreate(Clreplaced<K> clazz) {
try {
return applicationContext.getBean(clazz);
} catch (Exception e) {
return applicationContext.getAutowireCapableBeanFactory().createBean(clazz);
}
}
18
View Source File : SysInitializeAction.java
License : GNU Affero General Public License v3.0
Project Creator : qlangtech
License : GNU Affero General Public License v3.0
Project Creator : qlangtech
public static void systemDataInitialize() throws Exception {
SysInitializeAction initAction = new SysInitializeAction();
// ClreplacedPathXmlApplicationContext tis.application.context.xml src/main/resources/tis.application.mockable.context.xml
ApplicationContext appContext = new ClreplacedPathXmlApplicationContext("clreplacedpath:/tis.application.context.xml", "clreplacedpath:/tis.application.mockable.context.xml");
appContext.getAutowireCapableBeanFactory().autowireBeanProperties(initAction, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
initAction.doInit();
}
18
View Source File : DefaultScheduler.java
License : Apache License 2.0
Project Creator : OpenWiseSolutions
License : Apache License 2.0
Project Creator : OpenWiseSolutions
/**
* Create new instance of {@link Scheduler}.
*
* @return scheduler
*/
protected synchronized Scheduler createScheduler() {
try {
LOG.info("Create scheduler {}.", schedulerName);
SchedulerFactoryBean result = new SchedulerFactoryBean();
result.setJobFactory(jobFactory);
if (dataSource != null) {
result.setDataSource(dataSource);
}
if (quartzConfProperties != null) {
result.setQuartzProperties(quartzConfProperties);
}
if (taskExecutor != null) {
result.setTaskExecutor(taskExecutor);
}
result.setAutoStartup(false);
result.setSchedulerName(schedulerName);
result.setWaitForJobsToCompleteOnShutdown(true);
result.setOverwriteExistingJobs(true);
// create triggers
List<Trigger> triggers = new LinkedList<>();
if (!CollectionUtils.isEmpty(triggerFactories)) {
for (TriggerFactory triggerFactory : triggerFactories) {
triggers.addAll(triggerFactory.createTriggers(getJobExecuteType()));
}
}
if (!triggers.isEmpty()) {
result.setTriggers(triggers.toArray(new Trigger[triggers.size()]));
}
// autowire all and initialize the bean
ctx.getAutowireCapableBeanFactory().autowireBean(result);
ctx.getAutowireCapableBeanFactory().initializeBean(result, schedulerName + "_FACTORY");
return result.getObject();
} catch (Exception e) {
throw new IllegalStateException("Error in creating scheduler. Error: " + e.getMessage());
}
}
18
View Source File : TurNLP.java
License : GNU General Public License v3.0
Project Creator : openturing
License : GNU General Public License v3.0
Project Creator : openturing
public Map<String, Object> retrieveNLP() throws JSONException {
logger.debug("Executing retrieveNLP...");
TurNLPImpl nlpService;
try {
nlpService = (TurNLPImpl) Clreplaced.forName(turNLPVendor.getPlugin()).newInstance();
ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
applicationContext.getAutowireCapableBeanFactory().autowireBean(nlpService);
nlpService.startup(turNLPInstance);
this.setNlpAttributes(nlpService.retrieve(this.getAttributes()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (logger.isDebugEnabled() && this.getNlpAttributes() != null) {
logger.debug("Result retrieveNLP: " + this.getNlpAttributes().toString());
}
return this.getNlpAttributes();
}
18
View Source File : RocketMQConfig.java
License : MIT License
Project Creator : MartinDai
License : MIT License
Project Creator : MartinDai
@Override
public void afterPropertiesSet() throws MQClientException {
clearUserProducer = new TransactionMQProducer(clearUserGroup);
clearUserProducer.setNamesrvAddr(nameServerAddress);
ExecutorService executorService = new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<>(2000), r -> {
Thread thread = new Thread(r);
thread.setName("client-transaction-msg-check-thread");
return thread;
});
clearUserProducer.setExecutorService(executorService);
clearUserProducer.setTransactionListener(applicationContext.getAutowireCapableBeanFactory().getBean(ClearUserTransactionListener.clreplaced));
clearUserProducer.start();
clearUserConsumer = new DefaultMQPushConsumer(clearUserGroup);
clearUserConsumer.setNamesrvAddr(nameServerAddress);
clearUserConsumer.subscribe(clearUserTopic, "*");
clearUserConsumer.registerMessageListener(applicationContext.getAutowireCapableBeanFactory().getBean(ClearUserMessageListener.clreplaced));
clearUserConsumer.start();
chatRecordProducer = new DefaultMQProducer(chatRecordGroup);
chatRecordProducer.setNamesrvAddr(nameServerAddress);
chatRecordProducer.start();
chatRecordConsumer = new DefaultMQPushConsumer(chatRecordGroup);
chatRecordConsumer.setNamesrvAddr(nameServerAddress);
chatRecordConsumer.subscribe(chatRecordTopic, chatRecordTags);
chatRecordConsumer.registerMessageListener(applicationContext.getAutowireCapableBeanFactory().getBean(ChatRecordMessageListener.clreplaced));
chatRecordConsumer.start();
}
18
View Source File : JuiserAuthenticationFilterRegistrar.java
License : Apache License 2.0
Project Creator : juiser
License : Apache License 2.0
Project Creator : juiser
@Override
public void init(HttpSecurity http) throws Exception {
// autowire this bean
ApplicationContext context = http.getSharedObject(ApplicationContext.clreplaced);
context.getAutowireCapableBeanFactory().autowireBean(this);
boolean springSecurityEnabled = forwardedHeaderConfig.getJwt() instanceof SpringSecurityJwtConfig;
if (springSecurityEnabled) {
String headerName = forwardedHeaderConfig.getName();
HeaderAuthenticationFilter filter = new HeaderAuthenticationFilter(headerName, authenticationManager);
http.addFilterBefore(filter, UsernamePreplacedwordAuthenticationFilter.clreplaced);
}
// else juiser.security.enabled is false or spring security is disabled via a property
}
18
View Source File : JdbcAuditReporterTest.java
License : Apache License 2.0
Project Creator : gravitee-io
License : Apache License 2.0
Project Creator : gravitee-io
@Before
public void init() throws Exception {
auditReporter = new JdbcAuditReporter();
context.getAutowireCapableBeanFactory().autowireBean(auditReporter);
if (auditReporter instanceof InitializingBean) {
((InitializingBean) auditReporter).afterPropertiesSet();
}
// wait for the schema initialization
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
17
View Source File : JobConfigure.java
License : MIT License
Project Creator : wuyouzhuguli
License : MIT License
Project Creator : wuyouzhuguli
/**
* 注册JobRegistryBeanPostProcessor bean
* 用于将任务名称和实际的任务关联起来
*/
@Bean
public JobRegistryBeanPostProcessor processor(JobRegistry jobRegistry, ApplicationContext applicationContext) {
JobRegistryBeanPostProcessor postProcessor = new JobRegistryBeanPostProcessor();
postProcessor.setJobRegistry(jobRegistry);
postProcessor.setBeanFactory(applicationContext.getAutowireCapableBeanFactory());
return postProcessor;
}
17
View Source File : HandlerMappingIntrospector.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private static List<HandlerMapping> initFallback(ApplicationContext applicationContext) {
Properties props;
String path = "DispatcherServlet.properties";
try {
Resource resource = new ClreplacedPathResource(path, DispatcherServlet.clreplaced);
props = PropertiesLoaderUtils.loadProperties(resource);
} catch (IOException ex) {
throw new IllegalStateException("Could not load '" + path + "': " + ex.getMessage());
}
String value = props.getProperty(HandlerMapping.clreplaced.getName());
String[] names = StringUtils.commaDelimitedListToStringArray(value);
List<HandlerMapping> result = new ArrayList<>(names.length);
for (String name : names) {
try {
Clreplaced<?> clazz = ClreplacedUtils.forName(name, DispatcherServlet.clreplaced.getClreplacedLoader());
Object mapping = applicationContext.getAutowireCapableBeanFactory().createBean(clazz);
result.add((HandlerMapping) mapping);
} catch (ClreplacedNotFoundException ex) {
throw new IllegalStateException("Could not find default HandlerMapping [" + name + "]");
}
}
return result;
}
17
View Source File : SqlScriptsTestExecutionListenerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void isolatedTxModeDeclaredWithoutTxMgr() throws Exception {
ApplicationContext ctx = mock(ApplicationContext.clreplaced);
given(ctx.getResource(anyString())).willReturn(mock(Resource.clreplaced));
given(ctx.getAutowireCapableBeanFactory()).willReturn(mock(AutowireCapableBeanFactory.clreplaced));
Clreplaced<?> clazz = IsolatedWithoutTxMgr.clreplaced;
BDDMockito.<Clreplaced<?>>given(testContext.getTestClreplaced()).willReturn(clazz);
given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo"));
given(testContext.getApplicationContext()).willReturn(ctx);
replacedertExceptionContains("cannot execute SQL scripts using Transaction Mode [ISOLATED] without a PlatformTransactionManager");
}
17
View Source File : SqlScriptsTestExecutionListenerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void missingDataSourceAndTxMgr() throws Exception {
ApplicationContext ctx = mock(ApplicationContext.clreplaced);
given(ctx.getResource(anyString())).willReturn(mock(Resource.clreplaced));
given(ctx.getAutowireCapableBeanFactory()).willReturn(mock(AutowireCapableBeanFactory.clreplaced));
Clreplaced<?> clazz = MissingDataSourceAndTxMgr.clreplaced;
BDDMockito.<Clreplaced<?>>given(testContext.getTestClreplaced()).willReturn(clazz);
given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo"));
given(testContext.getApplicationContext()).willReturn(ctx);
replacedertExceptionContains("supply at least a DataSource or PlatformTransactionManager");
}
17
View Source File : ShFormComponent.java
License : GNU General Public License v3.0
Project Creator : ShioCMS
License : GNU General Public License v3.0
Project Creator : ShioCMS
public String byPostType(String shPostTypeName, String shObjectId, HttpServletRequest request) {
final Context ctx = new Context();
ShFormConfiguration shFormConfiguration = null;
ShObjectImpl shObject = shObjectRepository.findById(shObjectId).orElse(null);
ShPostType shPostType = shPostTypeRepository.findByName(shPostTypeName);
CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.clreplaced.getName());
List<String> fields = new ArrayList<>();
List<ShPostTypeAttr> postTypeAttrByOrdinal = new ArrayList<>(shPostType.getShPostTypeAttrs());
Collections.sort(postTypeAttrByOrdinal, (ShPostTypeAttr o1, ShPostTypeAttr o2) -> o1.getOrdinal() - o2.getOrdinal());
for (ShPostTypeAttr shPostTypeAttr : postTypeAttrByOrdinal) {
String clreplacedName = shPostTypeAttr.getShWidget().getClreplacedName();
try {
ShWidgetImplementation object = (ShWidgetImplementation) Clreplaced.forName(clreplacedName).getDeclaredConstructor().newInstance();
applicationContext.getAutowireCapableBeanFactory().autowireBean(object);
fields.add(object.render(shPostTypeAttr, shObject));
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClreplacedNotFoundException e) {
logger.error(e);
}
if (shPostTypeAttr.getShWidget().getName().equals(ShSystemWidget.FORM_CONFIGURATION)) {
JSONObject formConfiguration = new JSONObject(shPostTypeAttr.getWidgetSettings());
shFormConfiguration = new ShFormConfiguration(formConfiguration);
}
}
String token = null;
if (csrf != null) {
token = csrf.getToken();
}
String method = "POST";
if (shFormConfiguration != null) {
method = shFormConfiguration.getMethod().toString();
}
ctx.setVariable("token", token);
ctx.setVariable("shPostType", shPostType);
ctx.setVariable("shPostTypeAttrs", shPostType.getShPostTypeAttrs());
ctx.setVariable("fields", fields);
ctx.setVariable("method", method);
return templateEngine.process("form", ctx);
}
17
View Source File : ShFormUtils.java
License : GNU General Public License v3.0
Project Creator : ShioCMS
License : GNU General Public License v3.0
Project Creator : ShioCMS
private void getWidget(ShPostTypeAttr shPostTypeAttr) {
String clreplacedName = shPostTypeAttr.getShWidget().getClreplacedName();
ShWidgetImplementation object;
try {
object = (ShWidgetImplementation) Clreplaced.forName(clreplacedName).getDeclaredConstructor().newInstance();
applicationContext.getAutowireCapableBeanFactory().autowireBean(object);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClreplacedNotFoundException e) {
logger.error(e);
}
}
17
View Source File : AuditFactory.java
License : Apache License 2.0
Project Creator : Pardus-Engerek
License : Apache License 2.0
Project Creator : Pardus-Engerek
public AuditService getAuditService() {
if (auditService == null) {
AuditServiceProxy proxy = new AuditServiceProxy();
for (AuditServiceFactory factory : serviceFactories) {
try {
AuditService service = factory.getAuditService();
// todo check this autowiring (check logs) how it's done
applicationContext.getAutowireCapableBeanFactory().autowireBean(service);
proxy.registerService(service);
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "Couldn't get audit service from factory '{}'", ex, factory);
throw new SystemException(ex.getMessage(), ex);
}
}
auditService = proxy;
}
return auditService;
}
17
View Source File : MicroInjectSpringPlugin.java
License : Apache License 2.0
Project Creator : jeffreyning
License : Apache License 2.0
Project Creator : jeffreyning
public GroovyObject execPlugIn(String name, GroovyObject groovyObject, GroovyObject proxyObject) throws Exception {
ApplicationContext context = MicroContextHolder.getContext();
AutowireCapableBeanFactory autowireCapableBeanFactory = context.getAutowireCapableBeanFactory();
autowireCapableBeanFactory.autowireBeanProperties(groovyObject, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
return proxyObject;
}
17
View Source File : FileAuditReporterTest.java
License : Apache License 2.0
Project Creator : gravitee-io
License : Apache License 2.0
Project Creator : gravitee-io
@Before
public void init() throws Exception {
auditReporter = new FileAuditReporter();
context.getAutowireCapableBeanFactory().autowireBean(auditReporter);
((AbstractService) auditReporter).setApplicationContext(context);
if (auditReporter instanceof InitializingBean) {
((InitializingBean) auditReporter).afterPropertiesSet();
}
auditReporter.start();
waitBulkLoadFlush();
}
17
View Source File : ProducerSteps.java
License : MIT License
Project Creator : davidmarquis
License : MIT License
Project Creator : davidmarquis
@SuppressWarnings("unchecked")
private MessageProducer<String> aMessageProducer(String queue) {
DefaultMessageProducer<String> producer = ctx.getAutowireCapableBeanFactory().createBean(DefaultMessageProducer.clreplaced);
producer.setQueue(queueSteps.queueWithName(queue));
return producer;
}
17
View Source File : BeanRegisterUtils.java
License : Apache License 2.0
Project Creator : chanjarster
License : Apache License 2.0
Project Creator : chanjarster
public static void registerSingleton(ApplicationContext applicationContext, String beanName, Object singletonObject) {
AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
if (!SingletonBeanRegistry.clreplaced.isreplacedignableFrom(beanFactory.getClreplaced())) {
throw new IllegalArgumentException("ApplicationContext: " + applicationContext.getClreplaced().toString() + " doesn't implements SingletonBeanRegistry, cannot register JMS connection at runtime");
}
SingletonBeanRegistry beanDefinitionRegistry = (SingletonBeanRegistry) beanFactory;
beanDefinitionRegistry.registerSingleton(beanName, singletonObject);
}
16
View Source File : JupiterConfig.java
License : MIT License
Project Creator : yizzuide
License : MIT License
Project Creator : yizzuide
@Override
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
JupiterCompilerPool.put(JupiterCompilerType.EL.toString(), new JupiterElCompiler());
JupiterCompilerPool.put(JupiterCompilerType.OGNL.toString(), new JupiterOnglCompiler());
Clreplaced<? extends JupiterRuleEngine> ruleEngineClreplaced = null;
if (props.getRuleEngineClazz() != null) {
ruleEngineClreplaced = props.getRuleEngineClazz();
} else {
if (props.getType() == JupiterRuleEngineType.SCOPE) {
ruleEngineClreplaced = JupiterScopeRuleEngine.clreplaced;
}
}
JupiterRuleEngine jupiterRuleEngine = WebContext.registerBean((ConfigurableApplicationContext) applicationContext, JupiterRuleEngine.BEAN_ID, ruleEngineClreplaced);
applicationContext.getAutowireCapableBeanFactory().autowireBean(jupiterRuleEngine);
Map<String, JupiterProperties.Rule> rules = props.getRules();
if (CollectionUtils.isEmpty(rules)) {
return;
}
for (Map.Entry<String, JupiterProperties.Rule> ruleEntry : rules.entrySet()) {
List<JupiterRuleItem> jupiterRuleItemList = new ArrayList<>();
for (Map.Entry<String, JupiterProperties.RuleItem> ruleItemEntry : ruleEntry.getValue().getRuleItems().entrySet()) {
JupiterProperties.RuleItem ruleItem = ruleItemEntry.getValue();
jupiterRuleItemList.add(JupiterRuleItem.copyFrom(ruleItem));
}
jupiterRuleEngine.addRule(ruleEntry.getKey(), jupiterRuleItemList);
}
}
16
View Source File : KernelExtension.java
License : MIT License
Project Creator : sunshower-io
License : MIT License
Project Creator : sunshower-io
@Override
@Nullable
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
Parameter parameter = parameterContext.getParameter();
int index = parameterContext.getIndex();
Clreplaced<?> testClreplaced = extensionContext.getRequiredTestClreplaced();
ApplicationContext applicationContext = getApplicationContext(extensionContext);
return ParameterResolutionDelegate.resolveDependency(parameter, index, testClreplaced, applicationContext.getAutowireCapableBeanFactory());
}
16
View Source File : SqlScriptsTestExecutionListenerTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
void isolatedTxModeDeclaredWithoutTxMgr() throws Exception {
ApplicationContext ctx = mock(ApplicationContext.clreplaced);
given(ctx.getResource(anyString())).willReturn(mock(Resource.clreplaced));
given(ctx.getAutowireCapableBeanFactory()).willReturn(mock(AutowireCapableBeanFactory.clreplaced));
Clreplaced<?> clazz = IsolatedWithoutTxMgr.clreplaced;
BDDMockito.<Clreplaced<?>>given(testContext.getTestClreplaced()).willReturn(clazz);
given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo"));
given(testContext.getApplicationContext()).willReturn(ctx);
replacedertExceptionContains("cannot execute SQL scripts using Transaction Mode [ISOLATED] without a PlatformTransactionManager");
}
See More Examples