To use, call invokeVisit, passing a Visitor object
- * and the data argument to accept (double-dispatch). For example:
- *
- *
- * 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>
- * }
- *
- *
- * 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 visit 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 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 null
- */
- Collection getAttributes(Class targetClass);
-
- /**
- * Return the class attributes of the target class of a given type.
- *
The class attributes are filtered by providing a Class
- * 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 null
- */
- Collection getAttributes(Method targetMethod);
-
- /**
- * Return the method attributes of the target method of a given type.
- *
The method attributes are filtered by providing a Class
- * 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 null
- */
- 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 null
- */
- Collection getAttributes(Field targetField);
-
- /**
- * Return the field attributes of the target method of a given type.
- *
The field attributes are filtered by providing a Class
- * 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 null
- */
- Collection getAttributes(Field targetField, Class filter);
-
-}
diff --git a/org.springframework.core/src/main/java/org/springframework/metadata/commons/CommonsAttributes.java b/org.springframework.core/src/main/java/org/springframework/metadata/commons/CommonsAttributes.java
deleted file mode 100644
index 990a0443d0e..00000000000
--- a/org.springframework.core/src/main/java/org/springframework/metadata/commons/CommonsAttributes.java
+++ /dev/null
@@ -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.
- *
- *
Please see the - * - * Commons Attributes documentation for information on how to use the - * attribute compiler. - * - *
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: - *
You need to perform the attribute compilation step before compiling your source. - * - *
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. - * - *
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); - } - -} diff --git a/org.springframework.core/src/main/java/org/springframework/metadata/commons/package.html b/org.springframework.core/src/main/java/org/springframework/metadata/commons/package.html deleted file mode 100644 index 8b073e3b17d..00000000000 --- a/org.springframework.core/src/main/java/org/springframework/metadata/commons/package.html +++ /dev/null @@ -1,8 +0,0 @@ - -
- -Attributes wrapper for -Commons Attributes. - - - diff --git a/org.springframework.core/src/main/java/org/springframework/metadata/package.html b/org.springframework.core/src/main/java/org/springframework/metadata/package.html deleted file mode 100644 index 12c4acf58f0..00000000000 --- a/org.springframework.core/src/main/java/org/springframework/metadata/package.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -Package defining a facade for accessing source-level -metadata attributes at runtime. - - - diff --git a/org.springframework.core/src/main/java/org/springframework/util/ClassLoaderUtils.java b/org.springframework.core/src/main/java/org/springframework/util/ClassLoaderUtils.java deleted file mode 100644 index a6fbbe9b99b..00000000000 --- a/org.springframework.core/src/main/java/org/springframework/util/ClassLoaderUtils.java +++ /dev/null @@ -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); - } - -} diff --git a/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java b/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java index e1f79d1e8eb..41c7f3ac54f 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java +++ b/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java @@ -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()); } diff --git a/org.springframework.core/src/main/java/org/springframework/util/ResponseTimeMonitor.java b/org.springframework.core/src/main/java/org/springframework/util/ResponseTimeMonitor.java deleted file mode 100644 index d1b3f659d24..00000000000 --- a/org.springframework.core/src/main/java/org/springframework/util/ResponseTimeMonitor.java +++ /dev/null @@ -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. - * - *Implementing objects must ensure that implementing this interface - * does not 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(); - -} diff --git a/org.springframework.core/src/main/java/org/springframework/util/ResponseTimeMonitorImpl.java b/org.springframework.core/src/main/java/org/springframework/util/ResponseTimeMonitorImpl.java deleted file mode 100644 index 7f083deeadc..00000000000 --- a/org.springframework.core/src/main/java/org/springframework/util/ResponseTimeMonitorImpl.java +++ /dev/null @@ -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(); - } - -} diff --git a/org.springframework.core/template.mf b/org.springframework.core/template.mf index f2119275e63..0a4613d1164 100644 --- a/org.springframework.core/template.mf +++ b/org.springframework.core/template.mf @@ -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,