AnnotationUtils.java 20.6 KB
Newer Older
A
Arjen Poutsma 已提交
1
/*
2
 * Copyright 2002-2012 the original author or authors.
A
Arjen Poutsma 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * 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.annotation;

import java.lang.annotation.Annotation;
20
import java.lang.reflect.AnnotatedElement;
A
Arjen Poutsma 已提交
21 22 23
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Map;
24
import java.util.WeakHashMap;
A
Arjen Poutsma 已提交
25 26 27 28 29

import org.springframework.core.BridgeMethodResolver;
import org.springframework.util.Assert;

/**
J
Juergen Hoeller 已提交
30 31 32
 * General utility methods for working with annotations, handling bridge methods (which the compiler
 * generates for generic declarations) as well as super methods (for optional "annotation inheritance").
 * Note that none of this is provided by the JDK's introspection facilities themselves.
A
Arjen Poutsma 已提交
33
 *
J
Juergen Hoeller 已提交
34 35 36 37 38 39
 * <p>As a general rule for runtime-retained annotations (e.g. for transaction control, authorization or service
 * exposure), always use the lookup methods on this class (e.g., {@link #findAnnotation(Method, Class)}, {@link
 * #getAnnotation(Method, Class)}, and {@link #getAnnotations(Method)}) instead of the plain annotation lookup
 * methods in the JDK. You can still explicitly choose between lookup on the given class level only ({@link
 * #getAnnotation(Method, Class)}) and lookup in the entire inheritance hierarchy of the given method ({@link
 * #findAnnotation(Method, Class)}).
A
Arjen Poutsma 已提交
40 41 42 43 44
 *
 * @author Rob Harrop
 * @author Juergen Hoeller
 * @author Sam Brannen
 * @author Mark Fisher
C
Chris Beams 已提交
45
 * @author Chris Beams
A
Arjen Poutsma 已提交
46 47 48 49 50 51 52
 * @since 2.0
 * @see java.lang.reflect.Method#getAnnotations()
 * @see java.lang.reflect.Method#getAnnotation(Class)
 */
public abstract class AnnotationUtils {

	/** The attribute name for annotations with a single element */
J
Juergen Hoeller 已提交
53
	static final String VALUE = "value";
A
Arjen Poutsma 已提交
54

55
	private static final Map<Class<?>, Boolean> annotatedInterfaceCache = new WeakHashMap<Class<?>, Boolean>();
56

J
Juergen Hoeller 已提交
57

58
	/**
C
Chris Beams 已提交
59 60 61 62 63 64 65
	 * Get a single {@link Annotation} of {@code annotationType} from the supplied
	 * Method, Constructor or Field. Meta-annotations will be searched if the annotation
	 * is not declared locally on the supplied element.
	 * @param ae the Method, Constructor or Field from which to get the annotation
	 * @param annotationType the annotation class to look for, both locally and as a meta-annotation
	 * @return the matching annotation or {@code null} if not found
	 * @since 3.1
66 67 68 69 70 71 72 73 74 75 76 77 78 79
	 */
	public static <T extends Annotation> T getAnnotation(AnnotatedElement ae, Class<T> annotationType) {
		T ann = ae.getAnnotation(annotationType);
		if (ann == null) {
			for (Annotation metaAnn : ae.getAnnotations()) {
				ann = metaAnn.annotationType().getAnnotation(annotationType);
				if (ann != null) {
					break;
				}
			}
		}
		return ann;
	}

A
Arjen Poutsma 已提交
80 81 82 83 84 85 86 87 88 89 90 91
	/**
	 * Get all {@link Annotation Annotations} from the supplied {@link Method}.
	 * <p>Correctly handles bridge {@link Method Methods} generated by the compiler.
	 * @param method the method to look for annotations on
	 * @return the annotations found
	 * @see org.springframework.core.BridgeMethodResolver#findBridgedMethod(Method)
	 */
	public static Annotation[] getAnnotations(Method method) {
		return BridgeMethodResolver.findBridgedMethod(method).getAnnotations();
	}

