|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
EnhancementOperation.java | - | - | - | - |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.enhance;
|
|
16 |
|
|
17 |
import java.util.List;
|
|
18 |
|
|
19 |
import org.apache.hivemind.service.MethodSignature;
|
|
20 |
|
|
21 |
/**
|
|
22 |
* A process object representing enhancements to a component class. The operation is passed to
|
|
23 |
* {@link org.apache.tapestry.enhance.EnhancementWorker}objects that perform enhancements.
|
|
24 |
*
|
|
25 |
* @author Howard M. Lewis Ship
|
|
26 |
* @since 4.0
|
|
27 |
*/
|
|
28 |
public interface EnhancementOperation |
|
29 |
{ |
|
30 |
/**
|
|
31 |
* Claims a property. Most enhancements are concerned with adding properties. Some enhancement
|
|
32 |
* workers exist to fill in defaults, and they need to know what properties have already been
|
|
33 |
* spoken for by eariler enhancement works.
|
|
34 |
*
|
|
35 |
* @throws org.apache.hivemind.ApplicationRuntimeException
|
|
36 |
* if the property was previously claimed
|
|
37 |
*/
|
|
38 |
|
|
39 |
public void claimProperty(String propertyName); |
|
40 |
|
|
41 |
/**
|
|
42 |
* Returns a list of the names of existing properties that are not claimed and which have
|
|
43 |
* abstract accessor methods.
|
|
44 |
*/
|
|
45 |
|
|
46 |
public List findUnclaimedAbstractProperties();
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Adds a field to the enhanced class; the field will be private and use the provided name and
|
|
50 |
* type.
|
|
51 |
*/
|
|
52 |
|
|
53 |
public void addField(String name, Class type); |
|
54 |
|
|
55 |
/**
|
|
56 |
* Adds a field containing an initial value, which is injected into the class via its fabricated
|
|
57 |
* constructor. This method may be called multiple times with the same value and will return the
|
|
58 |
* same variable name (an identity map is kept internally).
|
|
59 |
*
|
|
60 |
* @param fieldName
|
|
61 |
* The default name for the field, used if a new field (and contructor argument) is
|
|
62 |
* being created. Only used if a field for the value doesn't exist.
|
|
63 |
* @param value
|
|
64 |
* the value to be referenced, which may not be null
|
|
65 |
* @return the name of the field containing the value. This may or may not match fieldName. The
|
|
66 |
* provided fieldName may be modified to prevent naming conflicts.
|
|
67 |
*/
|
|
68 |
|
|
69 |
public String addInjectedField(String fieldName, Object value);
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Converts a type name (an object class name, a primtive name, or an array) into the
|
|
73 |
* corresponding Class object.
|
|
74 |
*/
|
|
75 |
|
|
76 |
public Class convertTypeName(String type);
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Confirms that the named property either doesn't exist (in the component base class), or that
|
|
80 |
* the type of the property exactly matches the indicated type.
|
|
81 |
*/
|
|
82 |
|
|
83 |
public void validateProperty(String name, Class expectedType); |
|
84 |
|
|
85 |
/**
|
|
86 |
* Returns the name of the accessor method for the given property (if it exists in the component
|
|
87 |
* base class), or fabricates a new name if it does not.
|
|
88 |
*/
|
|
89 |
|
|
90 |
public String getAccessorMethodName(String propertyName);
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Adds a method to the enhanced class.
|
|
94 |
*
|
|
95 |
* @param modifier
|
|
96 |
* as defined by {@link java.lang.reflect.Modifier}, typically
|
|
97 |
* {@link java.lang.reflect.Modifier#PUBLIC}
|
|
98 |
* @param sig
|
|
99 |
* the method signature (defining name, return type, etc.)
|
|
100 |
* @param methodBody
|
|
101 |
* a Javassist code snippet for the method body
|
|
102 |
*/
|
|
103 |
public void addMethod(int modifier, MethodSignature sig, String methodBody); |
|
104 |
|
|
105 |
/**
|
|
106 |
* Returns the base component class, as defined in the specification (or defaulted). An enhaced
|
|
107 |
* subclass of the component class will usually be created.
|
|
108 |
*/
|
|
109 |
public Class getBaseClass();
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Returns a reference to a particular class. This will, effectively, by the name of a private
|
|
113 |
* field.
|
|
114 |
*/
|
|
115 |
|
|
116 |
public String getClassReference(Class clazz);
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Returns the type of an existing property of the base component class. If the property does
|
|
120 |
* not exist, then returns null.
|
|
121 |
*/
|
|
122 |
|
|
123 |
public Class getPropertyType(String name);
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Allows for a kind of distributed construction of a particular method, within a particular
|
|
127 |
* interface. Code can be appended to the method's implementation throughout the course of the
|
|
128 |
* enhancement operation. When the enhanced class is finialized, the method is added with
|
|
129 |
* whatever contents are in its body. If the base class implements the method, then the method
|
|
130 |
* body will include an initial call to that implementation.
|
|
131 |
* <p>
|
|
132 |
* At this time, this works best for void methods (since there isn't an easy way to ensure code
|
|
133 |
* would be inserted before a final return statement).
|
|
134 |
*
|
|
135 |
* @param interfaceClass
|
|
136 |
* the interface containing the method. If the base class does not implement the
|
|
137 |
* interface, then the enhanced class will have the interface added.
|
|
138 |
* @param methodSignature
|
|
139 |
* the signature of the method to be added.
|
|
140 |
* @param code
|
|
141 |
* the Javassist markup to be added to the body of the method.
|
|
142 |
*/
|
|
143 |
public void extendMethodImplementation(Class interfaceClass, MethodSignature methodSignature, |
|
144 |
String code); |
|
145 |
|
|
146 |
/**
|
|
147 |
* Returns true if the class implements the specified interface. Checks the base class (as
|
|
148 |
* identified in the specification), but <em>also</em> accounts for any additional interfaces
|
|
149 |
* that may be added by {@link #extendMethodImplementation(Class, MethodSignature, String)}.
|
|
150 |
*/
|
|
151 |
|
|
152 |
public boolean implementsInterface(Class interfaceClass); |
|
153 |
} |
|