當前位置: 首頁>>代碼示例>>Java>>正文


Java Conditional類代碼示例

本文整理匯總了Java中org.springframework.context.annotation.Conditional的典型用法代碼示例。如果您正苦於以下問題:Java Conditional類的具體用法?Java Conditional怎麽用?Java Conditional使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Conditional類屬於org.springframework.context.annotation包,在下文中一共展示了Conditional類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: appengineCloudSqlJdbcInfoProvider

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
@Bean
@ConditionalOnMissingBean(CloudSqlJdbcInfoProvider.class)
@Conditional(AppEngineCondition.class)
public CloudSqlJdbcInfoProvider appengineCloudSqlJdbcInfoProvider() {
	CloudSqlJdbcInfoProvider appEngineProvider = new AppEngineCloudSqlJdbcInfoProvider(this.gcpCloudSqlProperties);

	if (LOGGER.isInfoEnabled()) {
		LOGGER.info("App Engine JdbcUrl provider. Connecting to "
				+ appEngineProvider.getJdbcUrl() + " with driver "
				+ appEngineProvider.getJdbcDriverClass());
	}

	setCredentialsProperty();

	return appEngineProvider;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-gcp,代碼行數:17,代碼來源:GcpCloudSqlAutoConfiguration.java

示例2: matches

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
public static boolean matches(ConditionContext context) {
	Class<AuthorizationServerEndpointsConfigurationBeanCondition> type = AuthorizationServerEndpointsConfigurationBeanCondition.class;
	Conditional conditional = AnnotationUtils.findAnnotation(type,
			Conditional.class);
	StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(type);
	for (Class<? extends Condition> conditionType : conditional.value()) {
		Condition condition = BeanUtils.instantiateClass(conditionType);
		if (condition.matches(context, metadata)) {
			return true;
		}
	}
	return false;
}
 
開發者ID:spring-projects,項目名稱:spring-security-oauth2-boot,代碼行數:14,代碼來源:OAuth2ResourceServerConfiguration.java

示例3: clientFactory

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/**
 * Returns {@link ClientFactory#DEFAULT} which is used as the default {@link ClientFactory} of a
 * {@link CentralDogma} client.
 */
@Bean
@ForCentralDogma
@Conditional(MissingCentralDogmaClientFactory.class)
public ClientFactory clientFactory() {
    return ClientFactory.DEFAULT;
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:11,代碼來源:CentralDogmaConfiguration.java

示例4: webMvcConfigurer

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
@Bean
@Conditional(Development.class)
public WebMvcConfigurer webMvcConfigurer() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addCorsMappings(final CorsRegistry registry) {
            registry.addMapping("/**");
        }
    };
}
 
開發者ID:backpaper0,項目名稱:spring-boot-vue-simple-sample,代碼行數:11,代碼來源:DemoApplication.java

示例5: dataSource

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
@Bean
@Conditional(PostgreSqlUrlCondition.class)
public DataSource dataSource(Environment env) throws URISyntaxException {
  final String DATABASE_URL = env.getProperty("DATABASE_URL");

  return createHerokuDataSource(DATABASE_URL);
}
 
開發者ID:VisualDataWeb,項目名稱:OntoBench,代碼行數:8,代碼來源:PersistenceConfig.java

示例6: getConditionClasses

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private List<String[]> getConditionClasses(AnnotatedTypeMetadata metadata) {
	MultiValueMap<String, Object> attributes = metadata
			.getAllAnnotationAttributes(Conditional.class.getName(), true);
	Object values = (attributes != null ? attributes.get("value") : null);
	return (List<String[]>) (values != null ? values : Collections.emptyList());
}
 
開發者ID:lodsve,項目名稱:lodsve-framework,代碼行數:8,代碼來源:AbstractNestedCondition.java

示例7: userService

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/**
 * The @Bean annotation tells Spring that this method will return an object that should <br>
 * be registered as a bean in the Spring application context.
 *
 * @return userService
 */
@Bean
@Conditional(UserCondition.class)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public UserService userService() {
    logger.debug("userService");
    return new UserServiceImpl();
}
 
開發者ID:tvajjala,項目名稱:interview-preparation,代碼行數:14,代碼來源:Application.java

示例8: clientBuilder

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/**
 * When the domain variable is set, we lookup the elasticsearch domain url dynamically, using the
 * AWS api. Otherwise, we assume the URL specified in ES_HOSTS is correct.
 */
