Java Doc for Loader.java in  » Byte-Code » Javassist » javassist » tools » reflect » 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 » Byte Code » Javassist » javassist.tools.reflect 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.lang.ClassLoader
      javassist.Loader
         javassist.tools.reflect.Loader

Loader
public class Loader extends javassist.Loader (Code)
A class loader for reflection.

To run a program, say MyApp, including a reflective class, you must write a start-up program as follows:

     public class Main {
     public static void main(String[] args) throws Throwable {
     javassist.tools.reflect.Loader cl
     = (javassist.tools.reflect.Loader)Main.class.getClassLoader();
     cl.makeReflective("Person", "MyMetaobject",
     "javassist.tools.reflect.ClassMetaobject");
     cl.run("MyApp", args);
     }
     }
     

Then run this program as follows:

    % java javassist.tools.reflect.Loader Main arg1, ...

This command runs Main.main() with arg1, ... and Main.main() runs MyApp.main() with arg1, ... The Person class is modified to be a reflective class. Method calls on a Person object are intercepted by an instance of MyMetaobject.

Also, you can run MyApp in a slightly different way:

     public class Main2 {
     public static void main(String[] args) throws Throwable {
     javassist.tools.reflect.Loader cl = new javassist.tools.reflect.Loader();
     cl.makeReflective("Person", "MyMetaobject",
     "javassist.tools.reflect.ClassMetaobject");
     cl.run("MyApp", args);
     }
     }
     

This program is run as follows:

    % java Main2 arg1, ...

The difference from the former one is that the class Main is loaded by javassist.tools.reflect.Loader whereas the class Main2 is not. Thus, Main belongs to the same name space (security domain) as MyApp whereas Main2 does not; Main2 belongs to the same name space as javassist.tools.reflect.Loader. For more details, see the notes in the manual page of javassist.Loader.

The class Main2 is equivalent to this class:

     public class Main3 {
     public static void main(String[] args) throws Throwable {
     Reflection reflection = new Reflection();
     javassist.Loader cl
     = new javassist.Loader(ClassPool.getDefault(reflection));
     reflection.makeReflective("Person", "MyMetaobject",
     "javassist.tools.reflect.ClassMetaobject");
     cl.run("MyApp", args);
     }
     }
     

Note:

javassist.tools.reflect.Loader does not make a class reflective if that class is in a java.* or javax.* pacakge because of the specifications on the class loading algorithm of Java. The JVM does not allow to load such a system class with a user class loader.

To avoid this limitation, those classes should be statically modified with javassist.tools.reflect.Compiler and the original class files should be replaced.
See Also:   javassist.tools.reflect.Reflection
See Also:   javassist.tools.reflect.Compiler
See Also:   javassist.Loader



Field Summary
protected  Reflectionreflection
    

Constructor Summary
public  Loader()
     Constructs a new class loader.

Method Summary
public static  voidmain(String[] args)
     Loads a class with an instance of Loader and calls main() in that class.
public  booleanmakeReflective(String clazz, String metaobject, String metaclass)
     Produces a reflective class. If the super class is also made reflective, it must be done before the sub class.
Parameters:
  clazz - the reflective class.
Parameters:
  metaobject - the class of metaobjects.It must be a subclass ofMetaobject.
Parameters:
  metaclass - the class of the class metaobject.It must be a subclass ofClassMetaobject.

Field Detail
reflection
protected Reflection reflection(Code)




Constructor Detail
Loader
public Loader() throws CannotCompileException, NotFoundException(Code)
Constructs a new class loader.




Method Detail
main
public static void main(String[] args) throws Throwable(Code)
Loads a class with an instance of Loader and calls main() in that class.
Parameters:
  args - command line parameters.
    args[0] is the class name to be loaded.
    args[1..n] are parameters passedto the target main().



makeReflective
public boolean makeReflective(String clazz, String metaobject, String metaclass) throws CannotCompileException, NotFoundException(Code)
Produces a reflective class. If the super class is also made reflective, it must be done before the sub class.
Parameters:
  clazz - the reflective class.