	/**
J
Juergen Hoeller 已提交
92
	 * Get a single {@link Annotation} of <code>annotationType</code> from the supplied {@link Method}.
A
Arjen Poutsma 已提交
93 94 95 96 97 98 99
	 * <p>Correctly handles bridge {@link Method Methods} generated by the compiler.
	 * @param method the method to look for annotations on
	 * @param annotationType the annotation class to look for
	 * @return the annotations found
	 * @see org.springframework.core.BridgeMethodResolver#findBridgedMethod(Method)
	 */
	public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
100 101 102 103 104 105 106 107 108 109 110
		Method resolvedMethod = BridgeMethodResolver.findBridgedMethod(method);
		A ann = resolvedMethod.getAnnotation(annotationType);
		if (ann == null) {
			for (Annotation metaAnn : resolvedMethod.getAnnotations()) {
				ann = metaAnn.annotationType().getAnnotation(annotationType);
				if (ann != null) {
					break;
				}
			}
		}
		return ann;
A
Arjen Poutsma 已提交
111 112 113
	}

	/**
J
Juergen Hoeller 已提交
114 115 116
	 * Get a single {@link Annotation} of <code>annotationType</code> from the supplied {@link Method},
	 * traversing its super methods if no annotation can be found on the given method itself.
	 * <p>Annotations on methods are not inherited by default, so we need to handle this explicitly.
A
Arjen Poutsma 已提交
117 118 119 120 121 122 123
	 * @param method the method to look for annotations on
	 * @param annotationType the annotation class to look for
	 * @return the annotation found, or <code>null</code> if none found
	 */
	public static <A extends Annotation> A findAnnotation(Method method, Class<A> annotationType) {
		A annotation = getAnnotation(method, annotationType);
		Class<?> cl = method.getDeclaringClass();
J
Juergen Hoeller 已提交
124 125
		if (annotation == null) {
			annotation = searchOnInterfaces(method, annotationType, cl.getInterfaces());
126
		}
A
Arjen Poutsma 已提交
127 128 129 130 131 132 133 134 135 136
		while (annotation == null) {
			cl = cl.getSuperclass();
			if (cl == null || cl == Object.class) {
				break;
			}
			try {
				Method equivalentMethod = cl.getDeclaredMethod(method.getName(), method.getParameterTypes());
				annotation = getAnnotation(equivalentMethod, annotationType);
			}
			catch (NoSuchMethodException ex) {
137 138 139 140
				// No equivalent method found
			}
			if (annotation == null) {
				annotation = searchOnInterfaces(method, annotationType, cl.getInterfaces());
A
Arjen Poutsma 已提交
141 142 143 144 145
			}
		}
		return annotation;
	}

146
	private static <A extends Annotation> A searchOnInterfaces(Method method, Class<A> annotationType, Class<?>[] ifcs) {
147
		A annotation = null;
J
Juergen Hoeller 已提交
148
		for (Class<?> iface : ifcs) {
149 150 151 152 153 154 155 156 157 158 159
			if (isInterfaceWithAnnotatedMethods(iface)) {
				try {
					Method equivalentMethod = iface.getMethod(method.getName(), method.getParameterTypes());
					annotation = getAnnotation(equivalentMethod, annotationType);
				}
				catch (NoSuchMethodException ex) {
					// Skip this interface - it doesn't have the method...
				}
				if (annotation != null) {
					break;
				}
160
			}
161 162 163 164 165 166 167 168 169
		}
		return annotation;
	}

	private static boolean isInterfaceWithAnnotatedMethods(Class<?> iface) {
		synchronized (annotatedInterfaceCache) {
			Boolean flag = annotatedInterfaceCache.get(iface);
			if (flag != null) {
				return flag;
170
			}
171 172 173 174 175 176
			boolean found = false;
			for (Method ifcMethod : iface.getMethods()) {
				if (ifcMethod.getAnnotations().length > 0) {
					found = true;
					break;
				}
177
			}
178 179
			annotatedInterfaceCache.put(iface, found);
			return found;
180 181 182
		}
	}

