本文整理汇总了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;
}
示例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;
}
示例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("/**");
}
};
}
示例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);
}
示例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());
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例12: asyncRestProcessor
import org.springframework.context.annotation.Conditional; //导入依赖的package包/类
/**
* Asynchronous REST processor
* @return
*/
@Bean
@Conditional(RestEnabledCondition.class)
public AsyncEventReceiverBean asyncRestProcessor()
{
return new AsyncEventReceiverBean();
}
示例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);
}
}
示例14: jarSharingAgent
import org.springframework.context.annotation.Conditional; //导入依赖的package包/类
/**
* Jar distribution agent.
* @return
*/
@Bean
@Conditional(RestEnabledCondition.class)
public JarFileSharingAgent jarSharingAgent()
{
return new JarFileSharingAgent();
}
示例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;
}