- Removed deprecated code
- Removed backport-util-concurrent - Removed commons attributes support
This commit is contained in:
parent
678e5b7cdf
commit
4bc407fef8
|
|
@ -22,11 +22,10 @@
|
|||
<!-- compile dependencies -->
|
||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1" conf="compile->runtime" />
|
||||
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="optional->runtime" />
|
||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.collections" rev="3.2.0" conf="optional->compile" />
|
||||
<!-- These should be replaced with the internal repackaging of ASM -->
|
||||
<dependency org="org.objectweb.asm" name="com.springsource.org.objectweb.asm" rev="2.2.3" conf="optional->compile" />
|
||||
<dependency org="org.objectweb.asm" name="com.springsource.org.objectweb.asm.commons" rev="2.2.3" conf="optional->compile" />
|
||||
<dependency org="edu.emory.mathcs.backport" name="com.springsource.edu.emory.mathcs.backport" rev="3.0.0" conf="optional->compile" />
|
||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.collections" rev="3.2.0" conf="optional->compile" />
|
||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.attributes" rev="2.2.0" conf="optional->compile" />
|
||||
<!-- test dependencies -->
|
||||
<dependency org="org.junit" name="com.springsource.org.junit" rev="4.4.0" conf="test->runtime" />
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import org.springframework.util.ClassUtils;
|
|||
* Spring-based applications/frameworks which were built to support JDK 1.3.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.1.1
|
||||
*/
|
||||
public abstract class CollectionFactory {
|
||||
|
|
@ -68,15 +69,9 @@ public abstract class CollectionFactory {
|
|||
ClassUtils.isPresent("org.apache.commons.collections.map.CaseInsensitiveMap",
|
||||
CollectionFactory.class.getClassLoader());
|
||||
|
||||
/** Whether the backport-concurrent library is present on the classpath */
|
||||
private static final boolean backportConcurrentAvailable =
|
||||
ClassUtils.isPresent("edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap",
|
||||
CollectionFactory.class.getClassLoader());
|
||||
private static final Set<Class> approximableCollectionTypes = new HashSet<Class>(10);
|
||||
|
||||
|
||||
private static final Set approximableCollectionTypes = new HashSet(10);
|
||||
|
||||
private static final Set approximableMapTypes = new HashSet(6);
|
||||
private static final Set<Class> approximableMapTypes = new HashSet<Class>(6);
|
||||
|
||||
static {
|
||||
approximableCollectionTypes.add(Collection.class);
|
||||
|
|
@ -107,33 +102,21 @@ public abstract class CollectionFactory {
|
|||
* @return the new Set instance
|
||||
* @deprecated as of Spring 2.5, for usage on JDK 1.4 or higher
|
||||
*/
|
||||
@Deprecated
|
||||
public static Set createLinkedSetIfPossible(int initialCapacity) {
|
||||
return new LinkedHashSet(initialCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy-on-write Set (allowing for synchronization-less iteration),
|
||||
* requiring JDK >= 1.5 or the backport-concurrent library on the classpath.
|
||||
* Prefers a JDK 1.5+ CopyOnWriteArraySet to its backport-concurrent equivalent.
|
||||
* Throws an IllegalStateException if no copy-on-write Set is available.
|
||||
* Create a copy-on-write Set (allowing for synchronization-less iteration) if possible:
|
||||
* This implementation always creates a {@link java.util.concurrent.CopyOnWriteArraySet},
|
||||
* since Spring 3 requires JDK 1.5 anyway.
|
||||
* @return the new Set instance
|
||||
* @throws IllegalStateException if no copy-on-write Set is available
|
||||
* @see java.util.concurrent.ConcurrentHashMap
|
||||
* @see edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap
|
||||
* @deprecated as of Spring 3.0, for usage on JDK 1.5 or higher
|
||||
*/
|
||||
@Deprecated
|
||||
public static Set createCopyOnWriteSet() {
|
||||
if (JdkVersion.isAtLeastJava15()) {
|
||||
logger.trace("Creating [java.util.concurrent.CopyOnWriteArraySet]");
|
||||
return JdkConcurrentCollectionFactory.createCopyOnWriteArraySet();
|
||||
}
|
||||
else if (backportConcurrentAvailable) {
|
||||
logger.trace("Creating [edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet]");
|
||||
return BackportConcurrentCollectionFactory.createCopyOnWriteArraySet();
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Cannot create CopyOnWriteArraySet - " +
|
||||
"neither JDK 1.5 nor backport-concurrent available on the classpath");
|
||||
}
|
||||
return new CopyOnWriteArraySet();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -144,6 +127,7 @@ public abstract class CollectionFactory {
|
|||
* @return the new Map instance
|
||||
* @deprecated as of Spring 2.5, for usage on JDK 1.4 or higher
|
||||
*/
|
||||
@Deprecated
|
||||
public static Map createLinkedMapIfPossible(int initialCapacity) {
|
||||
return new LinkedHashMap(initialCapacity);
|
||||
}
|
||||
|
|
@ -176,62 +160,37 @@ public abstract class CollectionFactory {
|
|||
* @return the new Map instance
|
||||
* @deprecated as of Spring 2.5, for usage on JDK 1.4 or higher
|
||||
*/
|
||||
@Deprecated
|
||||
public static Map createIdentityMapIfPossible(int initialCapacity) {
|
||||
return new IdentityHashMap(initialCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a concurrent Map if possible: that is, if running on JDK >= 1.5
|
||||
* or if the backport-concurrent library is available. Prefers a JDK 1.5+
|
||||
* ConcurrentHashMap to its backport-concurrent equivalent. Falls back
|
||||
* to a plain synchronized HashMap if no concurrent Map is available.
|
||||
* Create a concurrent Map if possible: This implementation always
|
||||
* creates a {@link java.util.concurrent.ConcurrentHashMap}, since Spring 3.0
|
||||
* required JDK 1.5 anyway.
|
||||
* @param initialCapacity the initial capacity of the Map
|
||||
* @return the new Map instance
|
||||
* @see java.util.concurrent.ConcurrentHashMap
|
||||
* @see edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap
|
||||
* @deprecated as of Spring 3.0, for usage on JDK 1.5 or higher
|
||||
*/
|
||||
@Deprecated
|
||||
public static Map createConcurrentMapIfPossible(int initialCapacity) {
|
||||
if (JdkVersion.isAtLeastJava15()) {
|
||||
logger.trace("Creating [java.util.concurrent.ConcurrentHashMap]");
|
||||
return JdkConcurrentCollectionFactory.createConcurrentHashMap(initialCapacity);
|
||||
}
|
||||
else if (backportConcurrentAvailable) {
|
||||
logger.trace("Creating [edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap]");
|
||||
return BackportConcurrentCollectionFactory.createConcurrentHashMap(initialCapacity);
|
||||
}
|
||||
else {
|
||||
logger.debug("Falling back to plain synchronized [java.util.HashMap] for concurrent map");
|
||||
return Collections.synchronizedMap(new HashMap(initialCapacity));
|
||||
}
|
||||
return new ConcurrentHashMap(initialCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a concurrent Map with a dedicated {@link ConcurrentMap} interface,
|
||||
* requiring JDK >= 1.5 or the backport-concurrent library on the classpath.
|
||||
* Prefers a JDK 1.5+ ConcurrentHashMap to its backport-concurrent equivalent.
|
||||
* Throws an IllegalStateException if no concurrent Map is available.
|
||||
* Create a concurrent Map with a dedicated {@link ConcurrentMap} interface:
|
||||
* This implementation always creates a {@link java.util.concurrent.ConcurrentHashMap},
|
||||
* since Spring 3.0 required JDK 1.5 anyway.
|
||||
* @param initialCapacity the initial capacity of the Map
|
||||
* @return the new ConcurrentMap instance
|
||||
* @throws IllegalStateException if no concurrent Map is available
|
||||
* @see java.util.concurrent.ConcurrentHashMap
|
||||
* @see edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap
|
||||
* @deprecated as of Spring 3.0, for usage on JDK 1.5 or higher
|
||||
*/
|
||||
@Deprecated
|
||||
public static ConcurrentMap createConcurrentMap(int initialCapacity) {
|
||||
if (JdkVersion.isAtLeastJava15()) {
|
||||
logger.trace("Creating [java.util.concurrent.ConcurrentHashMap]");
|
||||
return new JdkConcurrentHashMap(initialCapacity);
|
||||
}
|
||||
else if (backportConcurrentAvailable) {
|
||||
logger.trace("Creating [edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap]");
|
||||
return new BackportConcurrentHashMap(initialCapacity);
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Cannot create ConcurrentHashMap - " +
|
||||
"neither JDK 1.5 nor backport-concurrent available on the classpath");
|
||||
}
|
||||
return new JdkConcurrentHashMap(initialCapacity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether the given collection type is an approximable type,
|
||||
* i.e. a type that {@link #createApproximateCollection} can approximate.
|
||||
|
|
@ -312,38 +271,6 @@ public abstract class CollectionFactory {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Actual creation of JDK 1.5+ concurrent Collections.
|
||||
* In separate inner class to avoid runtime dependency on JDK 1.5.
|
||||
*/
|
||||
private static abstract class JdkConcurrentCollectionFactory {
|
||||
|
||||
private static Set createCopyOnWriteArraySet() {
|
||||
return new CopyOnWriteArraySet();
|
||||
}
|
||||
|
||||
private static Map createConcurrentHashMap(int initialCapacity) {
|
||||
return new ConcurrentHashMap(initialCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Actual creation of backport-concurrent Collections.
|
||||
* In separate inner class to avoid runtime dependency on the backport-concurrent library.
|
||||
*/
|
||||
private static abstract class BackportConcurrentCollectionFactory {
|
||||
|
||||
private static Set createCopyOnWriteArraySet() {
|
||||
return new edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet();
|
||||
}
|
||||
|
||||
private static Map createConcurrentHashMap(int initialCapacity) {
|
||||
return new edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap(initialCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ConcurrentMap adapter for the JDK ConcurrentHashMap class.
|
||||
*/
|
||||
|
|
@ -354,17 +281,4 @@ public abstract class CollectionFactory {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ConcurrentMap adapter for the backport-concurrent ConcurrentHashMap class.
|
||||
*/
|
||||
private static class BackportConcurrentHashMap
|
||||
extends edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap
|
||||
implements ConcurrentMap {
|
||||
|
||||
public BackportConcurrentHashMap(int initialCapacity) {
|
||||
super(initialCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,225 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2008 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.core;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CachingMapDecorator;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Helper implementation for a reflective visitor.
|
||||
* Mainly for internal use within the framework.
|
||||
*
|
||||
* <p>To use, call <code>invokeVisit</code>, passing a Visitor object
|
||||
* and the data argument to accept (double-dispatch). For example:
|
||||
*
|
||||
* <pre>
|
||||
* public String styleValue(Object value) {
|
||||
* reflectiveVistorSupport.invokeVisit(this, value)
|
||||
* }
|
||||
*
|
||||
* // visit call back will be invoked via reflection
|
||||
* String visit(<valueType> arg) {
|
||||
* // process argument of type <valueType>
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* See the {@link org.springframework.core.style.DefaultValueStyler} class
|
||||
* for a concrete usage of this visitor helper.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.2.2
|
||||
* @deprecated as of Spring 2.5, to be removed in Spring 3.0
|
||||
*/
|
||||
public class ReflectiveVisitorHelper {
|
||||
|
||||
private static final String VISIT_METHOD = "visit";
|
||||
|
||||
private static final String VISIT_NULL = "visitNull";
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ReflectiveVisitorHelper.class);
|
||||
|
||||
|
||||
private final CachingMapDecorator visitorClassVisitMethods = new CachingMapDecorator() {
|
||||
public Object create(Object key) {
|
||||
return new ClassVisitMethods((Class) key);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Use reflection to call the appropriate <code>visit</code> method
|
||||
* on the provided visitor, passing in the specified argument.
|
||||
* @param visitor the visitor encapsulating the logic to process the argument
|
||||
* @param argument the argument to dispatch
|
||||
* @throws IllegalArgumentException if the visitor parameter is null
|
||||
*/
|
||||
public Object invokeVisit(Object visitor, Object argument) {
|
||||
Assert.notNull(visitor, "The visitor to visit is required");
|
||||
// Perform call back on the visitor through reflection.
|
||||
Method method = getMethod(visitor.getClass(), argument);
|
||||
if (method == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("No method found by reflection for visitor class [" + visitor.getClass().getName()
|
||||
+ "] and argument of type [" + (argument != null ? argument.getClass().getName() : "") + "]");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Object[] args = null;
|
||||
if (argument != null) {
|
||||
args = new Object[] {argument};
|
||||
}
|
||||
if (!Modifier.isPublic(method.getModifiers())) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
return method.invoke(visitor, args);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ReflectionUtils.handleReflectionException(ex);
|
||||
throw new IllegalStateException("Should never get here");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the most appropriate visit method for the
|
||||
* given visitor class and argument.
|
||||
*/
|
||||
private Method getMethod(Class visitorClass, Object argument) {
|
||||
ClassVisitMethods visitMethods = (ClassVisitMethods) this.visitorClassVisitMethods.get(visitorClass);
|
||||
return visitMethods.getVisitMethod(argument != null ? argument.getClass() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internal class caching visitor methods by argument class.
|
||||
*/
|
||||
private static class ClassVisitMethods {
|
||||
|
||||
private final Class visitorClass;
|
||||
|
||||
private final CachingMapDecorator visitMethodCache = new CachingMapDecorator() {
|
||||
public Object create(Object argumentClazz) {
|
||||
if (argumentClazz == null) {
|
||||
return findNullVisitorMethod();
|
||||
}
|
||||
Method method = findVisitMethod((Class) argumentClazz);
|
||||
if (method == null) {
|
||||
method = findDefaultVisitMethod();
|
||||
}
|
||||
return method;
|
||||
}
|
||||
};
|
||||
|
||||
public ClassVisitMethods(Class visitorClass) {
|
||||
this.visitorClass = visitorClass;
|
||||
}
|
||||
|
||||
private Method findNullVisitorMethod() {
|
||||
for (Class clazz = this.visitorClass; clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
return clazz.getDeclaredMethod(VISIT_NULL, (Class[]) null);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
}
|
||||
}
|
||||
return findDefaultVisitMethod();
|
||||
}
|
||||
|
||||
private Method findDefaultVisitMethod() {
|
||||
final Class[] args = {Object.class};
|
||||
for (Class clazz = this.visitorClass; clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
return clazz.getDeclaredMethod(VISIT_METHOD, args);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
}
|
||||
}
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("No default '" + VISIT_METHOD + "' method found. Returning <null>.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cached visitor method for the specified argument type.
|
||||
*/
|
||||
private Method getVisitMethod(Class argumentClass) {
|
||||
return (Method) this.visitMethodCache.get(argumentClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverses class hierarchy looking for applicable visit() method.
|
||||
*/
|
||||
private Method findVisitMethod(Class rootArgumentType) {
|
||||
if (rootArgumentType == Object.class) {
|
||||
return null;
|
||||
}
|
||||
LinkedList classQueue = new LinkedList();
|
||||
classQueue.addFirst(rootArgumentType);
|
||||
|
||||
while (!classQueue.isEmpty()) {
|
||||
Class argumentType = (Class) classQueue.removeLast();
|
||||
// Check for a visit method on the visitor class matching this
|
||||
// argument type.
|
||||
try {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Looking for method " + VISIT_METHOD + "(" + argumentType + ")");
|
||||
}
|
||||
return findVisitMethod(this.visitorClass, argumentType);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
// Queue up the argument super class if it's not of type Object.
|
||||
if (!argumentType.isInterface() && (argumentType.getSuperclass() != Object.class)) {
|
||||
classQueue.addFirst(argumentType.getSuperclass());
|
||||
}
|
||||
// Queue up argument's implemented interfaces.
|
||||
Class[] interfaces = argumentType.getInterfaces();
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
classQueue.addFirst(interfaces[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// No specific method found -> return the default.
|
||||
return findDefaultVisitMethod();
|
||||
}
|
||||
|
||||
private Method findVisitMethod(Class visitorClass, Class argumentType) throws NoSuchMethodException {
|
||||
try {
|
||||
return visitorClass.getDeclaredMethod(VISIT_METHOD, new Class[] {argumentType});
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
// Try visitorClass superclasses.
|
||||
if (visitorClass.getSuperclass() != Object.class) {
|
||||
return findVisitMethod(visitorClass.getSuperclass(), argumentType);
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -49,6 +49,7 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator implement
|
|||
* @deprecated as of Spring 2.0.3, since the default thread name prefix
|
||||
* is now taken from the concrete class (could be a subclass)
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String DEFAULT_THREAD_NAME_PREFIX =
|
||||
ClassUtils.getShortName(SimpleAsyncTaskExecutor.class) + "-";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2005 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.metadata;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Interface for accessing attributes at runtime. This is a facade,
|
||||
* which can accommodate any attributes API such as Jakarta Commons Attributes,
|
||||
* or (possibly in future) a Spring attributes implementation.
|
||||
*
|
||||
* <p>The purpose of using this interface is to decouple Spring code from any
|
||||
* specific attributes implementation. Even once JSR-175 is available, there
|
||||
* is still value in such a facade interface, as it allows for hierarchical
|
||||
* attribute sources: for example, an XML file or properties file might override
|
||||
* some attributes defined in source-level metadata with JSR-175 or another framework.
|
||||
*
|
||||
* @author Mark Pollack
|
||||
* @author Rod Johnson
|
||||
* @since 30.09.2003
|
||||
* @see org.springframework.metadata.commons.CommonsAttributes
|
||||
*/
|
||||
public interface Attributes {
|
||||
|
||||
/**
|
||||
* Return the class attributes of the target class.
|
||||
* @param targetClass the class that contains attribute information
|
||||
* @return a collection of attributes, possibly an empty collection, never <code>null</code>
|
||||
*/
|
||||
Collection getAttributes(Class targetClass);
|
||||
|
||||
/**
|
||||
* Return the class attributes of the target class of a given type.
|
||||
* <p>The class attributes are filtered by providing a <code>Class</code>
|
||||
* reference to indicate the type to filter on. This is useful if you know
|
||||
* the type of the attribute you are looking for and don't want to sort
|
||||
* through the unfiltered Collection yourself.
|
||||
* @param targetClass the class that contains attribute information
|
||||
* @param filter specify that only this type of class should be returned
|
||||
* @return return only the Collection of attributes that are of the filter type
|
||||
*/
|
||||
Collection getAttributes(Class targetClass, Class filter);
|
||||
|
||||
/**
|
||||
* Return the method attributes of the target method.
|
||||
* @param targetMethod the method that contains attribute information
|
||||
* @return a Collection of attributes, possibly an empty Collection, never <code>null</code>
|
||||
*/
|
||||
Collection getAttributes(Method targetMethod);
|
||||
|
||||
/**
|
||||
* Return the method attributes of the target method of a given type.
|
||||
* <p>The method attributes are filtered by providing a <code>Class</code>
|
||||
* reference to indicate the type to filter on. This is useful if you know
|
||||
* the type of the attribute you are looking for and don't want to sort
|
||||
* through the unfiltered Collection yourself.
|
||||
* @param targetMethod the method that contains attribute information
|
||||
* @param filter specify that only this type of class should be returned
|
||||
* @return a Collection of attributes, possibly an empty Collection, never <code>null</code>
|
||||
*/
|
||||
Collection getAttributes(Method targetMethod, Class filter);
|
||||
|
||||
/**
|
||||
* Return the field attributes of the target field.
|
||||
* @param targetField the field that contains attribute information
|
||||
* @return a Collection of attribute, possibly an empty Collection, never <code>null</code>
|
||||
*/
|
||||
Collection getAttributes(Field targetField);
|
||||
|
||||
/**
|
||||
* Return the field attributes of the target method of a given type.
|
||||
* <p>The field attributes are filtered by providing a <code>Class</code>
|
||||
* reference to indicate the type to filter on. This is useful if you know
|
||||
* the type of the attribute you are looking for and don't want to sort
|
||||
* through the unfiltered Collection yourself.
|
||||
* @param targetField the field that contains attribute information
|
||||
* @param filter specify that only this type of class should be returned
|
||||
* @return a Collection of attributes, possibly an empty Collection, never <code>null</code>
|
||||
*/
|
||||
Collection getAttributes(Field targetField, Class filter);
|
||||
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2005 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.metadata.commons;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.metadata.Attributes;
|
||||
|
||||
/**
|
||||
* Implementation of the Spring Attributes facade for Commons Attributes.
|
||||
*
|
||||
* <p>Please see the
|
||||
* <a href="http://jakarta.apache.org/commons/sandbox/attributes">
|
||||
* Commons Attributes documentation</a> for information on how to use the
|
||||
* attribute compiler.
|
||||
*
|
||||
* <p>As of December 2003, follow the Javadocs to the AttributeCompiler class
|
||||
* to see how the Ant task works. Note that you need to put the following jars
|
||||
* in your $ANT_HOME/lib directory for the Common Attributes compiler to work:
|
||||
* <ul>
|
||||
* <li>Commons Attributes compiler jar
|
||||
* <li>the xjavadoc Jar (from XDoclet)
|
||||
* <li>commons-collection.jar (from Jakarta Commons)
|
||||
* </ul>
|
||||
*
|
||||
* <p>You need to perform the attribute compilation step before compiling your source.
|
||||
*
|
||||
* <p>See build.xml in the tests for package org.springframework.aop.autoproxy.metadata
|
||||
* for an example of the required Ant scripting. The header of this build script
|
||||
* includes some quick, and hopefully useful, hints on using Commons Attributes.
|
||||
* The source files in the same package (TxClass and TxClassWithClassAttribute)
|
||||
* illustrate attribute usage in source files.
|
||||
*
|
||||
* <p>The Spring Framework project does not provide support usage of specific
|
||||
* attributes implementations. Please refer to the appropriate site and mailing
|
||||
* list of the attributes implementation.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public class CommonsAttributes implements Attributes {
|
||||
|
||||
/*
|
||||
* Commons Attributes caches attributes, so we don't need to cache here
|
||||
* as well.
|
||||
*/
|
||||
|
||||
public Collection getAttributes(Class targetClass) {
|
||||
return org.apache.commons.attributes.Attributes.getAttributes(targetClass);
|
||||
}
|
||||
|
||||
public Collection getAttributes(Class targetClass, Class filter) {
|
||||
return org.apache.commons.attributes.Attributes.getAttributes(targetClass, filter);
|
||||
}
|
||||
|
||||
public Collection getAttributes(Method targetMethod) {
|
||||
return org.apache.commons.attributes.Attributes.getAttributes(targetMethod);
|
||||
}
|
||||
|
||||
public Collection getAttributes(Method targetMethod, Class filter) {
|
||||
return org.apache.commons.attributes.Attributes.getAttributes(targetMethod, filter);
|
||||
}
|
||||
|
||||
public Collection getAttributes(Field targetField) {
|
||||
return org.apache.commons.attributes.Attributes.getAttributes(targetField);
|
||||
}
|
||||
|
||||
public Collection getAttributes(Field targetField, Class filter) {
|
||||
return org.apache.commons.attributes.Attributes.getAttributes(targetField, filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<html>
|
||||
<body>
|
||||
|
||||
Attributes wrapper for
|
||||
<a href="http://jakarta.apache.org/commons/sandbox/attributes">Commons Attributes</a>.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<html>
|
||||
<body>
|
||||
|
||||
Package defining a facade for accessing source-level
|
||||
metadata attributes at runtime.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2008 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.util;
|
||||
|
||||
/**
|
||||
* Utility class for diagnostic purposes, to analyze the
|
||||
* ClassLoader hierarchy for any given object or class loader.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @since 02 April 2001
|
||||
* @deprecated as of Spring 2.5, to be removed in Spring 3.0
|
||||
* @see java.lang.ClassLoader
|
||||
*/
|
||||
public abstract class ClassLoaderUtils {
|
||||
|
||||
/**
|
||||
* Show the class loader hierarchy for this class.
|
||||
* Uses default line break and tab text characters.
|
||||
* @param obj object to analyze loader hierarchy for
|
||||
* @param role a description of the role of this class in the application
|
||||
* (e.g., "servlet" or "EJB reference")
|
||||
* @return a String showing the class loader hierarchy for this class
|
||||
*/
|
||||
public static String showClassLoaderHierarchy(Object obj, String role) {
|
||||
return showClassLoaderHierarchy(obj, role, "\n", "\t");
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the class loader hierarchy for this class.
|
||||
* @param obj object to analyze loader hierarchy for
|
||||
* @param role a description of the role of this class in the application
|
||||
* (e.g., "servlet" or "EJB reference")
|
||||
* @param lineBreak line break
|
||||
* @param tabText text to use to set tabs
|
||||
* @return a String showing the class loader hierarchy for this class
|
||||
*/
|
||||
public static String showClassLoaderHierarchy(Object obj, String role, String lineBreak, String tabText) {
|
||||
String s = "object of " + obj.getClass() + ": role is " + role + lineBreak;
|
||||
return s + showClassLoaderHierarchy(obj.getClass().getClassLoader(), lineBreak, tabText, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the class loader hierarchy for the given class loader.
|
||||
* Uses default line break and tab text characters.
|
||||
* @param cl class loader to analyze hierarchy for
|
||||
* @return a String showing the class loader hierarchy for this class
|
||||
*/
|
||||
public static String showClassLoaderHierarchy(ClassLoader cl) {
|
||||
return showClassLoaderHierarchy(cl, "\n", "\t");
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the class loader hierarchy for the given class loader.
|
||||
* @param cl class loader to analyze hierarchy for
|
||||
* @param lineBreak line break
|
||||
* @param tabText text to use to set tabs
|
||||
* @return a String showing the class loader hierarchy for this class
|
||||
*/
|
||||
public static String showClassLoaderHierarchy(ClassLoader cl, String lineBreak, String tabText) {
|
||||
return showClassLoaderHierarchy(cl, lineBreak, tabText, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the class loader hierarchy for the given class loader.
|
||||
* @param cl class loader to analyze hierarchy for
|
||||
* @param lineBreak line break
|
||||
* @param tabText text to use to set tabs
|
||||
* @param indent nesting level (from 0) of this loader; used in pretty printing
|
||||
* @return a String showing the class loader hierarchy for this class
|
||||
*/
|
||||
private static String showClassLoaderHierarchy(ClassLoader cl, String lineBreak, String tabText, int indent) {
|
||||
if (cl == null) {
|
||||
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
|
||||
return "context class loader=[" + ccl + "] hashCode=" + ccl.hashCode();
|
||||
}
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; i < indent; i++) {
|
||||
buf.append(tabText);
|
||||
}
|
||||
buf.append("[").append(cl).append("] hashCode=").append(cl.hashCode()).append(lineBreak);
|
||||
ClassLoader parent = cl.getParent();
|
||||
return buf.toString() + showClassLoaderHierarchy(parent, lineBreak, tabText, indent + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -271,6 +271,7 @@ public abstract class ClassUtils {
|
|||
* @return whether the specified class is present
|
||||
* @deprecated as of Spring 2.5, in favor of {@link #isPresent(String, ClassLoader)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isPresent(String className) {
|
||||
return isPresent(className, getDefaultClassLoader());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2008 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.util;
|
||||
|
||||
/**
|
||||
* Interface implemented by objects that can provide performance information
|
||||
* as well as a record of the number of times they are accessed.
|
||||
*
|
||||
* <p>Implementing objects must ensure that implementing this interface
|
||||
* does <b>not</b> compromise thread safety. However, it may be acceptable
|
||||
* for slight innaccuracies in reported statistics to result from the
|
||||
* avoidance of synchronization: performance may be well be more important
|
||||
* than exact reporting, so long as the errors are not likely to be misleading.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @since November 21, 2000
|
||||
* @deprecated as of Spring 2.5, to be removed in Spring 3.0
|
||||
*/
|
||||
public interface ResponseTimeMonitor {
|
||||
|
||||
/**
|
||||
* Return the number of accesses to this resource.
|
||||
*/
|
||||
int getAccessCount();
|
||||
|
||||
/**
|
||||
* Return the average response time in milliseconds.
|
||||
*/
|
||||
int getAverageResponseTimeMillis();
|
||||
|
||||
/**
|
||||
* Return the best (quickest) response time in milliseconds.
|
||||
*/
|
||||
int getBestResponseTimeMillis();
|
||||
|
||||
/**
|
||||
* Return the worst (slowest) response time in milliseconds.
|
||||
*/
|
||||
int getWorstResponseTimeMillis();
|
||||
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2008 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.util;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link ResponseTimeMonitor}.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @since November 21, 2000
|
||||
* @deprecated as of Spring 2.5, to be removed in Spring 3.0
|
||||
*/
|
||||
public class ResponseTimeMonitorImpl implements ResponseTimeMonitor {
|
||||
|
||||
/** The system time at which this object was initialized */
|
||||
private final long initedMillis = System.currentTimeMillis();
|
||||
|
||||
/** The number of operations recorded by this object */
|
||||
private volatile int accessCount;
|
||||
|
||||
/** The sum of the response times for all operations */
|
||||
private volatile int totalResponseTimeMillis = 0;
|
||||
|
||||
/** The best response time this object has recorded */
|
||||
private volatile int bestResponseTimeMillis = Integer.MAX_VALUE;
|
||||
|
||||
/** The worst response time this object has recorded */
|
||||
private volatile int worstResponseTimeMillis = Integer.MIN_VALUE;
|
||||
|
||||
|
||||
/**
|
||||
* Return the date when this object was loaded.
|
||||
*/
|
||||
public Date getLoadDate() {
|
||||
return new Date(this.initedMillis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of hits this object has handled.
|
||||
*/
|
||||
public int getAccessCount() {
|
||||
return this.accessCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of milliseconds since this object was loaded.
|
||||
*/
|
||||
public long getUptimeMillis() {
|
||||
return System.currentTimeMillis() - this.initedMillis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the average response time achieved by this object.
|
||||
*/
|
||||
public int getAverageResponseTimeMillis() {
|
||||
int count = getAccessCount();
|
||||
// avoid division by 0
|
||||
return (count != 0 ? this.totalResponseTimeMillis / count : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the best (lowest) response time achieved by this object.
|
||||
*/
|
||||
public int getBestResponseTimeMillis() {
|
||||
return this.bestResponseTimeMillis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the worst (slowest) response time achieved by this object.
|
||||
*/
|
||||
public int getWorstResponseTimeMillis() {
|
||||
return this.worstResponseTimeMillis;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility method to record this response time, updating
|
||||
* the best and worst response times if necessary.
|
||||
* @param responseTimeMillis the response time of this request
|
||||
*/
|
||||
public synchronized void recordResponseTime(long responseTimeMillis) {
|
||||
++this.accessCount;
|
||||
int iResponseTime = (int) responseTimeMillis;
|
||||
this.totalResponseTimeMillis += iResponseTime;
|
||||
if (iResponseTime < this.bestResponseTimeMillis) {
|
||||
this.bestResponseTimeMillis = iResponseTime;
|
||||
}
|
||||
if (iResponseTime > this.worstResponseTimeMillis) {
|
||||
this.worstResponseTimeMillis = iResponseTime;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a human-readable string showing the performance
|
||||
* data recorded by this object.
|
||||
*/
|
||||
public synchronized String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("hits=[").append(getAccessCount()).append("]; ");
|
||||
sb.append("average=[").append(getAverageResponseTimeMillis()).append("ms]; ");
|
||||
sb.append("best=[").append(getBestResponseTimeMillis()).append("ms]; ");
|
||||
sb.append("worst=[").append(getWorstResponseTimeMillis()).append("ms]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ Bundle-Vendor: SpringSource
|
|||
Bundle-ManifestVersion: 2
|
||||
Import-Template:
|
||||
edu.emory.mathcs.backport.*;version="[3.0.0, 4.0.0)";resolution:=optional,
|
||||
org.apache.commons.attributes.*;version="[2.2.0, 3.0.0)";resolution:=optional,
|
||||
org.apache.commons.collections.*;version="[3.2.0, 4.0.0)";resolution:=optional,
|
||||
org.apache.commons.logging.*;version="[1.1.1, 2.0.0)",
|
||||
org.objectweb.asm.*;version="[2.2.3, 3.0.0)";resolution:=optional,
|
||||
|
|
|
|||
Loading…
Reference in New Issue