@Bean
@Conditional(AwsDomainSetCondition.class)
InternalElasticsearchClient.Builder clientBuilder(
    ZipkinElasticsearchStorageProperties es,
    ZipkinElasticsearchAwsStorageProperties aws,
    @Qualifier("zipkinElasticsearchHttp") OkHttpClient client) {
  String domain = aws.getDomain();
  String region = region(es, aws);

  ElasticsearchDomainEndpoint hosts = new ElasticsearchDomainEndpoint(
      client, HttpUrl.parse("https://es." + region + ".amazonaws.com"), domain);

  return HttpClientBuilder.create(client).hosts(hosts);
}
 
開發者ID:liaominghua,項目名稱:zipkin,代碼行數:19,代碼來源:ZipkinElasticsearchAwsStorageAutoConfiguration.java

示例9: securityTokenService

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/** Setup {@link AWSSecurityTokenService} client an IAM role to assume is given. */
@Bean
@ConditionalOnMissingBean
@Conditional(STSSetCondition.class)
AWSSecurityTokenService securityTokenService(ZipkinSQSCollectorProperties properties) {
  return AWSSecurityTokenServiceClientBuilder.standard()
      .withCredentials(getDefaultCredentialsProvider(properties))
      .withRegion(properties.awsStsRegion)
      .build();
}
 
開發者ID:openzipkin,項目名稱:zipkin-aws,代碼行數:11,代碼來源:ZipkinSQSCredentialsAutoConfiguration.java

示例10: securityTokenService

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/** Setup {@link AWSSecurityTokenService} client an IAM role to assume is given. */
@Bean
@ConditionalOnMissingBean
@Conditional(STSSetCondition.class)
AWSSecurityTokenService securityTokenService(ZipkinKinesisCollectorProperties properties) {
  return AWSSecurityTokenServiceClientBuilder.standard()
      .withCredentials(getDefaultCredentialsProvider(properties))
      .withRegion(properties.awsStsRegion)
      .build();
}
 
開發者ID:openzipkin,項目名稱:zipkin-aws,代碼行數:11,代碼來源:ZipkinKinesisCredentialsAutoConfiguration.java

示例11: restServer

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/**
 * REST server for listening to POST/GET requests
 * @return
 */
@Bean
@Conditional(RestEnabledCondition.class)
public Serveable restServer()
{
  return new WebbitRestServerBean(port, nThreads, basePkg);
  
}
 
開發者ID:javanotes,項目名稱:reactive-data,代碼行數:12,代碼來源:Configurator.java

示例12: asyncRestProcessor

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/**
 * Asynchronous REST processor
 * @return
 */
@Bean
@Conditional(RestEnabledCondition.class)
public AsyncEventReceiverBean asyncRestProcessor()
{
  return new AsyncEventReceiverBean();
}
 
開發者ID:javanotes,項目名稱:reactive-data,代碼行數:11,代碼來源:Configurator.java

示例13: dllLoader

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/**
 * Jar module loader.
 * @return
 */
@Bean
@Conditional(RestEnabledCondition.class)
public JarModuleLoader dllLoader()
{
  try 
  {
    if(StringUtils.isEmpty(dllRoot))
      throw new BeanCreationException("'restserver.jaxrs.extDir' path not found");
    File f = ResourceLoaderHelper.loadFromFileOrClassPath(dllRoot, false);
    return new JarModuleLoader(f);
  } catch (IOException e) {
    throw new BeanCreationException("'restserver.jaxrs.extDir' path not found", e);
  }
}
 
開發者ID:javanotes,項目名稱:reactive-data,代碼行數:19,代碼來源:Configurator.java

示例14: jarSharingAgent

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
/**
 * Jar distribution agent.
 * @return
 */
@Bean
@Conditional(RestEnabledCondition.class)
public JarFileSharingAgent jarSharingAgent()
{
  return new JarFileSharingAgent();
}
 
開發者ID:javanotes,項目名稱:reactive-data,代碼行數:11,代碼來源:Configurator.java

示例15: periodicTrigger

import org.springframework.context.annotation.Conditional; //導入依賴的package包/類
@Bean(name = TriggerConstants.TRIGGER_BEAN_NAME)
@Conditional(PeriodicTriggerCondition.class)
public Trigger periodicTrigger() {
	PeriodicTrigger trigger = new PeriodicTrigger(triggerProperties.getFixedDelay(),
			triggerProperties.getTimeUnit());
	trigger.setInitialDelay(triggerProperties.getInitialDelay());
	return trigger;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-stream-app-starters,代碼行數:9,代碼來源:TriggerConfiguration.java


注:本文中的org.springframework.context.annotation.Conditional類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。