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


Java AnnotatedTypeMetadata类代码示例

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


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

示例1: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
    AnnotatedTypeMetadata metadata) {
  String prefix = (String) attribute(metadata, "prefix");
  Class<?> value = (Class<?>) attribute(metadata, "value");
  ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
  try {
    new Binder(ConfigurationPropertySources.from(environment.getPropertySources()))
        .bind(prefix, Bindable.of(value))
        .orElseThrow(
            () -> new FatalBeanException("Could not bind DataSourceSettings properties"));
    return new ConditionOutcome(true, String.format("Map property [%s] is not empty", prefix));
  } catch (Exception e) {
    //ignore
  }
  return new ConditionOutcome(false, String.format("Map property [%s] is empty", prefix));
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:18,代码来源:PrefixPropertyCondition.java

示例2: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	ConfigurableEnvironment environment = (ConfigurableEnvironment) context
			.getEnvironment();
	ResourceProperties properties = new ResourceProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
	binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
	Boolean match = properties.getChain().getEnabled();
	if (match == null) {
		boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
				getClass().getClassLoader());
		return new ConditionOutcome(webJarsLocatorPresent,
				"Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
						+ (webJarsLocatorPresent ? "present" : "absent"));
	}
	return new ConditionOutcome(match,
			"Resource chain is " + (match ? "enabled" : "disabled"));
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:20,代码来源:OnEnabledResourceChainCondition.java

示例3: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	ConditionMessage.Builder message = ConditionMessage
			.forCondition("OAuth JWT Condition");
	Environment environment = context.getEnvironment();
	String keyValue = environment
			.getProperty("security.oauth2.resource.jwt.key-value");
	String keyUri = environment
			.getProperty("security.oauth2.resource.jwt.key-uri");
	if (StringUtils.hasText(keyValue) || StringUtils.hasText(keyUri)) {
		return ConditionOutcome
				.match(message.foundExactly("provided public key"));
	}
	return ConditionOutcome
			.noMatch(message.didNotFind("provided public key").atAll());
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:18,代码来源:ResourceServerTokenServicesConfiguration.java

示例4: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	String[] enablers = context.getBeanFactory()
			.getBeanNamesForAnnotation(EnableOAuth2Sso.class);
	ConditionMessage.Builder message = ConditionMessage
			.forCondition("@EnableOAuth2Sso Condition");
	for (String name : enablers) {
		if (context.getBeanFactory().isTypeMatch(name,
				WebSecurityConfigurerAdapter.class)) {
			return ConditionOutcome.match(message
					.found("@EnableOAuth2Sso annotation on WebSecurityConfigurerAdapter")
					.items(name));
		}
	}
	return ConditionOutcome.noMatch(message.didNotFind(
			"@EnableOAuth2Sso annotation " + "on any WebSecurityConfigurerAdapter")
			.atAll());
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:20,代码来源:EnableOAuth2SsoCondition.java

示例5: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {

	CloudFactory cloudFactory = new CloudFactory();
	try {
		Cloud cloud = cloudFactory.getCloud();
		List<ServiceInfo> serviceInfos = cloud.getServiceInfos();

		for (ServiceInfo serviceInfo : serviceInfos) {
			if (serviceInfo instanceof VaultServiceInfo) {
				return ConditionOutcome.match(String.format(
						"Found Vault service %s", serviceInfo.getId()));
			}
		}

		return ConditionOutcome.noMatch("No Vault service found");
	}
	catch (CloudException e) {
		return ConditionOutcome.noMatch("Not running in a Cloud");
	}
}
 
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:23,代码来源:VaultConnectorBootstrapConfiguration.java

示例6: BeanSearchSpec

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
BeanSearchSpec(ConditionContext context, AnnotatedTypeMetadata metadata, Class<?> annotationType) {
    this.annotationType = annotationType;
    MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(annotationType.getName(), true);
    collect(attributes, "name", this.names);
    collect(attributes, "value", this.types);
    collect(attributes, "type", this.types);
    collect(attributes, "annotation", this.annotations);
    collect(attributes, "ignored", this.ignoredTypes);
    collect(attributes, "ignoredType", this.ignoredTypes);
    this.strategy = (SearchStrategy) metadata.getAnnotationAttributes(annotationType.getName()).get("search");
    BeanTypeDeductionException deductionException = null;
    try {
        if (this.types.isEmpty() && this.names.isEmpty()) {
            addDeducedBeanType(context, metadata, this.types);
        }
    } catch (BeanTypeDeductionException ex) {
        deductionException = ex;
    }
    validate(deductionException);
}
 