A
Arjen Poutsma 已提交
183
	/**
J
Juergen Hoeller 已提交
184
	 * Find a single {@link Annotation} of <code>annotationType</code> from the supplied {@link Class},
185
	 * traversing its interfaces and superclasses if no annotation can be found on the given class itself.
J
Juergen Hoeller 已提交
186
	 * <p>This method explicitly handles class-level annotations which are not declared as
187
	 * {@link java.lang.annotation.Inherited inherited} <i>as well as annotations on interfaces</i>.
J
Juergen Hoeller 已提交
188 189 190 191 192 193
	 * <p>The algorithm operates as follows: Searches for an annotation on the given class and returns
	 * it if found. Else searches all interfaces that the given class declares, returning the annotation
	 * from the first matching candidate, if any. Else proceeds with introspection of the superclass
	 * of the given class, checking the superclass itself; if no annotation found there, proceeds
	 * with the interfaces that the superclass declares. Recursing up through the entire superclass
	 * hierarchy if no match is found.
A
Arjen Poutsma 已提交
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
	 * @param clazz the class to look for annotations on
	 * @param annotationType the annotation class to look for
	 * @return the annotation found, or <code>null</code> if none found
	 */
	public static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType) {
		Assert.notNull(clazz, "Class must not be null");
		A annotation = clazz.getAnnotation(annotationType);
		if (annotation != null) {
			return annotation;
		}
		for (Class<?> ifc : clazz.getInterfaces()) {
			annotation = findAnnotation(ifc, annotationType);
			if (annotation != null) {
				return annotation;
			}
		}
210 211 212 213 214 215 216 217
		if (!Annotation.class.isAssignableFrom(clazz)) {
			for (Annotation ann : clazz.getAnnotations()) {
				annotation = findAnnotation(ann.annotationType(), annotationType);
				if (annotation != null) {
					return annotation;
				}
			}
		}
218
		Class<?> superClass = clazz.getSuperclass();
219
		if (superClass == null || superClass == Object.class) {
A
Arjen Poutsma 已提交
220 221 222 223 224 225
			return null;
		}
		return findAnnotation(superClass, annotationType);
	}

	/**
J
Juergen Hoeller 已提交
226 227 228 229 230 231 232 233 234
	 * Find the first {@link Class} in the inheritance hierarchy of the specified <code>clazz</code>
	 * (including the specified <code>clazz</code> itself) which declares an annotation for the
	 * specified <code>annotationType</code>, or <code>null</code> if not found. If the supplied
	 * <code>clazz</code> is <code>null</code>, <code>null</code> will be returned.
	 * <p>If the supplied <code>clazz</code> is an interface, only the interface itself will be checked;
	 * the inheritance hierarchy for interfaces will not be traversed.
	 * <p>The standard {@link Class} API does not provide a mechanism for determining which class
	 * in an inheritance hierarchy actually declares an {@link Annotation}, so we need to handle
	 * this explicitly.
A
Arjen Poutsma 已提交
235
	 * @param annotationType the Class object corresponding to the annotation type
J
Juergen Hoeller 已提交
236 237 238 239 240
	 * @param clazz the Class object corresponding to the class on which to check for the annotation,
	 * or <code>null</code>
	 * @return the first {@link Class} in the inheritance hierarchy of the specified <code>clazz</code>
	 * which declares an annotation for the specified <code>annotationType</code>, or <code>null</code>
	 * if not found
A
Arjen Poutsma 已提交
241 242 243 244 245 246 247 248
	 * @see Class#isAnnotationPresent(Class)
	 * @see Class#getDeclaredAnnotations()
	 */
	public static Class<?> findAnnotationDeclaringClass(Class<? extends Annotation> annotationType, Class<?> clazz) {
		Assert.notNull(annotationType, "Annotation type must not be null");
		if (clazz == null || clazz.equals(Object.class)) {
			return null;
		}
J
Juergen Hoeller 已提交
249 250
		return (isAnnotationDeclaredLocally(annotationType, clazz)) ? clazz :
				findAnnotationDeclaringClass(annotationType, clazz.getSuperclass());
A
Arjen Poutsma 已提交
251 252 253
	}

	/**
J
Juergen Hoeller 已提交
254 255 256 257 258 259
	 * Determine whether an annotation for the specified <code>annotationType</code> is
	 * declared locally on the supplied <code>clazz</code>. The supplied {@link Class}
	 * may represent any type.
	 * <p>Note: This method does <strong>not</strong> determine if the annotation is
	 * {@link java.lang.annotation.Inherited inherited}. For greater clarity regarding inherited
	 * annotations, consider using {@link #isAnnotationInherited(Class, Class)} instead.
A
Arjen Poutsma 已提交
260
	 * @param annotationType the Class object corresponding to the annotation type
J
Juergen Hoeller 已提交
261 262 263
	 * @param clazz the Class object corresponding to the class on which to check for the annotation
	 * @return <code>true</code> if an annotation for the specified <code>annotationType</code>
	 * is declared locally on the supplied <code>clazz</code>
A
Arjen Poutsma 已提交
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
	 * @see Class#getDeclaredAnnotations()
	 * @see #isAnnotationInherited(Class, Class)
	 */
	public static boolean isAnnotationDeclaredLocally(Class<? extends Annotation> annotationType, Class<?> clazz) {
		Assert.notNull(annotationType, "Annotation type must not be null");
		Assert.notNull(clazz, "Class must not be null");
		boolean declaredLocally = false;
		for (Annotation annotation : Arrays.asList(clazz.getDeclaredAnnotations())) {
			if (annotation.annotationType().equals(annotationType)) {
				declaredLocally = true;
				break;
			}
		}
		return declaredLocally;
	}

	/**
J
Juergen Hoeller 已提交
281 282 283 284 285 286 287
	 * Determine whether an annotation for the specified <code>annotationType</code> is present
	 * on the supplied <code>clazz</code> and is {@link java.lang.annotation.Inherited inherited}
	 * i.e., not declared locally for the class).
	 * <p>If the supplied <code>clazz</code> is an interface, only the interface itself will be checked.
	 * In accordance with standard meta-annotation semantics, the inheritance hierarchy for interfaces
	 * will not be traversed. See the {@link java.lang.annotation.Inherited JavaDoc} for the
	 * &#064;Inherited meta-annotation for further details regarding annotation inheritance.
A
Arjen Poutsma 已提交
288
	 * @param annotationType the Class object corresponding to the annotation type
J
Juergen Hoeller 已提交
289 290 291
	 * @param clazz the Class object corresponding to the class on which to check for the annotation
	 * @return <code>true</code> if an annotation for the specified <code>annotationType</code> is present
	 * on the supplied <code>clazz</code> and is {@link java.lang.annotation.Inherited inherited}
A
Arjen Poutsma 已提交
292 293 294 295 296 297 298 299 300 301
	 * @see Class#isAnnotationPresent(Class)
	 * @see #isAnnotationDeclaredLocally(Class, Class)
	 */
	public static boolean isAnnotationInherited(Class<? extends Annotation> annotationType, Class<?> clazz) {
		Assert.notNull(annotationType, "Annotation type must not be null");
		Assert.notNull(clazz, "Class must not be null");
		return (clazz.isAnnotationPresent(annotationType) && !isAnnotationDeclaredLocally(annotationType, clazz));
	}

	/**
302 303 304 305 306
	 * Retrieve the given annotation's attributes as a Map, preserving all attribute types
	 * as-is.
	 * <p>Note: As of Spring 3.1.1, the returned map is actually an
	 * {@link AnnotationAttributes} instance, however the Map signature of this method has
	 * been preserved for binary compatibility.
A
Arjen Poutsma 已提交
307
	 * @param annotation the annotation to retrieve the attributes for
J
Juergen Hoeller 已提交
308 309
	 * @return the Map of annotation attributes, with attribute names as keys and
	 * corresponding attribute values as values
A
Arjen Poutsma 已提交
310 311
	 */
	public static Map<String, Object> getAnnotationAttributes(Annotation annotation) {
312
		return getAnnotationAttributes(annotation, false, false);
313 314 315
	}

	/**
316 317 318 319 320 321
	 * Retrieve the given annotation's attributes as a Map. Equivalent to calling
	 * {@link #getAnnotationAttributes(Annotation, boolean, boolean)} with
	 * the {@code nestedAnnotationsAsMap} parameter set to {@code false}.
	 * <p>Note: As of Spring 3.1.1, the returned map is actually an
	 * {@link AnnotationAttributes} instance, however the Map signature of this method has
	 * been preserved for binary compatibility.
322
	 * @param annotation the annotation to retrieve the attributes for
323 324 325
	 * @param classValuesAsString whether to turn Class references into Strings (for
	 * compatibility with {@link org.springframework.core.type.AnnotationMetadata} or to
	 * preserve them as Class references
J
Juergen Hoeller 已提交
326 327
	 * @return the Map of annotation attributes, with attribute names as keys and
	 * corresponding attribute values as values
328
	 */
