@Override public Object resolveParameterValue(Message message) { return beanFactory.getBean(beanName); }
AgentCommand get(final String requestedCommandName) { final Class<? extends AgentCommand> commandClass = commandMap.get(requestedCommandName); final AgentCommand commandInstance; if (commandClass == null) { log.error("Command not found: {}", requestedCommandName); commandInstance = null; } else { commandInstance = applicationContext.getAutowireCapableBeanFactory().getBean(commandClass); } return commandInstance; }
VersionInfoService getVersionInfoService() { return this.getApplicationContext().getAutowireCapableBeanFactory().getBean(VersionInfoService.class); }
MaintenanceModeService getMaintenanceModeService() { return this.getApplicationContext().getAutowireCapableBeanFactory().getBean(MaintenanceModeService.class); }
WebpackAssetsService webpackAssetsService() { return this.getApplicationContext().getAutowireCapableBeanFactory().getBean(WebpackAssetsService.class); }
RailsAssetsService getRailsAssetsService() { return this.getApplicationContext().getAutowireCapableBeanFactory().getBean(RailsAssetsService.class); }
DefaultPluginInfoFinder getPluginInfoFinder() { return this.getApplicationContext().getAutowireCapableBeanFactory().getBean(DefaultPluginInfoFinder.class); }
SecurityService getSecurityService() { return this.getApplicationContext().getAutowireCapableBeanFactory().getBean(SecurityService.class); }
@Test public void accessAfterClosing() { GenericApplicationContext ac = new GenericApplicationContext(); ac.registerBeanDefinition("testBean", new RootBeanDefinition(String.class)); ac.refresh(); assertSame(ac.getBean("testBean"), ac.getBean(String.class)); assertSame(ac.getAutowireCapableBeanFactory().getBean("testBean"), ac.getAutowireCapableBeanFactory().getBean(String.class)); ac.close(); try { assertSame(ac.getBean("testBean"), ac.getBean(String.class)); fail("Should have thrown IllegalStateException"); } catch (IllegalStateException ex) { // expected } try { assertSame(ac.getAutowireCapableBeanFactory().getBean("testBean"), ac.getAutowireCapableBeanFactory().getBean(String.class)); fail("Should have thrown IllegalStateException"); } catch (IllegalStateException ex) { // expected } }
public HalFormsHandlerInstantiator(RelProvider relProvider, CurieProvider curieProvider, MessageSourceAccessor messageSource, boolean enforceEmbeddedCollections, AutowireCapableBeanFactory beanFactory) { this(relProvider, curieProvider, messageSource, enforceEmbeddedCollections, beanFactory.getBean(HalFormsConfiguration.class)); }
public HalHandlerInstantiator(RelProvider provider, CurieProvider curieProvider, MessageSourceAccessor messageSourceAccessor, AutowireCapableBeanFactory beanFactory) { this(provider, curieProvider, messageSourceAccessor, beanFactory, beanFactory.getBean(HalConfiguration.class)); }
void pollDirectories(File... directories) { for (File directory : directories) { StandardIntegrationFlow integrationFlow = IntegrationFlows .from(Files.inboundAdapter(directory) .scanner(new DefaultDirectoryScanner()), e -> e.poller(p -> p.fixedDelay(1000)) .id(directory.getName() + ".adapter")) .transform(Files.toStringTransformer(), e -> e.id(directory.getName() + ".transformer")) .channel(this.dynamicAdaptersResult) .get(); this.beanFactory.initializeBean(integrationFlow, directory.getName()); this.beanFactory.getBean(directory.getName() + ".transformer", Lifecycle.class).start(); this.beanFactory.getBean(directory.getName() + ".adapter", Lifecycle.class).start(); } }
AgentCommand get(final String requestedCommandName) { final Class<? extends AgentCommand> commandClass = commandMap.get(requestedCommandName); final AgentCommand commandInstance; if (commandClass == null) { log.error("Command not found: {}", requestedCommandName); commandInstance = null; } else { commandInstance = applicationContext.getAutowireCapableBeanFactory().getBean(commandClass); } return commandInstance; }
@Autowired public MyService(AutowireCapableBeanFactory factory, TaskScheduler scheduler) { MyFirstCommand command1 = factory.getBean(MyFirstCommand.class); MySecondCommand command2 = factory.getBean(MySecondCommand.class); scheduler.schedule(command2, new Date()); scheduler.schedule(command1, new Date()); }
private <T extends ConstraintValidator<?, ?>> T findValidatorImplementation(Class<T> key) { T bean = null; try { trace("Trying to find a validator bean of class {}", key.getSimpleName()); bean = this.beanFactory.getBean(key); } catch (BeansException exc) { trace("Failed to find a bean of class {}", key.getSimpleName()); trace(exc); } return bean; }
@Nonnull @Override public <T> T provideFor(@Nonnull String name, @Nonnull Class<T> clazz, @Nonnull Type type) { final T result; final AutowireCapableBeanFactory beanFactory = getBeanFactory(); if (beanFactory.containsBean(name)) { validateTypeAgainstBeanConfiguration(name, type); result = beanFactory.getBean(name, clazz); } else if (isCreateLocaleBeansIfNotPresentInApplicationContext()) { result = type == singleton ? getLocalCreatedAndConfiguredSingleton(name, clazz) : createInstanceAndConfigure(name, clazz); } else { throw new IllegalArgumentException("No such bean named '" + name + "' found."); } return result; }
@Override public RedisClient createRedisClient() { return new RedisClient(ApplicationContextProvider.getAutowireCapableBeanFactory().getBean(RedisClientProvider.class).getRedisClient()); } }
@Override protected HandlerMethod createHandlerMethod(Object handler, Method method) { if (handler instanceof String) { String beanName = (String) handler; handler = this.getApplicationContext().getAutowireCapableBeanFactory().getBean(beanName); } if (AnnotatedElementUtils.hasAnnotation(method, WxAsyncMessage.class) || AnnotatedElementUtils.hasAnnotation(handler.getClass(), WxAsyncMessage.class)) { return new HandlerMethod(wxAsyncHandlerFactory.createHandler(handler), method); } else { return new HandlerMethod(handler, method); } }
/** * Handles a new incoming connection. * * @param newConnection The new incoming connection */ private void handleNewConnection(Connection newConnection) { this.context.registerBean("network.newConnection.raknet", Connection.class, () -> newConnection); this.context.registerBean("network.newConnection.tcp", ConnectionHandler.class, () -> null); PlayerConnection playerConnection = this.context.getAutowireCapableBeanFactory().getBean(PlayerConnection.class); this.incomingConnections.add(playerConnection); this.context.removeBeanDefinition("network.newConnection.raknet"); this.context.removeBeanDefinition("network.newConnection.tcp"); }
public void pollDirectories(File... directories) { for (File directory : directories) { StandardIntegrationFlow integrationFlow = IntegrationFlows .from(s -> s.file(directory) .scanner(new DefaultDirectoryScanner()), e -> e.poller(p -> p.fixedDelay(1000)) .id(directory.getName() + ".adapter")) .transform(Transformers.fileToString(), e -> e.id(directory.getName() + ".transformer")) .channel(this.dynamicAdaptersResult) .get(); this.beanFactory.initializeBean(integrationFlow, directory.getName()); this.beanFactory.getBean(directory.getName() + ".transformer", Lifecycle.class).start(); this.beanFactory.getBean(directory.getName() + ".adapter", Lifecycle.class).start(); } }