开发者ID:drtrang,项目名称:spring-boot-autoconfigure,代码行数:21,代码来源:OnBeansCondition.java

示例7: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
	final RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(),
			"holon.swagger.");

	if (!resolver.getProperty("holon.swagger.enabled", boolean.class, true)) {
		return ConditionOutcome.noMatch(ConditionMessage.forCondition("SwaggerApiAutoDetectCondition")
				.because("holon.swagger.enabled is false"));
	}

	if (resolver.containsProperty("resourcePackage")) {
		return ConditionOutcome.noMatch(
				ConditionMessage.forCondition("SwaggerApiAutoDetectCondition").available("resourcePackage"));
	}
	Map<String, Object> ag = resolver.getSubProperties("apiGroups");
	if (ag != null && ag.size() > 0) {
		return ConditionOutcome
				.noMatch(ConditionMessage.forCondition("SwaggerApiAutoDetectCondition").available("apiGroups"));
	}
	return ConditionOutcome.match();
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:22,代码来源:SwaggerApiAutoDetectCondition.java

示例8: processCommonDefinitionAnnotations

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
static void processCommonDefinitionAnnotations(AnnotatedBeanDefinition abd, AnnotatedTypeMetadata metadata) {
	if (metadata.isAnnotated(Lazy.class.getName())) {
		abd.setLazyInit(attributesFor(metadata, Lazy.class).getBoolean("value"));
	}
	else if (abd.getMetadata().isAnnotated(Lazy.class.getName())) {
		abd.setLazyInit(attributesFor(abd.getMetadata(), Lazy.class).getBoolean("value"));
	}

	if (metadata.isAnnotated(Primary.class.getName())) {
		abd.setPrimary(true);
	}
	if (metadata.isAnnotated(DependsOn.class.getName())) {
		abd.setDependsOn(attributesFor(metadata, DependsOn.class).getStringArray("value"));
	}

	if (abd instanceof AbstractBeanDefinition) {
		AbstractBeanDefinition absBd = (AbstractBeanDefinition) abd;
		if (metadata.isAnnotated(Role.class.getName())) {
			absBd.setRole(attributesFor(metadata, Role.class).getNumber("value").intValue());
		}
		if (metadata.isAnnotated(Description.class.getName())) {
			absBd.setDescription(attributesFor(metadata, Description.class).getString("value"));
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AnnotationConfigUtils.java

示例9: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	ConditionMessage.Builder message = ConditionMessage
			.forCondition("EmbeddedDataSource");
	if (anyMatches(context, metadata, this.pooledCondition)) {
		return ConditionOutcome
				.noMatch(message.foundExactly("supported pooled data source"));
	}
	EmbeddedDatabaseType type = EmbeddedDatabaseConnection
			.get(context.getClassLoader()).getType();
	if (type == null) {
		return ConditionOutcome
				.noMatch(message.didNotFind("embedded database").atAll());
	}
	return ConditionOutcome.match(message.found("embedded database").items(type));
}
 
开发者ID:muxiangqiu,项目名称:spring-boot-multidatasource,代码行数:18,代码来源:DataSourceAutoConfiguration.java

示例10: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
	Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnPropertyPrefix.class.getName());
	if (attributes.containsKey("value")) {
		String prefix = (String) attributes.get("value");
		if (prefix != null && !prefix.trim().equals("")) {
			final String propertyPrefix = !prefix.endsWith(".") ? prefix + "." : prefix;
			ConfigPropertyProvider configPropertyProvider = EnvironmentConfigPropertyProvider
					.create(context.getEnvironment());
			Set<String> names = configPropertyProvider.getPropertyNames()
					.filter((n) -> n.startsWith(propertyPrefix)).collect(Collectors.toSet());
			if (!names.isEmpty()) {
				return ConditionOutcome.match();
			}
			return ConditionOutcome.noMatch(
					ConditionMessage.forCondition(ConditionalOnPropertyPrefix.class).notAvailable(propertyPrefix));
		}
	}
	return ConditionOutcome.match();
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:21,代码来源:OnPropertyPrefixCondition.java

示例11: addDeducedBeanTypeForBeanMethod

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
private void addDeducedBeanTypeForBeanMethod(ConditionContext context,
		AnnotatedTypeMetadata metadata, final List<String> beanTypes,
		final MethodMetadata methodMetadata) {
	try {
		// We should be safe to load at this point since we are in the
		// REGISTER_BEAN phase
		Class<?> configClass = ClassUtils.forName(
				methodMetadata.getDeclaringClassName(), context.getClassLoader());
		ReflectionUtils.doWithMethods(configClass, new MethodCallback() {
			@Override
			public void doWith(Method method)
					throws IllegalArgumentException, IllegalAccessException {
				if (methodMetadata.getMethodName().equals(method.getName())) {
					beanTypes.add(method.getReturnType().getName());
				}
			}
		});
	}
	catch (Throwable ex) {
		throw new BeanTypeDeductionException(
				methodMetadata.getDeclaringClassName(),
				methodMetadata.getMethodName(), ex);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:OnBeanCondition.java

示例12: BeanSearchSpec

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
BeanSearchSpec(ConditionContext context, AnnotatedTypeMetadata metadata,
		Class<?> annotationType) {
	this.annotationType = annotationType;
	MultiValueMap<String, Object> attributes = metadata
			.getAllAnnotationAttributes(annotationType.getName(), true);
	collect(attributes, "name", this.names);
	collect(attributes, "value", this.types);
	collect(attributes, "type", this.types);
	collect(attributes, "annotation", this.annotations);
	collect(attributes, "ignored", this.ignoredTypes);
	collect(attributes, "ignoredType", this.ignoredTypes);
	this.strategy = (SearchStrategy) metadata
			.getAnnotationAttributes(annotationType.getName()).get("search");
	BeanTypeDeductionException deductionException = null;
	try {
		if (this.types.isEmpty() && this.names.isEmpty()) {
			addDeducedBeanType(context, metadata, this.types);
		}
	}
	catch (BeanTypeDeductionException ex) {
		deductionException = ex;
	}
	validate(deductionException);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:25,代码来源:OnBeanCondition.java

示例13: isWebApplication

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
private ConditionOutcome isWebApplication(ConditionContext context,
		AnnotatedTypeMetadata metadata, boolean required) {
	ConditionMessage.Builder message = ConditionMessage.forCondition(
			ConditionalOnWebApplication.class, required ? "(required)" : "");
	if (!ClassUtils.isPresent(WEB_CONTEXT_CLASS, context.getClassLoader())) {
		return ConditionOutcome
				.noMatch(message.didNotFind("web application classes").atAll());
	}
	if (context.getBeanFactory() != null) {
		String[] scopes = context.getBeanFactory().getRegisteredScopeNames();
		if (ObjectUtils.containsElement(scopes, "session")) {
			return ConditionOutcome.match(message.foundExactly("'session' scope"));
		}
	}
	if (context.getEnvironment() instanceof StandardServletEnvironment) {
		return ConditionOutcome
				.match(message.foundExactly("StandardServletEnvironment"));
	}
	if (context.getResourceLoader() instanceof WebApplicationContext) {
		return ConditionOutcome.match(message.foundExactly("WebApplicationContext"));
	}
	return ConditionOutcome.noMatch(message.because("not a web application"));
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:24,代码来源:OnWebApplicationCondition.java

示例14: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
	List<String> dispatchServletBeans = Arrays.asList(beanFactory
			.getBeanNamesForType(DispatcherServlet.class, false, false));
	if (dispatchServletBeans.contains(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
		return ConditionOutcome.noMatch("found DispatcherServlet named "
				+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
	}
	if (beanFactory.containsBean(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
		return ConditionOutcome.noMatch("found non-DispatcherServlet named "
				+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
	}
	if (dispatchServletBeans.isEmpty()) {
		return ConditionOutcome.match("no DispatcherServlet found");
	}
	return ConditionOutcome
			.match("one or more DispatcherServlets found and none is named "
					+ DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:22,代码来源:DispatcherServletAutoConfiguration.java

示例15: getMatchOutcome

import org.springframework.core.type.AnnotatedTypeMetadata; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	Environment environment = context.getEnvironment();
	String config = environment.resolvePlaceholders("${logging.file:}");
	if (StringUtils.hasText(config)) {
		return ConditionOutcome.match("Found logging.file: " + config);
	}
	config = environment.resolvePlaceholders("${logging.path:}");
	if (StringUtils.hasText(config)) {
		return ConditionOutcome.match("Found logging.path: " + config);
	}
	config = new RelaxedPropertyResolver(environment, "endpoints.logfile.")
			.getProperty("external-file");
	if (StringUtils.hasText(config)) {
		return ConditionOutcome
				.match("Found endpoints.logfile.external-file: " + config);
	}
	return ConditionOutcome.noMatch("Found no log file configuration");
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:21,代码来源:EndpointWebMvcManagementContextConfiguration.java


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