当前位置: 首页>>代码示例>>Java>>正文


Java Bean类代码示例

本文整理汇总了Java中org.springframework.context.annotation.Bean的典型用法代码示例。如果您正苦于以下问题:Java Bean类的具体用法?Java Bean怎么用?Java Bean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Bean类属于org.springframework.context.annotation包,在下文中一共展示了Bean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mqProducer

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
@ConditionalOnClass(DefaultMQProducer.class)
@ConditionalOnMissingBean(DefaultMQProducer.class)
@ConditionalOnProperty(prefix = "spring.rocketmq", value = {"nameServer", "producer.group"})
public DefaultMQProducer mqProducer(RocketMQProperties rocketMQProperties) {

    RocketMQProperties.Producer producerConfig = rocketMQProperties.getProducer();
    String groupName = producerConfig.getGroup();
    Assert.hasText(groupName, "[spring.rocketmq.producer.group] must not be null");

    DefaultMQProducer producer = new DefaultMQProducer(producerConfig.getGroup());
    producer.setNamesrvAddr(rocketMQProperties.getNameServer());
    producer.setSendMsgTimeout(producerConfig.getSendMsgTimeout());
    producer.setRetryTimesWhenSendFailed(producerConfig.getRetryTimesWhenSendFailed());
    producer.setRetryTimesWhenSendAsyncFailed(producerConfig.getRetryTimesWhenSendAsyncFailed());
    producer.setMaxMessageSize(producerConfig.getMaxMessageSize());
    producer.setCompressMsgBodyOverHowmuch(producerConfig.getCompressMsgBodyOverHowmuch());
    producer.setRetryAnotherBrokerWhenNotStoreOK(producerConfig.isRetryAnotherBrokerWhenNotStoreOk());

    return producer;
}
 
开发者ID:QianmiOpen,项目名称:spring-boot-starter-rocketmq,代码行数:22,代码来源:RocketMQAutoConfiguration.java

