當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。