Java Doc for ClassTransformation.java in  » Library » Tapestry » org » apache » tapestry » services » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Tapestry » org.apache.tapestry.services 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.tapestry.services.ClassTransformation

ClassTransformation
public interface ClassTransformation extends AnnotationProvider(Code)
Contains class-specific information used when transforming an raw class into an executable class. Much of this information is somewhat like ordinary reflection, but applies to a class that has not yet been loaded.

Transformation is primarily about identifying annotations on fields and on methods and changing the class, adding new interfaces, fields and methods, and deleting some existing fields.

A ClassTransformation contains all the state data specific to a particular class being transformed. A number of workers will operate upon the ClassTransformation to effect the desired changes before the true class is loaded into memory.

Instances of this class are not designed to be thread safe, access to an instance should be restricted to a single thread. In fact, the design of this type is to allow stateless singletons in multiple threads to work on thread-specific data (within the ClassTransformation). *

The majority of methods concern the declared members (field and methods) of a specific class, rather than any fields or methods inherited from a base class.





Method Summary
 StringaddField(int modifiers, String type, String suggestedName)
     Defines a new declared field for the class.
 voidaddImplementedInterface(Class interfaceClass)
     Transforms the class to implement the indicated interface.
 StringaddInjectedField(Class type, String suggestedName, Object value)
     Defines a new protected instance variable whose initial value is provided statically, via a constructor parameter.
 voidaddMethod(MethodSignature signature, String methodBody)
     Adds a new method to the transformed class.
 voidclaimField(String fieldName, Object tag)
     Claims a field so as to ensure that only a single annotation is applied to any single field.
 voidextendConstructor(String statement)
     Adds a statement to the constructor.
 voidextendMethod(MethodSignature methodSignature, String methodBody)
     Extends an existing method.
 List<String>findFields(FieldFilter filter)
     Finds all unclaimed fields matched by the provided filter.
 List<String>findFieldsOfType(String type)
     Generates a list of the names of declared instance fields that exactly match the specified type.
 List<String>findFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
     Generates a list of the names of declared instance fields that have the indicated annotation. Non-private and static fields are ignored.
 List<MethodSignature>findMethods(MethodFilter filter)
     Finds all methods matched by the provided filter.
 List<MethodSignature>findMethodsWithAnnotation(Class<? extends Annotation> annotationClass)
     Finds all methods defined in the class that are marked with the provided annotation.
 List<String>findUnclaimedFields()
     Finds any declared instance fields that have not been claimed (via ClassTransformation.claimField(String,Object) ) and returns the names of those fields.
 StringgetClassName()
     Returns the fully qualified class name of the class being transformed.
 TgetFieldAnnotation(String fieldName, Class<T> annotationClass)
     Finds an annotation on a declared instance field.
 intgetFieldModifiers(String fieldName)
     Returns the modifiers for the named field.
 StringgetFieldType(String fieldName)
     Obtains the type of a declared instance field.
 LoggetLog()
     Returns a log, based on the class name being transformed, to which warnings or errors concerning the class being transformed may be logged.
 TgetMethodAnnotation(MethodSignature method, Class<T> annotationClass)
     Finds an annotation on a declared method.
 StringgetMethodIdentifier(MethodSignature signature)
     Converts a signature to a string used to identify the method; this consists of the MethodSignature.getMediumDescription appended with source file information and line number information (when available).
 StringgetResourcesFieldName()
     Returns the name of a field that provides the org.apache.tapestry.ComponentResources for the transformed component.
 voidinjectField(String fieldName, Object value)
     Converts the field into a read only field whose value is the provided value.
 booleanisField(String fieldName)
     Returns true if the indicated name is a private instance field.
 voidmakeReadOnly(String fieldName)
     Changes the field to be read only.
 StringnewMemberName(String suggested)
     Returns the name of a new member (field or method).
 StringnewMemberName(String prefix, String baseName)
     As with ClassTransformation.newMemberName(String) , but the suggested name is constructed from the prefix and base name.
 voidremoveField(String fieldName)
     Removes a field entirely; this is useful for fields that are replaced entirely by computed values.
 voidreplaceReadAccess(String fieldName, String methodName)
     Replaces all read-references to the specified field with invocations of the specified method name.
 voidreplaceWriteAccess(String fieldName, String methodName)
     Replaces all write accesses to the specified field with invocations of the specified method name.
 ClasstoClass(String type)
     Converts a type name into a corresponding class (possibly, a transformed class).