329
	public static Map<String, Object> getAnnotationAttributes(Annotation annotation, boolean classValuesAsString) {
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
		return getAnnotationAttributes(annotation, classValuesAsString, false);
	}

	/**
	 * Retrieve the given annotation's attributes as an {@link AnnotationAttributes}
	 * map structure. Implemented in Spring 3.1.1 to provide fully recursive annotation
	 * reading capabilities on par with that of the reflection-based
	 * {@link org.springframework.core.type.StandardAnnotationMetadata}.
	 * @param annotation the annotation to retrieve the attributes for
	 * @param classValuesAsString whether to turn Class references into Strings (for
	 * compatibility with {@link org.springframework.core.type.AnnotationMetadata} or to
	 * preserve them as Class references
	 * @param nestedAnnotationsAsMap whether to turn nested Annotation instances into
	 * {@link AnnotationAttributes} maps (for compatibility with
	 * {@link org.springframework.core.type.AnnotationMetadata} or to preserve them as
	 * Annotation instances
	 * @return the annotation attributes (a specialized Map) with attribute names as keys
	 * and corresponding attribute values as values
	 * @since 3.1.1
	 */
	public static AnnotationAttributes getAnnotationAttributes(
			Annotation annotation, boolean classValuesAsString, boolean nestedAnnotationsAsMap) {

		AnnotationAttributes attrs = new AnnotationAttributes();
A
Arjen Poutsma 已提交
354
		Method[] methods = annotation.annotationType().getDeclaredMethods();
355
		for (Method method : methods) {
A
Arjen Poutsma 已提交
356 357
			if (method.getParameterTypes().length == 0 && method.getReturnType() != void.class) {
				try {
358
					Object value = method.invoke(annotation);
359
					if (classValuesAsString) {
360
						if (value instanceof Class) {
361
							value = ((Class<?>) value).getName();
362 363
						}
						else if (value instanceof Class[]) {
364
							Class<?>[] clazzArray = (Class[]) value;
365 366 367 368 369 370 371
							String[] newValue = new String[clazzArray.length];
							for (int i = 0; i < clazzArray.length; i++) {
								newValue[i] = clazzArray[i].getName();
							}
							value = newValue;
						}
					}
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
					if (nestedAnnotationsAsMap && value instanceof Annotation) {
						attrs.put(method.getName(), getAnnotationAttributes(
								(Annotation)value, classValuesAsString, nestedAnnotationsAsMap));
					}
					else if (nestedAnnotationsAsMap && value instanceof Annotation[]) {
						Annotation[] realAnnotations = (Annotation[])value;
						AnnotationAttributes[] mappedAnnotations = new AnnotationAttributes[realAnnotations.length];
						for (int i = 0; i < realAnnotations.length; i++) {
							mappedAnnotations[i] = getAnnotationAttributes(
									realAnnotations[i], classValuesAsString, nestedAnnotationsAsMap);
						}
						attrs.put(method.getName(), mappedAnnotations);
					}
					else {
						attrs.put(method.getName(), value);
					}
A
Arjen Poutsma 已提交
388 389 390 391 392 393 394 395 396 397
				}
				catch (Exception ex) {
					throw new IllegalStateException("Could not obtain annotation attribute values", ex);
				}
			}
		}
		return attrs;
	}

	/**
J
Juergen Hoeller 已提交
398 399
	 * Retrieve the <em>value</em> of the <code>&quot;value&quot;</code> attribute of a
	 * single-element Annotation, given an annotation instance.
A
Arjen Poutsma 已提交
400 401 402 403 404 405 406 407 408
	 * @param annotation the annotation instance from which to retrieve the value
	 * @return the attribute value, or <code>null</code> if not found
	 * @see #getValue(Annotation, String)
	 */
	public static Object getValue(Annotation annotation) {
		return getValue(annotation, VALUE);
	}

	/**
J
Juergen Hoeller 已提交
409
	 * Retrieve the <em>value</em> of a named Annotation attribute, given an annotation instance.
A
Arjen Poutsma 已提交
410 411 412
	 * @param annotation the annotation instance from which to retrieve the value
	 * @param attributeName the name of the attribute value to retrieve
	 * @return the attribute value, or <code>null</code> if not found
J
Juergen Hoeller 已提交
413
	 * @see #getValue(Annotation)
A
Arjen Poutsma 已提交
414 415 416 417 418 419 420 421 422 423 424 425
	 */
	public static Object getValue(Annotation annotation, String attributeName) {
		try {
			Method method = annotation.annotationType().getDeclaredMethod(attributeName, new Class[0]);
			return method.invoke(annotation);
		}
		catch (Exception ex) {
			return null;
		}
	}

	/**
J
Juergen Hoeller 已提交
426 427 428
	 * Retrieve the <em>default value</em> of the <code>&quot;value&quot;</code> attribute
	 * of a single-element Annotation, given an annotation instance.
	 * @param annotation the annotation instance from which to retrieve the default value
A
Arjen Poutsma 已提交
429 430 431 432 433 434 435 436
	 * @return the default value, or <code>null</code> if not found
	 * @see #getDefaultValue(Annotation, String)
	 */
	public static Object getDefaultValue(Annotation annotation) {
		return getDefaultValue(annotation, VALUE);
	}

	/**
J
Juergen Hoeller 已提交
437 438
	 * Retrieve the <em>default value</em> of a named Annotation attribute, given an annotation instance.
	 * @param annotation the annotation instance from which to retrieve the default value
A
Arjen Poutsma 已提交
439
	 * @param attributeName the name of the attribute value to retrieve
440
	 * @return the default value of the named attribute, or <code>null</code> if not found
A
Arjen Poutsma 已提交
441 442 443 444 445 446 447
	 * @see #getDefaultValue(Class, String)
	 */
	public static Object getDefaultValue(Annotation annotation, String attributeName) {
		return getDefaultValue(annotation.annotationType(), attributeName);
	}

	/**
J
Juergen Hoeller 已提交
448 449 450
	 * Retrieve the <em>default value</em> of the <code>&quot;value&quot;</code> attribute
	 * of a single-element Annotation, given the {@link Class annotation type}.
	 * @param annotationType the <em>annotation type</em> for which the default value should be retrieved
A
Arjen Poutsma 已提交
451 452 453 454 455 456 457 458
	 * @return the default value, or <code>null</code> if not found
	 * @see #getDefaultValue(Class, String)
	 */
	public static Object getDefaultValue(Class<? extends Annotation> annotationType) {
		return getDefaultValue(annotationType, VALUE);
	}

	/**
J
Juergen Hoeller 已提交
459 460
	 * Retrieve the <em>default value</em> of a named Annotation attribute, given the {@link Class annotation type}.
	 * @param annotationType the <em>annotation type</em> for which the default value should be retrieved
A
Arjen Poutsma 已提交
461
	 * @param attributeName the name of the attribute value to retrieve.
J
Juergen Hoeller 已提交
462
	 * @return the default value of the named attribute, or <code>null</code> if not found
A
Arjen Poutsma 已提交
463 464 465 466 467 468 469 470 471 472 473 474 475
	 * @see #getDefaultValue(Annotation, String)
	 */
	public static Object getDefaultValue(Class<? extends Annotation> annotationType, String attributeName) {
		try {
			Method method = annotationType.getDeclaredMethod(attributeName, new Class[0]);
			return method.getDefaultValue();
		}
		catch (Exception ex) {
			return null;
		}
	}

}