org.springframework.context.annotation.Scope Java Examples
The following examples show how to use
org.springframework.context.annotation.Scope.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GovernanceApplication.java From WeEvent with Apache License 2.0 | 6 votes |
@Scope("prototype") @Bean("httpClient") public CloseableHttpClient getHttpClient(GovernanceConfig config) { /** * config connect parameter */ PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(config.getConnectionRequestTimeout()) .setConnectTimeout(config.getHttpConnectTimeOut()).setSocketTimeout(config.getSocketTimeout()).build(); cm.setMaxTotal(config.getMaxTotal()); cm.setDefaultMaxPerRoute(config.getMaxPerRoute()); return HttpClients.custom().setConnectionManager(cm) .setDefaultRequestConfig(requestConfig).setRetryHandler(retryHandler).build(); }
Example #2
Source File: FileLockClusterServiceAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 6 votes |
@Bean(name = "file-lock-cluster-service") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public CamelClusterService fileClusterService() throws Exception { FileLockClusterService service = new FileLockClusterService(); Optional.ofNullable(configuration.getId()) .ifPresent(service::setId); Optional.ofNullable(configuration.getRoot()) .ifPresent(service::setRoot); Optional.ofNullable(configuration.getOrder()) .ifPresent(service::setOrder); Optional.ofNullable(configuration.getAttributes()) .ifPresent(service::setAttributes); Optional.ofNullable(configuration.getAcquireLockDelay()) .map(TimePatternConverter::toMilliSeconds) .ifPresent(v -> service.setAcquireLockDelay(v, TimeUnit.MILLISECONDS)); Optional.ofNullable(configuration.getAcquireLockInterval()) .map(TimePatternConverter::toMilliSeconds) .ifPresent(v -> service.setAcquireLockInterval(v, TimeUnit.MILLISECONDS)); return service; }
Example #3
Source File: DubboConfiguration.java From chronus with Apache License 2.0 | 5 votes |
@Bean(name = "DUBBO") @Scope("prototype") @ConditionalOnMissingBean public DubboJobDispatcherImpl jobByDubboType(ChronusSdkProcessor chronusSdkFacade) { DubboJobDispatcherImpl dubboJobDispatcher = new DubboJobDispatcherImpl(chronusSdkFacade); return dubboJobDispatcher; }
Example #4
Source File: EnableMBeanExportConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Bean @Lazy @Scope(proxyMode = ScopedProxyMode.TARGET_CLASS) public AnnotationTestBean testBean() { AnnotationTestBean bean = new AnnotationTestBean(); bean.setName("TEST"); bean.setAge(100); return bean; }
Example #5
Source File: BeanConfig.java From WeBASE-Node-Manager with Apache License 2.0 | 5 votes |
/** * factory for deploy. */ @Bean() @Scope("prototype") public SimpleClientHttpRequestFactory getHttpFactoryForDeploy() { SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); return factory; }
Example #6
Source File: MvelLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "mvel-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(MvelLanguage.class) public MvelLanguage configureMvelLanguage() throws Exception { MvelLanguage language = new MvelLanguage(); if (CamelContextAware.class.isAssignableFrom(MvelLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<MvelLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.mvel.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.mvel.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #7
Source File: GroovyLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "groovy-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(GroovyLanguage.class) public GroovyLanguage configureGroovyLanguage() throws Exception { GroovyLanguage language = new GroovyLanguage(); if (CamelContextAware.class.isAssignableFrom(GroovyLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<GroovyLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.groovy.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.groovy.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #8
Source File: JGroupsLockClusterServiceAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "jgroups-lock-cluster-service") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public CamelClusterService zookeeperClusterService() throws Exception { JGroupsLockClusterService service = new JGroupsLockClusterService(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; }
Example #9
Source File: KubernetesClusterServiceAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "kubernetes-cluster-service") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public CamelClusterService kubernetesClusterService() throws Exception { KubernetesClusterService service = new KubernetesClusterService(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; }
Example #10
Source File: ZooKeeperServiceRegistryAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "zookeeper-service-registry") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public ZooKeeperServiceRegistry zookeeperServiceRegistry(ZooKeeperServiceRegistryConfiguration configuration) throws Exception { ZooKeeperServiceRegistry service = new ZooKeeperServiceRegistry(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; }
Example #11
Source File: ZooKeeperClusterServiceAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "zookeeper-cluster-service") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public CamelClusterService zookeeperClusterService() throws Exception { ZooKeeperClusterService service = new ZooKeeperClusterService(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; }
Example #12
Source File: XMLTokenizeLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "xtokenize-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(XMLTokenizeLanguage.class) public XMLTokenizeLanguage configureXMLTokenizeLanguage() throws Exception { XMLTokenizeLanguage language = new XMLTokenizeLanguage(); if (CamelContextAware.class.isAssignableFrom(XMLTokenizeLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<XMLTokenizeLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.xtokenize.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.xtokenize.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #13
Source File: JsonPathLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "jsonpath-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(JsonPathLanguage.class) public JsonPathLanguage configureJsonPathLanguage() throws Exception { JsonPathLanguage language = new JsonPathLanguage(); if (CamelContextAware.class.isAssignableFrom(JsonPathLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<JsonPathLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.jsonpath.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.jsonpath.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #14
Source File: ConsulClusterServiceAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "consul-cluster-service") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public CamelClusterService consulClusterService() throws Exception { ConsulClusterService service = new ConsulClusterService(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; }
Example #15
Source File: GitHubConfiguration.java From codeway_service with GNU General Public License v3.0 | 5 votes |
@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; }
Example #16
Source File: FeignMultipartSupportConfiguration.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
/** * Feign Spring 表单编码器 * @return 表单编码器 */ @Bean @Primary @Scope("prototype") public Encoder multipartEncoder(){ return new SpringFormEncoder(); }
Example #17
Source File: EnableMBeanExportConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Bean @Lazy @Scope(proxyMode = ScopedProxyMode.TARGET_CLASS) public AnnotationTestBean testBean() { AnnotationTestBean bean = new AnnotationTestBean(); bean.setName("TEST"); bean.setAge(100); return bean; }
Example #18
Source File: TokenizeLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "tokenize-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(TokenizeLanguage.class) public TokenizeLanguage configureTokenizeLanguage() throws Exception { TokenizeLanguage language = new TokenizeLanguage(); if (CamelContextAware.class.isAssignableFrom(TokenizeLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<TokenizeLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.tokenize.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.tokenize.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #19
Source File: RefLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "ref-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(RefLanguage.class) public RefLanguage configureRefLanguage() throws Exception { RefLanguage language = new RefLanguage(); if (CamelContextAware.class.isAssignableFrom(RefLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<RefLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.ref.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.ref.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #20
Source File: ExchangePropertyLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "exchangeProperty-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(ExchangePropertyLanguage.class) public ExchangePropertyLanguage configureExchangePropertyLanguage() throws Exception { ExchangePropertyLanguage language = new ExchangePropertyLanguage(); if (CamelContextAware.class.isAssignableFrom(ExchangePropertyLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<ExchangePropertyLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.exchangeproperty.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.exchangeproperty.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #21
Source File: ConstantLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "constant-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(ConstantLanguage.class) public ConstantLanguage configureConstantLanguage() throws Exception { ConstantLanguage language = new ConstantLanguage(); if (CamelContextAware.class.isAssignableFrom(ConstantLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<ConstantLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.constant.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.constant.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #22
Source File: JGroupsRaftClusterServiceAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "jgroups-raft-cluster-service") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public CamelClusterService jgroupsRaftClusterService() throws Exception { JGroupsRaftClusterService service = new JGroupsRaftClusterService(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; }
Example #23
Source File: Hl7TerserLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "hl7terser-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(Hl7TerserLanguage.class) public Hl7TerserLanguage configureHl7TerserLanguage() throws Exception { Hl7TerserLanguage language = new Hl7TerserLanguage(); if (CamelContextAware.class.isAssignableFrom(Hl7TerserLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<Hl7TerserLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.hl7terser.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.hl7terser.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #24
Source File: XQueryLanguageAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "xquery-language") @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnMissingBean(XQueryLanguage.class) public XQueryLanguage configureXQueryLanguage() throws Exception { XQueryLanguage language = new XQueryLanguage(); if (CamelContextAware.class.isAssignableFrom(XQueryLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class .cast(language); if (contextAware != null) { contextAware.setCamelContext(camelContext); } } Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, language, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (LanguageCustomizer<XQueryLanguage> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.xquery.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.language.customizer", "camel.language.xquery.customizer"); if (useCustomizer) { LOGGER.debug("Configure language {}, with customizer {}", language, customizer); customizer.customize(language); } } } return language; }
Example #25
Source File: ConsulServiceRegistryAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "consul-service-registry") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public ConsulServiceRegistry consulServiceRegistry(ConsulServiceRegistryConfiguration configuration) throws Exception { ConsulServiceRegistry service = new ConsulServiceRegistry(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; }
Example #26
Source File: AutowiredConfigurationTests.java From spring-analysis-note with MIT License | 4 votes |
@Bean @Scope("prototype") public TestBean testBean() { return new TestBean(name); }
Example #27
Source File: AutowiredConfigurationTests.java From java-technology-stack with MIT License | 4 votes |
@Bean @Scope("prototype") public TestBean testBean2() { return new TestBean(name2); }
Example #28
Source File: AutowiredConfigurationTests.java From java-technology-stack with MIT License | 4 votes |
@Bean @Scope("prototype") public TestBean testBean2(@Value("#{systemProperties[myProp]}") Provider<String> name2) { return new TestBean(name2.get()); }
Example #29
Source File: ConfigurationClassProcessingTests.java From java-technology-stack with MIT License | 4 votes |
@Bean @Scope("prototype") public TestBean adaptive2(DependencyDescriptor dd) { return new TestBean(dd.getMember().getName()); }
Example #30
Source File: AutowiredConfigurationTests.java From java-technology-stack with MIT License | 4 votes |
@Bean @Scope("prototype") public TestBean testBean(@Value("#{systemProperties[myProp]}") Provider<String> name) { return new TestBean(name.get()); }