@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { boolean present = false; int i = 0; while (!present && i < CONDITION_CLASSES.length) { present = ClassUtils.isPresent(CONDITION_CLASSES[i], context.getClassLoader()); i++; } return present; }
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return ClassUtils.isPresent("com.broadleafcommerce.enterprise.foldering.admin.domain.AssetFolder", context.getClassLoader()); }
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return ClassUtils.isPresent("com.broadleafcommerce.accountcredit.profile.core.domain.GiftCardAccount", context.getClassLoader()); }
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return context.getClassLoader() != null && context.getClassLoader().getResource("org/springframework/boot") != null; } }
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return context.getClassLoader() != null && context.getClassLoader().getResource("org/springframework/web/servlet") != null; } }
/** * @inheritDoc */ @Override @SuppressWarnings("all") public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return ClassUtils.isPresent(APACHE_SHIRO_LIFECYCLE_BEAN_POST_PROCESSOR_CLASS_NAME, context.getClassLoader()); } }
/** * @inheritDoc */ @Override @SuppressWarnings("all") public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return ClassUtils.isPresent(APACHE_SHIRO_LIFECYCLE_BEAN_POST_PROCESSOR_CLASS_NAME, context.getClassLoader()); } }
private boolean isWebApplicationContext(ConditionContext context) { ResourceLoader resourceLoader = context.getResourceLoader(); if (resourceLoader instanceof ConfigurableReactiveWebApplicationContext) { return true; } if (!ClassUtils.isPresent(CLASS_NAME_WEB_APPLICATION_CONTEXT, context.getClassLoader())) { return false; } return WebApplicationContext.class.isInstance(resourceLoader); }
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(ConditionalOnClass.class.getName(), true); String className = String.valueOf(attributes.get(AnnotationUtils.VALUE).get(0)); return ClassUtils.isPresent(className, context.getClassLoader()); } }
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(ConditionalOnClass.class.getName(), true); String className = String.valueOf(attributes.get(AnnotationUtils.VALUE).get(0)); return ClassUtils.isPresent(className, context.getClassLoader()); } }
@Override public ConditionOutcome getMatchOutcome(final ConditionContext context, final AnnotatedTypeMetadata metadata) { for (String className : CLASS_NAMES) { if (ClassUtils.isPresent(className, context.getClassLoader())) { return ConditionOutcome.match("found EclipselinkEntityManager class"); } } return ConditionOutcome.noMatch("did not find EclipselinkEntityManager class"); }
@Override public boolean matches( ConditionContext context, AnnotatedTypeMetadata metadata ) { AnnotationAttributes attributes = (AnnotationAttributes) metadata.getAnnotationAttributes( ConditionalOnAutoConfiguration.class.getName(), true ); val registry = AcrossApplicationAutoConfiguration.retrieve( context.getBeanFactory(), context.getClassLoader() ); List<String> required = new ArrayList<>(); String[] classNames = attributes.getStringArray( "value" ); if ( classNames != null ) { required.addAll( Arrays.asList( classNames ) ); } classNames = attributes.getStringArray( "classNames" ); if ( classNames != null ) { required.addAll( Arrays.asList( classNames ) ); } for ( String className : required ) { if ( !registry.notExcluded( className ) ) { return false; } } return true; } }
private Class<?> getEndpointType(ConditionContext context, AnnotatedTypeMetadata metadata) { Map<String, Object> attributes = metadata .getAnnotationAttributes(ConditionalOnEnabledEndpoint.class.getName()); if (attributes != null && attributes.containsKey("endpoint")) { Class<?> target = (Class<?>) attributes.get("endpoint"); if (target != Void.class) { return target; } } Assert.state( metadata instanceof MethodMetadata && metadata.isAnnotated(Bean.class.getName()), "OnEnabledEndpointCondition must be used on @Bean methods when the endpoint is not specified"); MethodMetadata methodMetadata = (MethodMetadata) metadata; try { return ClassUtils.forName(methodMetadata.getReturnTypeName(), context.getClassLoader()); } catch (Throwable ex) { throw new IllegalStateException("Failed to extract endpoint id for " + methodMetadata.getDeclaringClassName() + "." + methodMetadata.getMethodName(), ex); } }
private ConditionOutcome getMatchOutcomeForBasename(ConditionContext context, String basename) { ConditionMessage.Builder message = ConditionMessage .forCondition("ResourceBundle"); for (String name : StringUtils.commaDelimitedListToStringArray( StringUtils.trimAllWhitespace(basename))) { for (Resource resource : getResources(context.getClassLoader(), name)) { if (resource.exists()) { return ConditionOutcome .match(message.found("bundle").items(resource)); } } } return ConditionOutcome.noMatch( message.didNotFind("bundle with basename " + basename).atAll()); }
private ConditionOutcome getMatchOutcomeForBasename(ConditionContext context, String basename) { ConditionMessage.Builder message = ConditionMessage .forCondition("ResourceBundle"); for (String name : StringUtils.commaDelimitedListToStringArray( StringUtils.trimAllWhitespace(basename))) { for (Resource resource : getResources(context.getClassLoader(), name)) { if (resource.exists()) { return ConditionOutcome .match(message.found("bundle").items(resource)); } } } return ConditionOutcome.noMatch( message.didNotFind("bundle with basename " + basename).atAll()); }