Method Detail
addField
String addField(int modifiers, String type, String suggestedName)(Code)
Defines a new declared field for the class. The suggestedName may be modified to ensure uniqueness.
Parameters:
  modifiers - modifiers for the field (typically, java.lang.reflect.Modifier.PRIVATE)
Parameters:
  type - the type for the field, as a string
Parameters:
  suggestedName - the desired name for the field, which may be modified (for uniqueness) whenreturned the (uniqued) name for the field



addImplementedInterface
void addImplementedInterface(Class interfaceClass)(Code)
Transforms the class to implement the indicated interface. If the class (or its super class) does not already implement the interface, then the interface is added, and default implementations of any methods of the interface are added.

TODO: Checking that the names of methods in the interface do not conflict with the names of methods present in the (unmodified) class.
Parameters:
  interfaceClass - the interface to be implemented by the class
throws:
  IllegalArgumentException - if the interfaceClass argument does not represent an interface




addInjectedField
String addInjectedField(Class type, String suggestedName, Object value)(Code)
Defines a new protected instance variable whose initial value is provided statically, via a constructor parameter. The transformation caches the result, so calling this method repeatedly with the same type and value will return the same field name. Caching extends to the parent transformation, so that a value injected into a parent class will be available (via the protected instance variable) to subclasses.
Parameters:
  type - the type of object to inject
Parameters:
  suggestedName - the suggested name for the new field
Parameters:
  value - to be injected. This value is retained. the actual name of the injected field



addMethod
void addMethod(MethodSignature signature, String methodBody)(Code)
Adds a new method to the transformed class. Replaces any existing method declared for the class. When overriding a super-class method, you should use ClassTransformation.extendMethod(MethodSignature,String) , or you should remember to invoke the super class implemetation explicitly. Use this method to control when the super-class implementation is invoked.



claimField
void claimField(String fieldName, Object tag)(Code)
Claims a field so as to ensure that only a single annotation is applied to any single field. When a transformation occurs (driven by a field annotation), the first thing that occurs is to claim the field, on behalf of the annotation.
Parameters:
  fieldName - the name of the field that is being claimed
Parameters:
  tag - a non-null object that represents why the field is being tagged (this is typicallya specific annotation on the field)
throws:
  IllegalArgumentException - if the fieldName does not correspond to a declared instance field
throws:
  IllegalStateException - if the field is already claimed for some other tag



extendConstructor
void extendConstructor(String statement)(Code)
Adds a statement to the constructor. The statement is added as is, though a newline is added.
Parameters:
  statement - the statement to add, which should end with a semicolon



extendMethod
void extendMethod(MethodSignature methodSignature, String methodBody)(Code)
Extends an existing method. The provided method body is inserted at the end of the existing method (i.e. javassist.CtBehavior.insertAfter(java.lang.String) ). To access or change the return value, use the $_ pseudo variable.

The method may be declared in the class, or may be inherited from a super-class. For inherited methods, a method is added that first invokes the super implementation. Use ClassTransformation.addMethod(MethodSignature,String) when it is necessary to control when the super-class method is invoked.
Parameters:
  signature - the signature of the method to extend
Parameters:
  methodBody - the body of code
throws:
  IllegalArgumentException - if the provided Javassist method body can not be compiled




findFields
List<String> findFields(FieldFilter filter)(Code)
Finds all unclaimed fields matched by the provided filter. Only considers unclaimed, private, instance fields.
Parameters:
  filter - passed each field name and field type the names of all matched fields, in ascending order



findFieldsOfType
List<String> findFieldsOfType(String type)(Code)
Generates a list of the names of declared instance fields that exactly match the specified type. Only the names of private instance fields are returned. Any ClassTransformation.claimField(String,Object) claimed fields are excluded.



findFieldsWithAnnotation
List<String> findFieldsWithAnnotation(Class<? extends Annotation> annotationClass)(Code)
Generates a list of the names of declared instance fields that have the indicated annotation. Non-private and static fields are ignored. Only the names of private instance fields are returned. Any ClassTransformation.claimField(String,Object) claimed fields are excluded.



findMethods
List<MethodSignature> findMethods(MethodFilter filter)(Code)
Finds all methods matched by the provided filter.
Parameters:
  filter - Passed each method signature, it may include or exclude each potential a list of matching method signatures (which may be empty) in ascending order



findMethodsWithAnnotation
List<MethodSignature> findMethodsWithAnnotation(Class<? extends Annotation> annotationClass)(Code)
Finds all methods defined in the class that are marked with the provided annotation.
Parameters:
  annotationClass - a list of method signature (which may be empty) in ascending order



