polishing

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2100 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller 2009-10-13 20:59:10 +00:00
parent 3f2884910a
commit fd54577c86
6 changed files with 94 additions and 77 deletions

View File

@ -136,8 +136,7 @@ public class PropertyBatchUpdateException extends BeansException {
if (exType.isInstance(this)) { if (exType.isInstance(this)) {
return true; return true;
} }
for (int i = 0; i < this.propertyAccessExceptions.length; i++) { for (PropertyAccessException pae : this.propertyAccessExceptions) {
PropertyAccessException pae = this.propertyAccessExceptions[i];
if (pae.contains(exType)) { if (pae.contains(exType)) {
return true; return true;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2009 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -74,6 +74,7 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas
} }
@SuppressWarnings("unchecked")
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
if (this.scopes != null) { if (this.scopes != null) {
for (Map.Entry<String, Object> entry : this.scopes.entrySet()) { for (Map.Entry<String, Object> entry : this.scopes.entrySet()) {

View File

@ -426,10 +426,10 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
if (System.getSecurityManager() != null) { if (System.getSecurityManager() != null) {
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() { public Boolean run() {
return Boolean.valueOf(((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean) factoryBean).isPrototype()) || return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean) factoryBean).isPrototype()) ||
!factoryBean.isSingleton())); !factoryBean.isSingleton());
} }
}, getAccessControlContext()).booleanValue(); }, getAccessControlContext());
} }
else { else {
return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean) factoryBean).isPrototype()) || return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean) factoryBean).isPrototype()) ||
@ -1015,9 +1015,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
if (!this.customEditors.isEmpty()) { if (!this.customEditors.isEmpty()) {
for (Map.Entry<Class, Class<? extends PropertyEditor>> entry : this.customEditors.entrySet()) { for (Map.Entry<Class, Class<? extends PropertyEditor>> entry : this.customEditors.entrySet()) {
Class requiredType = entry.getKey(); Class requiredType = entry.getKey();
Class editorClass = entry.getValue(); Class<? extends PropertyEditor> editorClass = entry.getValue();
registry.registerCustomEditor(requiredType, registry.registerCustomEditor(requiredType, BeanUtils.instantiateClass(editorClass));
(PropertyEditor) BeanUtils.instantiateClass(editorClass));
} }
} }
} }
@ -1196,10 +1195,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
if (mbd.hasBeanClass()) { if (mbd.hasBeanClass()) {
return mbd.getBeanClass(); return mbd.getBeanClass();
} }
if (System.getSecurityManager() != null) { if (System.getSecurityManager() != null) {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Class>() { return AccessController.doPrivileged(new PrivilegedExceptionAction<Class>() {
public Class run() throws Exception { public Class run() throws Exception {
return doResolveBeanClass(mbd, typesToMatch); return doResolveBeanClass(mbd, typesToMatch);
} }
@ -1211,10 +1208,10 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
} }
catch (PrivilegedActionException pae) { catch (PrivilegedActionException pae) {
ClassNotFoundException ex = (ClassNotFoundException) pae.getException(); ClassNotFoundException ex = (ClassNotFoundException) pae.getException();
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), (ClassNotFoundException) ex); throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
} }
catch (ClassNotFoundException ex) { catch (ClassNotFoundException ex) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), (ClassNotFoundException) ex); throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
} }
catch (LinkageError err) { catch (LinkageError err) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), err); throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), err);

View File