示例2: taskMessageListenerContainer

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
@Autowired
public DefaultMessageListenerContainer taskMessageListenerContainer(JmsExternalTaskListener externalTaskListener
        , ConnectionFactory receiverConnectionFactory
        , ActiveMQQueue taskQueue) {
    DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer();
    listenerContainer.setMessageListener(externalTaskListener);
    listenerContainer.setDestination(taskQueue);
    listenerContainer.setConnectionFactory(receiverConnectionFactory);

    listenerContainer.setAcceptMessagesWhileStopping(false);
    listenerContainer.setSessionTransacted(true);
    listenerContainer.setConcurrentConsumers(concurrentConsumers);
    listenerContainer.setMaxMessagesPerTask(maxMessagesPerTask);
    listenerContainer.setReceiveTimeout(receiveTimeout);
    return listenerContainer;
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:18,代码来源:JmsExternalTaskReceiverConfig.java

示例3: bbTaskScheduler

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
public TaskScheduler bbTaskScheduler() {
	ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
	taskScheduler.setThreadNamePrefix("API-Schd-ThrP-");
	taskScheduler.setAwaitTerminationSeconds(1);
	taskScheduler.setRejectedExecutionHandler(new ThreadPoolTaskRejectedHandler());
	
	return taskScheduler;
}
 
开发者ID:BuaBook,项目名称:buabook-api-interface,代码行数:10,代码来源:BuaBookApiInterfaceConfig.java

示例4: keyGenerator

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
/**
 * this was used to generate unique key for each method, the key will be like:
 * className + methodName + args.
 */
@Bean
public KeyGenerator keyGenerator() {
	return new KeyGenerator() {
		@Override
		public Object generate(Object target, Method method, Object... params) {
			StringBuilder sb = new StringBuilder();
			sb.append(target.getClass().getName());
			sb.append(":");
			sb.append(method.getName());
			sb.append(":");
			for (Object obj : params) {
				sb.append(String.valueOf(obj));
				sb.append(":");
			}
			return sb.toString();
		}
	};
}
 
开发者ID:profullstack,项目名称:spring-seed,代码行数:23,代码来源:SpringSeedRedis.java

示例5: jaasAuthenticationHandlers

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@ConditionalOnMissingBean(name = "jaasAuthenticationHandlers")
@RefreshScope
@Bean
public List<AuthenticationHandler> jaasAuthenticationHandlers() {
    return casProperties.getAuthn().getJaas()
        .stream()
        .filter(jaas -> StringUtils.isNotBlank(jaas.getRealm()))
        .map(jaas -> {
            final JaasAuthenticationHandler h =
                new JaasAuthenticationHandler(jaas.getName(),
                    servicesManager, jaasPrincipalFactory(), null);

            h.setKerberosKdcSystemProperty(jaas.getKerberosKdcSystemProperty());
            h.setKerberosRealmSystemProperty(jaas.getKerberosRealmSystemProperty());
            h.setRealm(jaas.getRealm());
            h.setPasswordEncoder(Beans.newPasswordEncoder(jaas.getPasswordEncoder()));

            if (jaasPasswordPolicyConfiguration != null) {
                h.setPasswordPolicyConfiguration(jaasPasswordPolicyConfiguration);
            }
            h.setPrincipalNameTransformer(Beans.newPrincipalNameTransformer(
                jaas.getPrincipalTransformation()));
            h.setCredentialSelectionPredicate(Beans.newCredentialSelectionPredicate(
                jaas.getCredentialCriteria()));
            return h;
        })
        .collect(Collectors.toList());
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:29,代码来源:CasCoreAuthenticationHandlersConfiguration.java

示例6: persoonsvraagWebserviceVerzoekVerwerker

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
/**
 * {@link BevragingVerzoekVerwerker} specifiek voor GBA Ad hoc webservice(Persoons)vraag.
 * @return de GBA Ad hoc webservice (Persoons)vraag verwerker
 */
@Bean
@Named("gbaPersoonsvraagWebserviceVerwerker")
public BevragingVerzoekVerwerker<PersoonsvraagWebserviceVerzoek> persoonsvraagWebserviceVerzoekVerwerker() {
    return new GeneriekeBevragingVerzoekVerwerker<PersoonsvraagWebserviceVerzoek, BevragingResultaat>() {
    };
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:11,代码来源:BevragingGbaVerzoekVerwerkerProvider.java

示例7: createDataSource

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
public DataSource createDataSource() {
	HikariConfig config = new HikariConfig();
	config.setJdbcUrl(this.url);
	config.setUsername(this.username);
	config.setPassword(this.password);
	config.addDataSourceProperty("poolName", this.poolName);
	config.addDataSourceProperty("connectionTimeout", this.connectionTimeout);
	config.addDataSourceProperty("autoCommit", "false");
	return new HikariDataSource(config);
}
 
开发者ID:michaelliao,项目名称:cryptoexchange,代码行数:12,代码来源:DbTestConfiguration.java

示例8: resourceDetails

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails resourceDetails() {
    AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
    details.setClientId(properties.getClientId());
    details.setClientSecret(properties.getClientSecret());

    // URLs retrieved from https://accounts.google.com/.well-known/openid-configuration
    details.setUserAuthorizationUri("https://accounts.google.com/o/oauth2/v2/auth");
    details.setAccessTokenUri("https://www.googleapis.com/oauth2/v4/token");
    details.setPreEstablishedRedirectUri("http://localhost:8080/google/callback");
    details.setScope(Arrays.asList("openid", "email", "profile"));
    details.setUseCurrentUri(false);
    return details;
}
 
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:15,代码来源:GoogleConfiguration.java

示例9: corsFilter

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
public FilterRegistrationBean corsFilter() {
  FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
  filterRegistrationBean.setFilter(new CorsFilter());
  // Highest priority to authorise OPTION requests.
  filterRegistrationBean.setOrder(0);
  return filterRegistrationBean;
}
 
开发者ID:melphi,项目名称:java-api-best-practices,代码行数:9,代码来源:SecurityConfiguration.java

示例10: contextSource

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
/**
 * LDAP Server Context
 * @return
 */
@Bean
public DefaultSpringSecurityContextSource contextSource() {
    return new DefaultSpringSecurityContextSource(
            Arrays.asList("ldap://corp.jbcpcalendar.com/"), "dc=corp,dc=jbcpcalendar,dc=com"){{

        setUserDn("CN=Administrator,CN=Users,DC=corp,DC=jbcpcalendar,DC=com");
        setPassword("admin123!");
    }};
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:14,代码来源:SecurityConfig.java

示例11: rssInputRoute

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
/**
 * Camel routes for reading RSS feeds. Routes could be also defined in XML, Groovy or scripting knowledge bases.
 *
 * @return route builder.
 */
@Bean
public RouteBuilder rssInputRoute() {
    return new RouteBuilder() {

        // @formatter:off
        @SuppressWarnings("unchecked")
        @Override
        public void configure() throws Exception {
            EngineOperations operations = camelRssEngine().getOperations();
            Map<String, String> rssSources = operations.getVariable(Map.class, CamelRssConstants.VAR_RSS_SOURCES);

            // Read RSS feeds from all configured sources.
            rssSources.forEach((source, url) ->
                    from("rss:" + url + operations.getVariable(CamelRssConstants.VAR_RSS_ENDPOINT_PARAMETERS, "")).routeId(source)
                        .setHeader(HEADER_SOURCE).constant(source)
                        .to("direct:rss"));

            // Gathers RSS from different sources and sends to Sponge engine as a normalized event.
            from("direct:rss").routeId("rss")
                    .marshal().rss()
                    // Deduplicate by title.
                    .idempotentConsumer(xpath("/rss/channel/item/title/text()"),
                            MemoryIdempotentRepository.memoryIdempotentRepository())
                    // Conversion from RSS XML to Sponge event with attributes.
                    .process((exchange) -> exchange.getIn().setBody(operations.event("news")
                            .set("source", exchange.getIn().getHeader(HEADER_SOURCE))
                            .set("channel", CamelUtils.xpath(exchange, "/rss/channel/title/text()"))
                            .set("title", CamelUtils.xpath(exchange, "/rss/channel/item/title/text()"))
                            .set("link", CamelUtils.xpath(exchange, "/rss/channel/item/link/text()"))
                            .set("description", CamelUtils.xpath(exchange, "/rss/channel/item/description/text()"))
                            .make()))
                    //.filter((exchange) -> false)
                    .to("sponge:camelRssEngine");
        }
        // @formatter:on
    };
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:43,代码来源:SpringConfiguration.java

示例12: getJobExplorer

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(JobExplorer.class)
public JobExplorer getJobExplorer() throws Exception {
	BatchConfigurer batchConfigurer = getBatchConfigurer();
	if (batchConfigurer != null) {
		return batchConfigurer.getJobExplorer();
	}
	JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
	jobExplorerFactoryBean.setDataSource(dataSource);
	return jobExplorerFactoryBean.getObject();
}
 
开发者ID:namics,项目名称:spring-batch-support,代码行数:12,代码来源:SpringBatchDefaultServiceConfiguration.java

示例13: clientValidator

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
public ClientValidator clientValidator() throws Exception {

    final ClientValidator mock = mock(ClientValidator.class);
    when(mock.isValid(eq(GrantTypes.OPENID), anyString())).thenReturn(true);
    return mock;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:8,代码来源:TestConfig.java

示例14: subscriptionAdminClient

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public SubscriptionAdminClient subscriptionAdminClient() {
	try {
		return SubscriptionAdminClient.create(
				SubscriptionAdminSettings.newBuilder()
						.setCredentialsProvider(this.finalCredentialsProvider)
						.build());
	}
	catch (IOException ioe) {
		throw new PubSubException("An error occurred while creating SubscriptionAdminClient.",
				ioe);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:15,代码来源:GcpPubSubAutoConfiguration.java

示例15: createRestApi

import org.springframework.context.annotation.Bean; //导入依赖的package包/类
@Bean
public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.wind.web"))
            .paths(PathSelectors.any())
            .build();
}
 
开发者ID:ustcwudi,项目名称:springboot-seed,代码行数:10,代码来源:Swagger2Config.java


注:本文中的org.springframework.context.annotation.Bean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。