findUnclaimedFields
List<String> findUnclaimedFields()(Code)
Finds any declared instance fields that have not been claimed (via ClassTransformation.claimField(String,Object) ) and returns the names of those fields. May return an empty array.



getClassName
String getClassName()(Code)
Returns the fully qualified class name of the class being transformed.



getFieldAnnotation
T getFieldAnnotation(String fieldName, Class<T> annotationClass)(Code)
Finds an annotation on a declared instance field. <
Parameters:
  T - >constrains parameter and return value to Annotation types
Parameters:
  fieldName - the name of the field, which must exist
Parameters:
  annotationClass - the type of annotation to access the annotation if present, or null otherwise
throws:
  IllegalArgumentException - if the fieldName does not correspond to a declared field



getFieldModifiers
int getFieldModifiers(String fieldName)(Code)
Returns the modifiers for the named field.



getFieldType
String getFieldType(String fieldName)(Code)
Obtains the type of a declared instance field.
Parameters:
  fieldName - the type of the field, as a string
throws:
  IllegalArgumentException - if the fieldName does not correspond to a declared instance field



getLog
Log getLog()(Code)
Returns a log, based on the class name being transformed, to which warnings or errors concerning the class being transformed may be logged.



getMethodAnnotation
T getMethodAnnotation(MethodSignature method, Class<T> annotationClass)(Code)
Finds an annotation on a declared method. <
Parameters:
  T - >constrains parameter and return value to Annotation types
Parameters:
  method - the method signature to search
Parameters:
  annotationClass - the type of annotation to access the annotation if present, or null otherwise
throws:
  IllegalArgumentException - if the method signature does not correspond to a declared method



getMethodIdentifier
String getMethodIdentifier(MethodSignature signature)(Code)
Converts a signature to a string used to identify the method; this consists of the MethodSignature.getMediumDescription appended with source file information and line number information (when available).
Parameters:
  signature - a string that identifies the class, method name, types of parameters, source file andsource line number



getResourcesFieldName
String getResourcesFieldName()(Code)
Returns the name of a field that provides the org.apache.tapestry.ComponentResources for the transformed component. This will be a protected field, accessible to the class and subclasses. name of field



injectField
void injectField(String fieldName, Object value)(Code)
Converts the field into a read only field whose value is the provided value. This is used when converting an existing field into a read-only injected value.
Parameters:
  fieldName - name of field to convert
Parameters:
  value - the value provided by the field



isField
boolean isField(String fieldName)(Code)
Returns true if the indicated name is a private instance field.
Parameters:
  fieldName - true if field exists



makeReadOnly
void makeReadOnly(String fieldName)(Code)
Changes the field to be read only. Any existing code that changes the field will cause a runtime exception.
Parameters:
  fieldName - name of field to so change



newMemberName
String newMemberName(String suggested)(Code)
Returns the name of a new member (field or method). Ensures that the resulting name does not conflict with any existing member (declared by the underlying class, or inherited from a base class).
Parameters:
  suggested - the suggested value for the member a unique name for the member



newMemberName
String newMemberName(String prefix, String baseName)(Code)
As with ClassTransformation.newMemberName(String) , but the suggested name is constructed from the prefix and base name. An underscore will seperate the prefix from the base name.
Parameters:
  prefix - for the generated name
Parameters:
  baseName - an name, often of an existing field or method a unique name



removeField
void removeField(String fieldName)(Code)
Removes a field entirely; this is useful for fields that are replaced entirely by computed values.
Parameters:
  fieldName - the name of the field to remove
See Also:   ClassTransformation.replaceReadAccess(String,String)
See Also:   ClassTransformation.replaceWriteAccess(String,String)



replaceReadAccess
void replaceReadAccess(String fieldName, String methodName)(Code)
Replaces all read-references to the specified field with invocations of the specified method name. Replacements do not occur in methods added via ClassTransformation.addMethod(MethodSignature,String) or ClassTransformation.extendMethod(MethodSignature,String) .



replaceWriteAccess
void replaceWriteAccess(String fieldName, String methodName)(Code)
Replaces all write accesses to the specified field with invocations of the specified method name. The method should take a single parameter of the same type as the field. Replacements do not occur in methods added via ClassTransformation.addMethod(MethodSignature,String) or ClassTransformation.extendMethod(MethodSignature,String) .



toClass
Class toClass(String type)(Code)
Converts a type name into a corresponding class (possibly, a transformed class). Primitive type names are returned as wrapper types.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.