本文整理了Java中org.springframework.context.annotation.Conditional
类的一些代码示例,展示了Conditional
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Conditional
类的具体详情如下:
包路径:org.springframework.context.annotation.Conditional
类名称:Conditional
暂无
代码示例来源:origin: codecentric/spring-boot-admin
@Configuration
@ConditionalOnWebApplication
@Conditional(SpringBootAdminClientEnabledCondition.class)
@AutoConfigureAfter({WebEndpointAutoConfiguration.class, RestTemplateAutoConfiguration.class})
@EnableConfigurationProperties({ClientProperties.class, InstanceProperties.class, ServerProperties.class, ManagementServerProperties.class})
public class SpringBootAdminClientAutoConfiguration {
代码示例来源:origin: org.springframework.cloud/spring-cloud-context
@Configuration
@Conditional(KeyCondition.class)
@ConditionalOnMissingClass("org.springframework.security.rsa.crypto.RsaSecretEncryptor")
protected static class VanillaEncryptionConfiguration {
@Autowired
private KeyProperties key;
@Bean
@ConditionalOnMissingBean(TextEncryptor.class)
public TextEncryptor textEncryptor() {
return new EncryptorFactory(this.key.getSalt()).create(this.key.getKey());
}
}
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
@Configuration
@Conditional(MigrateOnConditionClass.class)
public class MigrateRibbonCofiguration {
@Bean
public MigrateRibbonBeanPostProcessor migrateBeanPostProcessor(IClientConfig clientConfig) {
return new MigrateRibbonBeanPostProcessor(clientConfig);
}
}
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
/**
* @author xiaolongzuo
*/
@Configuration
@Conditional(MigrateOnConditionMissingClass.class)
@ConditionalOnMissingBean(DiscoveryClient.class)
@EnableConfigurationProperties
@AutoConfigureBefore(SimpleDiscoveryClientAutoConfiguration.class)
public class AnsDiscoveryClientAutoConfiguration {
@Bean
public DiscoveryClient ansDiscoveryClient() {
return new AnsDiscoveryClient();
}
}
代码示例来源:origin: org.springframework.boot/spring-boot-devtools
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
@Conditional(DevToolsDataSourceCondition.class)
@Configuration
public class DevToolsDataSourceAutoConfiguration {
代码示例来源:origin: ctripcorp/apollo
@Component
@Conditional(TitanCondition.class)
public class TitanEntityManager {
private final TitanSettings settings;
public TitanEntityManager(final TitanSettings settings) {
this.settings = settings;
}
@SuppressWarnings({"rawtypes", "unchecked"})
@Bean
public DataSource datasource() throws Exception {
Class clazz = Class.forName("com.ctrip.datasource.configure.DalDataSourceFactory");
Object obj = clazz.newInstance();
Method method = clazz.getMethod("createDataSource", new Class[] {String.class, String.class});
DataSource ds = ((DataSource) method.invoke(obj,
new Object[] {settings.getTitanDbname(), settings.getTitanUrl()}));
Tracer.logEvent("Apollo.Datasource.Titan", settings.getTitanDbname());
return ds;
}
}
代码示例来源:origin: org.springframework.security.oauth.boot/spring-security-oauth2-autoconfigure
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;
}
代码示例来源:origin: forezp/BootNettyRpc
@Configuration
@Conditional(MailMonitorCondition.class)
protected static class MailMonitorConfig {
@Autowired
NettyRpcProperties nettyRpcProperties;
@Bean
public SmtpEventHandler smtpEventHandler() {
SmtpEventHandler smtpEventHandler = new SmtpEventHandler( nettyRpcProperties );
return smtpEventHandler;
}
}
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
/**
* @author xiaolongzuo
*/
@Configuration
@Conditional(MigrateOnConditionMissingClass.class)
public class AnsRibbonClientConfiguration {
@Bean
@ConditionalOnMissingBean
public ServerList<?> ansRibbonServerList(IClientConfig config) {
AnsServerList serverList = new AnsServerList(config.getClientName());
return serverList;
}
}
代码示例来源:origin: codecentric/spring-boot-admin
@Configuration
@ConditionalOnWebApplication
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
@Conditional(SpringBootAdminClientEnabledCondition.class)
@EnableConfigurationProperties(CloudFoundryApplicationProperties.class)
@AutoConfigureBefore({SpringBootAdminClientAutoConfiguration.class})
public class SpringBootAdminClientCloudFoundryAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public CloudFoundryMetadataContributor cloudFoundryMetadataContributor(CloudFoundryApplicationProperties cloudFoundryApplicationProperties) {
return new CloudFoundryMetadataContributor(cloudFoundryApplicationProperties);
}
@Bean
@ConditionalOnMissingBean
public CloudFoundryApplicationFactory applicationFactory(InstanceProperties instance,
ManagementServerProperties management,
ServerProperties server,
PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint,
MetadataContributor metadataContributor,
CloudFoundryApplicationProperties cfApplicationProperties) {
return new CloudFoundryApplicationFactory(instance, management, server, pathMappedEndpoints, webEndpoint,
metadataContributor, cfApplicationProperties);
}
}
代码示例来源:origin: org.apache.camel/camel-spring-cloud-netflix
@Configuration
@ConditionalOnBean(CamelAutoConfiguration.class)
@AutoConfigureAfter({ CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, RibbonAutoConfiguration.class })
@Conditional(CamelCloudNetflixAutoConfiguration.Condition.class)
public class CamelCloudNetflixAutoConfiguration {
// *******************************
// Condition
// *******************************
public static class Condition extends GroupCondition {
public Condition() {
super(
"camel.cloud",
"camel.cloud.netflix"
);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Conditional(RegisterBeanPhaseCondition.class)
public static class RegisterBeanPhaseConditionConfiguration extends BaseConfiguration {
}
代码示例来源:origin: spring-projects/spring-security-oauth2-boot
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;
}
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
@Configuration
@EnableConfigurationProperties
@Conditional(MigrateOnConditionMissingClass.class)
@ConditionalOnClass(name = "org.springframework.boot.web.context.WebServerInitializedEvent")
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
@ConditionalOnAnsEnabled
@AutoConfigureAfter(AutoServiceRegistrationAutoConfiguration.class)
public class AnsAutoConfiguration {
代码示例来源:origin: org.springframework.cloud/spring-cloud-function-stream
@Configuration
@Conditional(SinkOnlyCondition.class)
protected static class SinkConfiguration {
@Autowired
private StreamConfigurationProperties properties;
public SinkConfiguration() {
}
@Bean
public StreamListeningConsumerInvoker consumerInvoker(FunctionCatalog registry,
FunctionInspector functionInspector,
@Lazy CompositeMessageConverterFactory compositeMessageConverterFactory) {
return new StreamListeningConsumerInvoker(registry, functionInspector,
compositeMessageConverterFactory, properties.getSink().getName(),
properties.isShared());
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Conditional(NoBeanOneCondition.class)
static class BeanTwoConfiguration {
@Bean
public ExampleBean bean2() {
return new ExampleBean();
}
}
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
@Configuration
@EnableConfigurationProperties
@Conditional(MigrateOnConditionClass.class)
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
@ConditionalOnAnsEnabled
public class MigrationAutoconfiguration {
@Bean
public MigrateServiceRegistry migrationManger(AnsProperties ansProperties,
ApplicationContext applicationContext) {
return new MigrateServiceRegistry(ansProperties, applicationContext);
}
@Bean
public MigrateRefreshEventListener migrateRefreshEventListener(
Environment environment,
@Qualifier(value = "springClientFactory") NamedContextFactory namedContextFactory) {
return new MigrateRefreshEventListener(environment, namedContextFactory);
}
}
代码示例来源:origin: org.apache.camel/camel-spring-cloud-netflix
@Configuration
@AutoConfigureAfter(RibbonAutoConfiguration.class)
@AutoConfigureBefore(CamelSpringCloudServiceRegistryAutoConfiguration.class)
@Conditional(CamelCloudNetflixServiceLoadBalancerAutoConfiguration.Condition.class)
public class CamelCloudNetflixServiceLoadBalancerAutoConfiguration {
@ConditionalOnBean(LoadBalancerClient.class)
@ConditionalOnMissingBean
@Bean("netflix-client-load-balancer-adapter")
public CamelSpringCloudServiceLoadBalancer.LoadBalancerClientAdapter netflixClientLoadBalancerAdapter(List<ConversionService> conversionServices) {
return client -> new CamelCloudNetflixServiceLoadBalancer(client, conversionServices);
}
// *******************************
// Condition
// *******************************
public static class Condition extends GroupCondition {
public Condition() {
super(
"camel.cloud",
"camel.cloud.netflix"
);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Conditional(ParseConfigurationPhaseCondition.class)
public static class ParseConfigurationPhaseConditionConfiguration extends BaseConfiguration {
}
代码示例来源:origin: spring-cloud/spring-cloud-sleuth
@Configuration
@ConditionalOnMissingBean(name = ZipkinAutoConfiguration.SENDER_BEAN_NAME)
@Conditional(ZipkinSenderCondition.class)
@EnableConfigurationProperties(ZipkinSenderProperties.class)
class ZipkinRestTemplateSenderConfiguration {
@Autowired
ZipkinUrlExtractor extractor;
内容来源于网络,如有侵权,请联系作者删除!