Parameters:
  metaobject - the class of metaobjects.It must be a subclass ofMetaobject.
Parameters:
  metaclass - the class of the class metaobject.It must be a subclass ofClassMetaobject. false if the class is already reflective.
See Also:   javassist.tools.reflect.Metaobject
See Also:   javassist.tools.reflect.ClassMetaobject



Fields inherited from javassist.Loader
public boolean doDelegation(Code)(Java Doc)

Methods inherited from javassist.Loader
public void addTranslator(ClassPool cp, Translator t) throws NotFoundException, CannotCompileException(Code)(Java Doc)
public void delegateLoadingOf(String classname)(Code)(Java Doc)
protected Class delegateToParent(String classname) throws ClassNotFoundException(Code)(Java Doc)
protected Class findClass(String name) throws ClassNotFoundException(Code)(Java Doc)
protected Package getPackage(String name)(Code)(Java Doc)
protected Class loadClass(String name, boolean resolve) throws ClassFormatError, ClassNotFoundException(Code)(Java Doc)
protected Class loadClassByDelegation(String name) throws ClassNotFoundException(Code)(Java Doc)
public static void main(String[] args) throws Throwable(Code)(Java Doc)
public void run(String[] args) throws Throwable(Code)(Java Doc)
public void run(String classname, String[] args) throws Throwable(Code)(Java Doc)
public void setClassPool(ClassPool cp)(Code)(Java Doc)
public void setDomain(ProtectionDomain d)(Code)(Java Doc)

Methods inherited from java.lang.ClassLoader
public synchronized void clearAssertionStatus()(Code)(Java Doc)
final protected Class defineClass(byte[] b, int off, int len) throws ClassFormatError(Code)(Java Doc)
final protected Class defineClass(String name, byte[] b, int off, int len) throws ClassFormatError(Code)(Java Doc)
final protected Class defineClass(String name, byte[] b, int off, int len, ProtectionDomain protectionDomain) throws ClassFormatError(Code)(Java Doc)
final protected Class defineClass(String name, java.nio.ByteBuffer b, ProtectionDomain protectionDomain) throws ClassFormatError(Code)(Java Doc)
protected Package definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) throws IllegalArgumentException(Code)(Java Doc)
protected Class findClass(String name) throws ClassNotFoundException(Code)(Java Doc)
protected String findLibrary(String libname)(Code)(Java Doc)
final protected Class findLoadedClass(String name)(Code)(Java Doc)
protected URL findResource(String name)(Code)(Java Doc)
protected Enumeration<URL> findResources(String name) throws IOException(Code)(Java Doc)
final protected Class findSystemClass(String name) throws ClassNotFoundException(Code)(Java Doc)
protected Package getPackage(String name)(Code)(Java Doc)
protected Package[] getPackages()(Code)(Java Doc)
final public ClassLoader getParent()(Code)(Java Doc)
public URL getResource(String name)(Code)(Java Doc)
public InputStream getResourceAsStream(String name)(Code)(Java Doc)
public Enumeration<URL> getResources(String name) throws IOException(Code)(Java Doc)
public static ClassLoader getSystemClassLoader()(Code)(Java Doc)
public static URL getSystemResource(String name)(Code)(Java Doc)
public static InputStream getSystemResourceAsStream(String name)(Code)(Java Doc)
public static Enumeration<URL> getSystemResources(String name) throws IOException(Code)(Java Doc)
public Class loadClass(String name) throws ClassNotFoundException(Code)(Java Doc)
protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException(Code)(Java Doc)
final protected void resolveClass(Class c)(Code)(Java Doc)
public synchronized void setClassAssertionStatus(String className, boolean enabled)(Code)(Java Doc)
public synchronized void setDefaultAssertionStatus(boolean enabled)(Code)(Java Doc)
public synchronized void setPackageAssertionStatus(String packageName, boolean enabled)(Code)(Java Doc)
final protected void setSigners(Class c, Object[] signers)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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