@ -518,8 +518,8 @@ public class BeanDefinitionParserDelegate {
} }
else if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) { else if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) {
// Spring 1.x "singleton" attribute // Spring 1.x "singleton" attribute
bd.setScope(TRUE_VALUE.equals(ele.getAttribute(SINGLETON_ATTRIBUTE)) ? BeanDefinition.SCOPE_SINGLETON bd.setScope(TRUE_VALUE.equals(ele.getAttribute(SINGLETON_ATTRIBUTE)) ?
: BeanDefinition.SCOPE_PROTOTYPE); BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
} }
else if (containingBean != null) { else if (containingBean != null) {
// Take default from containing bean in case of an inner bean definition. // Take default from containing bean in case of an inner bean definition.

View File

@ -1,3 +1,19 @@
/*
* Copyright 2002-2009 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.jmx.export.annotation; package org.springframework.jmx.export.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@ -13,7 +29,6 @@ import org.springframework.jmx.support.MetricType;
* property as JMX attribute, with added Descriptor properties to indicate that * property as JMX attribute, with added Descriptor properties to indicate that
* it is a metric. Only valid when used on a JavaBean getter. * it is a metric. Only valid when used on a JavaBean getter.
* *
*
* @author Jennifer Hickey * @author Jennifer Hickey
* @since 3.0 * @since 3.0
* @see org.springframework.jmx.export.metadata.ManagedMetric * @see org.springframework.jmx.export.metadata.ManagedMetric
@ -39,4 +54,4 @@ public @interface ManagedMetric {
String unit() default ""; String unit() default "";
} }

View File

@ -1,3 +1,19 @@
/*
* Copyright 2002-2009 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.jmx.export.metadata; package org.springframework.jmx.export.metadata;
import org.springframework.jmx.support.MetricType; import org.springframework.jmx.support.MetricType;
@ -6,7 +22,7 @@ import org.springframework.jmx.support.MetricType;
* Metadata that indicates to expose a given bean property as a JMX attribute, * Metadata that indicates to expose a given bean property as a JMX attribute,
* with additional descriptor properties that indicate that the attribute is a * with additional descriptor properties that indicate that the attribute is a
* metric. Only valid when used on a JavaBean getter. * metric. Only valid when used on a JavaBean getter.
* *
* @author Jennifer Hickey * @author Jennifer Hickey
* @since 3.0 * @since 3.0
* @see org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler * @see org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler
@ -25,100 +41,89 @@ public class ManagedMetric extends AbstractJmxAttribute {
private String unit = ""; private String unit = "";
/**
*
*@return The category of this metric (ex. throughput, performance, utilization)
*/
public String getCategory() {
return category;
}
/** /**
* * The category of this metric (ex. throughput, performance, utilization).
* @return A display name for this metric
*/
public String getDisplayName() {
return displayName;
}
/**
*
* @return A description of how this metric's values change over time
*/
public MetricType getMetricType() {
return metricType;
}
/**
*
* @return The persist period for this metric
*/
public int getPersistPeriod() {
return persistPeriod;
}
/**
*
* @return The persist policy for this metric
*/
public String getPersistPolicy() {
return persistPolicy;
}
/**
*
* @return The expected unit of measurement values
*/
public String getUnit() {
return unit;
}
/**
*
* @param category The category of this metric (ex. throughput, performance, utilization)
*/ */
public void setCategory(String category) { public void setCategory(String category) {
this.category = category; this.category = category;
} }
/** /**
* * The category of this metric (ex. throughput, performance, utilization).
* @param displayName A display name for this metric */
public String getCategory() {
return this.category;
}
/**
* A display name for this metric.
*/ */
public void setDisplayName(String displayName) { public void setDisplayName(String displayName) {
this.displayName = displayName; this.displayName = displayName;
} }
/** /**
* * A display name for this metric.
* @param metricType A description of how this metric's values change over time */
public String getDisplayName() {
return this.displayName;
}
/**
* A description of how this metric's values change over time.
*/ */
public void setMetricType(MetricType metricType) { public void setMetricType(MetricType metricType) {
this.metricType = metricType; this.metricType = metricType;
} }
/** /**
* * A description of how this metric's values change over time.
* @param persistPeriod The persist period for this metric */
public MetricType getMetricType() {
return this.metricType;
}
/**
* The persist period for this metric.
*/ */
public void setPersistPeriod(int persistPeriod) { public void setPersistPeriod(int persistPeriod) {
this.persistPeriod = persistPeriod; this.persistPeriod = persistPeriod;
} }
/** /**
* * The persist period for this metric.
* @param persistPolicy The persist policy for this metric */
public int getPersistPeriod() {
return this.persistPeriod;
}
/**
* The persist policy for this metric.
*/ */
public void setPersistPolicy(String persistPolicy) { public void setPersistPolicy(String persistPolicy) {
this.persistPolicy = persistPolicy; this.persistPolicy = persistPolicy;
} }
/** /**
* * The persist policy for this metric.
* @param unit The expected unit of measurement values */
public String getPersistPolicy() {
return this.persistPolicy;
}
/**
* The expected unit of measurement values.
*/ */
public void setUnit(String unit) { public void setUnit(String unit) {
this.unit = unit; this.unit = unit;
} }
/**
* The expected unit of measurement values.
*/
public String getUnit() {
return this.unit;
}
} }