Polishing (collapsed if checks, consistent downcasts, refined javadoc)

This commit is contained in:
Juergen Hoeller
2018-03-08 18:11:57 +01:00
parent 0f7485b01d
commit 139dc1d373
50 changed files with 336 additions and 435 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -105,10 +105,8 @@ class ConditionEvaluator {
if (condition instanceof ConfigurationCondition) {
requiredPhase = ((ConfigurationCondition) condition).getConfigurationPhase();
}
if (requiredPhase == null || requiredPhase == phase) {
if (!condition.matches(this.context, metadata)) {
return true;
}
if ((requiredPhase == null || requiredPhase == phase) && !condition.matches(this.context, metadata)) {
return true;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -351,10 +351,8 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
while (!candidates.isEmpty());
// Register the ImportRegistry as a bean in order to support ImportAware @Configuration classes
if (sbr != null) {
if (!sbr.containsSingleton(IMPORT_REGISTRY_BEAN_NAME)) {
sbr.registerSingleton(IMPORT_REGISTRY_BEAN_NAME, parser.getImportRegistry());
}
if (sbr != null && !sbr.containsSingleton(IMPORT_REGISTRY_BEAN_NAME)) {
sbr.registerSingleton(IMPORT_REGISTRY_BEAN_NAME, parser.getImportRegistry());
}
if (this.metadataReaderFactory instanceof CachingMetadataReaderFactory) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -362,10 +362,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
}
for (ResolvableType declaredEventType : this.declaredEventTypes) {
Class<?> eventClass = declaredEventType.getRawClass();
if ((eventClass == null || !ApplicationEvent.class.isAssignableFrom(eventClass)) && payloadType != null) {
if (declaredEventType.isAssignableFrom(payloadType)) {
return declaredEventType;
}
if ((eventClass == null || !ApplicationEvent.class.isAssignableFrom(eventClass)) &&
payloadType != null && declaredEventType.isAssignableFrom(payloadType)) {
return declaredEventType;
}
if (declaredEventType.getRawClass().isInstance(event)) {
return declaredEventType;

View File

@@ -363,25 +363,23 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
ModelMBeanOperationInfo info = null;
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
if (pd != null) {
if ((method.equals(pd.getReadMethod()) && includeReadAttribute(method, beanKey)) ||
(method.equals(pd.getWriteMethod()) && includeWriteAttribute(method, beanKey))) {
// Attributes need to have their methods exposed as
// operations to the JMX server as well.
info = createModelMBeanOperationInfo(method, pd.getName(), beanKey);
Descriptor desc = info.getDescriptor();
if (method.equals(pd.getReadMethod())) {
desc.setField(FIELD_ROLE, ROLE_GETTER);
}
else {
desc.setField(FIELD_ROLE, ROLE_SETTER);
}
desc.setField(FIELD_VISIBILITY, ATTRIBUTE_OPERATION_VISIBILITY);
if (isExposeClassDescriptor()) {
desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName());
}
info.setDescriptor(desc);
if (pd != null && ((method.equals(pd.getReadMethod()) && includeReadAttribute(method, beanKey)) ||
(method.equals(pd.getWriteMethod()) && includeWriteAttribute(method, beanKey)))) {
// Attributes need to have their methods exposed as
// operations to the JMX server as well.
info = createModelMBeanOperationInfo(method, pd.getName(), beanKey);
Descriptor desc = info.getDescriptor();
if (method.equals(pd.getReadMethod())) {
desc.setField(FIELD_ROLE, ROLE_GETTER);
}
else {
desc.setField(FIELD_ROLE, ROLE_SETTER);
}
desc.setField(FIELD_VISIBILITY, ATTRIBUTE_OPERATION_VISIBILITY);
if (isExposeClassDescriptor()) {
desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName());
}
info.setDescriptor(desc);
}
// allow getters and setters to be marked as operations directly

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -158,12 +158,7 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
@Override
protected boolean includeOperation(Method method, String beanKey) {
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
if (pd != null) {
if (hasManagedAttribute(method)) {
return true;
}
}
return hasManagedOperation(method);
return (pd != null && hasManagedAttribute(method)) || hasManagedOperation(method);
}
/**