01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.metadata.commons;
18:
19: import java.lang.reflect.Field;
20: import java.lang.reflect.Method;
21: import java.util.Collection;
22:
23: import org.springframework.metadata.Attributes;
24:
25: /**
26: * Implementation of the Spring Attributes facade for Commons Attributes.
27: *
28: * <p>Please see the
29: * <a href="http://jakarta.apache.org/commons/sandbox/attributes">
30: * Commons Attributes documentation</a> for information on how to use the
31: * attribute compiler.
32: *
33: * <p>As of December 2003, follow the Javadocs to the AttributeCompiler class
34: * to see how the Ant task works. Note that you need to put the following jars
35: * in your $ANT_HOME/lib directory for the Common Attributes compiler to work:
36: * <ul>
37: * <li>Commons Attributes compiler jar
38: * <li>the xjavadoc Jar (from XDoclet)
39: * <li>commons-collection.jar (from Jakarta Commons)
40: * </ul>
41: *
42: * <p>You need to perform the attribute compilation step before compiling your source.
43: *
44: * <p>See build.xml in the tests for package org.springframework.aop.autoproxy.metadata
45: * for an example of the required Ant scripting. The header of this build script
46: * includes some quick, and hopefully useful, hints on using Commons Attributes.
47: * The source files in the same package (TxClass and TxClassWithClassAttribute)
48: * illustrate attribute usage in source files.
49: *
50: * <p>The Spring Framework project does not provide support usage of specific
51: * attributes implementations. Please refer to the appropriate site and mailing
52: * list of the attributes implementation.
53: *
54: * @author Rod Johnson
55: */
56: public class CommonsAttributes implements Attributes {
57:
58: /*
59: * Commons Attributes caches attributes, so we don't need to cache here
60: * as well.
61: */
62:
63: public Collection getAttributes(Class targetClass) {
64: return org.apache.commons.attributes.Attributes
65: .getAttributes(targetClass);
66: }
67:
68: public Collection getAttributes(Class targetClass, Class filter) {
69: return org.apache.commons.attributes.Attributes.getAttributes(
70: targetClass, filter);
71: }
72:
73: public Collection getAttributes(Method targetMethod) {
74: return org.apache.commons.attributes.Attributes
75: .getAttributes(targetMethod);
76: }
77:
78: public Collection getAttributes(Method targetMethod, Class filter) {
79: return org.apache.commons.attributes.Attributes.getAttributes(
80: targetMethod, filter);
81: }
82:
83: public Collection getAttributes(Field targetField) {
84: return org.apache.commons.attributes.Attributes
85: .getAttributes(targetField);
86: }
87:
88: public Collection getAttributes(Field targetField, Class filter) {
89: return org.apache.commons.attributes.Attributes.getAttributes(
90: targetField, filter);
91: }
92:
93: }
|