@Bean @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES) public DefaultOAuth2ClientContext oauth2ClientContext() { DefaultOAuth2ClientContext context = new DefaultOAuth2ClientContext( new DefaultAccessTokenRequest()); Authentication principal = SecurityContextHolder.getContext() .getAuthentication(); if (principal instanceof OAuth2Authentication) { OAuth2Authentication authentication = (OAuth2Authentication) principal; Object details = authentication.getDetails(); if (details instanceof OAuth2AuthenticationDetails) { OAuth2AuthenticationDetails oauthsDetails = (OAuth2AuthenticationDetails) details; String token = oauthsDetails.getTokenValue(); context.setAccessToken(new DefaultOAuth2AccessToken(token)); } } return context; }
@Bean @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public AuditorAware<Username> auditorAware() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); log.debug("current authentication:" + authentication); if (authentication == null || !authentication.isAuthenticated()) { return () -> Optional.<Username>empty(); } return () -> Optional.of( Username.builder() .username(((UserDetails) authentication.getPrincipal()).getUsername()) .build() ); }
@Bean @ConditionalOnMissingBean(Facebook.class) @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES) public Facebook facebook(ConnectionRepository repository) { Connection<Facebook> connection = repository .findPrimaryConnection(Facebook.class); return connection != null ? connection.getApi() : null; }
/** * Configures the AOP file System watcher to observe the paths passed in for the * jboss aop folder. */ @Bean @Scope(BeanDefinition.SCOPE_SINGLETON) @Autowired public AopXmlLoader aopFolderWatcher(Environment env) throws JaffaRulesFrameworkException { // Check to see if this is supported. If explicitly disabled, then return early. if (env.containsProperty("jaffa.aop.springconfig.disabled") && env.getProperty("jaffa.aop.springconfig.disabled").equals("true")) { return null; } String aopPath = env.containsProperty("jboss.aop.path") ? env.getProperty("jboss.aop.path") : AopConstants.DEFAULT_AOP_PATTERN; List<String> paths = Arrays.asList(aopPath.split(";")); return new AopXmlLoader(paths); }
@Bean @Scope("singleton") @Qualifier("operationIgniteClient") @ConditionalOnMissingBean(KafkaOperationRepository.class) public Ignite createIgnite(ApplicationContext applicationContext) throws IgniteCheckedException { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setClientMode(true); cfg.setPeerClassLoadingEnabled(false); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); ipFinder.setAddresses(Arrays.asList(clientAddress.split(","))); discoSpi.setIpFinder(ipFinder); cfg.setDiscoverySpi(discoSpi); cfg.setMetricsLogFrequency(0); return IgniteSpring.start(cfg,applicationContext); }
@Bean @Scope(scopeName = "prototype") @SuppressWarnings("unchecked") public <ITEM> Grid<ITEM> configureBeanGrid(DependencyDescriptor dependencyDescriptor) { logger.debug("Configuring Vaadin Grid as bean"); long timestamp = System.currentTimeMillis(); ResolvableType injectionPointType = dependencyDescriptor.getResolvableType(); if (!injectionPointType.hasGenerics()) { throw new IllegalStateException("Grid injection point is expected to declare a static item type"); } ResolvableType genericType = injectionPointType.getGeneric(); Class<ITEM> itemType = (Class<ITEM>) genericType.resolve(); logger.debug("Vaadin Grid will use " + itemType.getCanonicalName() + " as item type"); Grid<ITEM> grid = configureGridInstance(itemType); long configTime = System.currentTimeMillis() - timestamp; logger.debug("Done configuring Grid for " + itemType.getName() + " in " + configTime + "ms"); return grid; }
@Bean @Scope(BeanDefinition.SCOPE_PROTOTYPE) public Menu fileMenu() { Menu file = new Menu(localeService.getMessage("ui.menu.file")); file.setMnemonicParsing(false); MenuItem connect = new MenuItem(localeService.getMessage("ui.menu.file.connect")); connect.setMnemonicParsing(false); connect.setOnAction(event -> newConnectionBox(getMainView().getPrimaryStage(), (data) -> getMainController().loadTables(data))); MenuItem manager = new MenuItem(localeService.getMessage("ui.menu.file.manager")); manager.setMnemonicParsing(false); manager.setOnAction(event -> connectionManager()); file.getItems().addAll(connect, manager); return file; }
/** * Configure the MaxValue Validator * * @return MaxValue Validator */ @Bean(name = "max-value") @Scope(BeanDefinition.SCOPE_PROTOTYPE) public MaxValueValidator maxValueValidator() { MaxValueValidator validator = new MaxValueValidator(); validator.setRuleEvaluator(ruleHelper()); return validator; }
@Bean @Scope(value = "prototype") public IStreamProcessor StreamProcessor(int mode, String clientIdentifier, String channel, String profile) { String identifier = new Date().getTime() + clientIdentifier; String identifier64 = new String(Base64.getEncoder().encode(identifier.getBytes())); HttpSoureStreamProcessor sourceStreamProcessor = (HttpSoureStreamProcessor) context.getBean("HttpSoureStreamProcessor", identifier64, channel); IStreamProcessor streamProcessor = null; if (profile==null) { streamProcessor = sourceStreamProcessor; } else { //streamProcessor = (IStreamProcessor) context.getBean("TranscodedStreamProcessor", identifier64, sourceStreamProcessor, profile); streamProcessor = (IStreamProcessor) context.getBean("DirectTranscodedStreamProcessor", identifier64, channel, profile); } IStreamProcessor postStreamProcessor = null; switch (mode) { case ProxyLiveConstants.HLS_MODE: postStreamProcessor = (IStreamProcessor) context.getBean("HLSStreamProcessor", identifier64, streamProcessor); break; case ProxyLiveConstants.STREAM_MODE: postStreamProcessor = streamProcessor; break; } return postStreamProcessor; }
/** * Configure the MinLength Validator * * @return MinLength Validator */ @Bean(name = "min-length") @Scope(BeanDefinition.SCOPE_PROTOTYPE) public MinLengthValidator minLengthValidator() { MinLengthValidator validator = new MinLengthValidator(); validator.setRuleEvaluator(ruleHelper()); return validator; }
@Bean(name="empRec2") @Scope("prototype") public Employee getEmpRecord2(){ Employee empRec2 = new Employee(); empRec2.setFirstName("Juan"); empRec2.setLastName("Luna"); empRec2.setAge(50); empRec2.setBirthdate(new Date(45,9,30)); empRec2.setPosition("historian"); empRec2.setSalary(100000.00); empRec2.setDept(getDept2()); return empRec2; }
/** * Configure the GenericForeignKey Validator * * @return GenericForeignKey Validator */ @Bean(name = "generic-foreign-key") @Scope(BeanDefinition.SCOPE_PROTOTYPE) public GenericForeignKeyValidator genericForeignKeyValidator() { GenericForeignKeyValidator validator = new GenericForeignKeyValidator(); validator.setRuleEvaluator(ruleHelper()); return validator; }
@Bean @Scope(AppScope.APP_SCOPE) IAppModelFacade modelFacade(String appName, IDataSourceConnector connector, IDataChangePoller dataChangePoller, IWebServiceClient dataFacadeWebServiceClient, ZKConfig config) { return new AppModelRestFacade.Builder() .withConnector(connector) .forApplication(appName) .withDataChangePoller(dataChangePoller) .withWebServiceClient(dataFacadeWebServiceClient) .withZkConfig(config) .build(); }
@Bean @Scope(SCOPE_SINGLETON) protected LepManager lepManager() { return new SpringLepManager(extensionService(), lepExecutor(), applicationLepProcessingEventPublisher(), lepResourceService()); }
@Bean @Scope("prototype") public MessageCodec messageCodec() { MessageCodec codec = new MessageCodec(); codec.setMaxFramePayloadSize(16); System.out.println("SysPropConfig1.messageCodec"); return codec; }
@Bean @Scope("prototype") public MessageCodec messageCodec() { MessageCodec codec = new MessageCodec(); codec.setMaxFramePayloadSize(16); System.out.println("SysPropConfig2.messageCodec"); return codec; }
@Bean @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES) public Google google(final ConnectionRepository repository) { final Connection<Google> connection = repository .findPrimaryConnection(Google.class); return connection != null ? connection.getApi() : null; }
@Bean @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES) public GitHub gitHub(ConnectionRepository repository) { Connection<GitHub> connection = repository .findPrimaryConnection(GitHub.class); return connection != null ? connection.getApi() : null; }
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) @Bean(name = "verifier-context", initMethod = "start", destroyMethod = "stop") public static CamelContext verifierContext() { CamelContext context = new DefaultCamelContext(); context.setNameStrategy(new ExplicitCamelContextNameStrategy("verifier-context")); context.disableJMX(); return context; }
@Bean("twitter") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) @Lazy @ConditionalOnProperty(prefix = "io.syndesis.connector.twitter.verifier", name = "enabled", matchIfMissing = true) public Verifier twitterVerifier() { return new TwitterVerifier(); }
/** * Load the properties files used in application contexts here * * @return the initialized instance of the PropertyPlaceholderConfigurer class */ @Bean(name="properties") @Scope(BeanDefinition.SCOPE_SINGLETON) public PropertyPlaceholderConfigurer conversionService() { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); Resource resource1 = new ClassPathResource("application_file_1.properties"); Resource resource2 = new ClassPathResource("application_file_2.properties"); configurer.setLocations(resource1, resource2); return configurer; }
@Bean @Scope("prototype") public Feign.Builder feignBuilder() { return Feign.builder() .requestInterceptor(new TccRestTemplateInterceptor()) .invocationHandlerFactory(invocationHandlerFactory()); }
/** * Declare AADAuthenticationFilter bean. * * @return AADAuthenticationFilter bean */ @Bean @Scope("singleton") @ConditionalOnMissingBean(AADAuthenticationFilter.class) public AADAuthenticationFilter azureADJwtTokenFilter() { LOG.info("AzureADJwtTokenFilter Constructor."); return new AADAuthenticationFilter(aadAuthFilterProperties); }
/** * Configure the CaseType Validator * * @return CaseType Validator */ @Bean(name = "case-type") @Scope(BeanDefinition.SCOPE_PROTOTYPE) public CaseTypeValidator caseTypeValidator() { CaseTypeValidator validator = new CaseTypeValidator(); validator.setRuleEvaluator(ruleHelper()); return validator; }
/** * Configure the Pattern Validator * * @return Pattern Validator */ @Bean(name = "pattern") @Scope(BeanDefinition.SCOPE_PROTOTYPE) public PatternValidator patternValidator() { PatternValidator validator = new PatternValidator(); validator.setRuleEvaluator(ruleHelper()); return validator; }
@Scope("prototype") @Bean(name = "prototypeBean") public ExampleScopeBean prototypeBean() { ExampleScopeBean exampleScopeBean = new ExampleScopeBean(); exampleScopeBean.setMessage("hello"); return exampleScopeBean; }
@Bean @Scope("prototype") public RequestInterceptor opIdInterceptor(@Autowired OperationContext operationContext) { return template -> { String key = operationContext.getContext(); if (key != null) template.header("opId", key.toString()); }; }
@Bean @Scope("prototype") public RequestInterceptor opIdInterceptor() { return (template) -> { String key = this.operationContext.getContext(); if (key != null) { template.header("opId", key); } }; }
@Bean @Scope("singleton") public NexmoClient nexmoClientBean() throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException, IOException { AuthMethod tokenAuthMethod = new TokenAuthMethod(this.apiKey, this.apiSecret); AuthMethod jwtAuthMethod = new JWTAuthMethod(this.applicationId, new File(this.pathPrivateKey).toPath()); return new NexmoClient(tokenAuthMethod, jwtAuthMethod); }
@Bean @Scope("prototype") public JvmControlService getJvmControlService() { reset(mockJvmCommandFactory, mockSshConfig, mockShellCommandFactory, mockHistoryFacadeService, mockJvmStateService, mockRemoteCommandExecutorService, mockSshConfig, mockJvmPersistenceService); return new JvmControlServiceImpl( mockJvmPersistenceService, mockJvmStateService, mockHistoryFacadeService); }
/** * Configure the validator factory * * @return validator factory */ @Bean(name = "ruleValidatorFactory") @Scope(BeanDefinition.SCOPE_SINGLETON) public RuleValidatorFactory ruleValidatorFactory() { RuleValidatorFactory factory = new RuleValidatorFactory(); factory.addValidatorTypes("mandatory", "max-length", "min-length", "case-type", "max-value", "min-value", "candidate-key", "comment", "foreign-key", "generic-foreign-key", "in-list", "not-in-list", "partial-foreign-key", "pattern", "primary-key"); return factory; }
@Bean @Scope("prototype") public BinaryDistributionService getBinaryDistributionService() { reset(mockBinaryDistributionControlService, mockBinaryDistributionLockManager, historyFacadeService, mockSshConfig, mockSshConfiguration, mockRemoteCommandExecutorService); return new BinaryDistributionServiceImpl(); }
@SuppressWarnings("rawtypes") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Bean public IMessagePublisher messagePublisher(final String className) { return createObject(className, IMessagePublisher.class); }
@Bean @Lazy @Scope(BeanDefinition.SCOPE_PROTOTYPE) public CassandraMappingContext cassandraMapping(Cluster cluster, String keyspace) throws ClassNotFoundException { BasicCassandraMappingContext mappingContext = new BasicCassandraMappingContext(); mappingContext.setBeanClassLoader(classLoader); mappingContext.setInitialEntitySet(CassandraEntityClassScanner.scan(getEntityBasePackages())); CustomConversions customConversions = customConversions(); mappingContext.setCustomConversions(customConversions); mappingContext.setSimpleTypeHolder(customConversions.getSimpleTypeHolder()); mappingContext.setUserTypeResolver(new SimpleUserTypeResolver(cluster, keyspace)); return mappingContext; }
/** * Configure the MinValue Validator * * @return MinValue Validator */ @Bean(name = "min-value") @Scope(BeanDefinition.SCOPE_PROTOTYPE) public MinValueValidator minValueValidator() { MinValueValidator validator = new MinValueValidator(); validator.setRuleEvaluator(ruleHelper()); return validator; }
@Bean @Scope(BeanDefinition.SCOPE_PROTOTYPE) public Menu helpMenu() { Menu file = new Menu(localeService.getMessage("ui.menu.help")); file.setMnemonicParsing(false); MenuItem about = new MenuItem(localeService.getMessage("ui.menu.help.about")); about.setMnemonicParsing(false); about.setOnAction(event -> aboutBox()); file.getItems().add(about); return file; }
@Bean @Scope(value = "prototype") public JobDetailFactoryBean getMonitorJob(){ JobDetailFactoryBean bean = new JobDetailFactoryBean(); bean.setJobClass(NodeMonitorJob.class); return bean; }
@Bean @Scope(value = "prototype") public JobDetailFactoryBean getEventJob(){ JobDetailFactoryBean bean = new JobDetailFactoryBean(); bean.setJobClass(EventJob.class); return bean; }
/** * Containerize {@link FxmlLoader} so we can add our resource bundle. */ @Bean @Scope(scopeName = SCOPE_PROTOTYPE) public FxmlLoader fxmlLoader(final ApplicationContext context, final ResourceBundle resourceBundle) { final FxmlLoader loader = new FxmlLoader(); loader.setControllerFactory(context::getBean); loader.setResources(resourceBundle); return loader; }
@Bean @Scope("prototype") public Feign.Builder feignBuilder() { return Feign.builder().requestInterceptor(new RestTemplateInterceptor()); }