Source Code Cross Referenced for WeavingClassLoader.java in  » Aspect-oriented » aspectwerkz-2.0 » org » codehaus » aspectwerkz » hook » impl » 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 » Aspect oriented » aspectwerkz 2.0 » org.codehaus.aspectwerkz.hook.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /**************************************************************************************
02:         * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
03:         * http://aspectwerkz.codehaus.org                                                    *
04:         * ---------------------------------------------------------------------------------- *
05:         * The software in this package is published under the terms of the LGPL license      *
06:         * a copy of which has been included with this distribution in the license.txt file.  *
07:         **************************************************************************************/package org.codehaus.aspectwerkz.hook.impl;
08:
09:        import sun.misc.Resource;
10:        import sun.misc.URLClassPath;
11:
12:        import java.io.File;
13:        import java.io.IOException;
14:        import java.lang.reflect.Method;
15:        import java.net.URL;
16:        import java.net.URLClassLoader;
17:        import java.util.ArrayList;
18:        import java.util.StringTokenizer;
19:
20:        /**
21:         * Very basic classloader that do online weaving. <p/>This classloader can be used thru several means
22:         * <ul>
23:         * <li>as a URLClassLoader in a custom development</li>
24:         * <li>as a <i>MainClass </i> to allow on the fly weaving (without support for classloader hierarchy)</li>
25:         * </ul>
26:         * It can also be used for debugging step by step in any IDE
27:         *
28:         * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
29:         * @todo rewrite based on SUN src (definePackage missing)
30:         */
31:        public class WeavingClassLoader extends URLClassLoader {
32:            public WeavingClassLoader(URL[] urls, ClassLoader parent) {
33:                super (urls, parent);
34:            }
35:
36:            protected Class findClass(String name)
37:                    throws ClassNotFoundException {
38:                String path = name.replace('.', '/').concat(".class");
39:                Resource res = new URLClassPath(getURLs()).getResource(path,
40:                        false);
41:                if (res != null) {
42:                    //definePackage(name.substring(0, name.lastIndexOf(".")), null, null);
43:                    try {
44:                        byte[] b = res.getBytes();
45:                        byte[] transformed = ClassPreProcessorHelper
46:                                .defineClass0Pre(this , name, b, 0, b.length,
47:                                        null);
48:                        return defineClass(name, transformed, 0,
49:                                transformed.length);
50:                    } catch (IOException e) {
51:                        throw new ClassNotFoundException(e.getMessage());
52:                    }
53:                } else {
54:                    throw new ClassNotFoundException(name);
55:                }
56:            }
57:
58:            public static void main(String[] args) throws Exception {
59:                String path = System.getProperty("java.class.path");
60:                ArrayList paths = new ArrayList();
61:                StringTokenizer st = new StringTokenizer(path,
62:                        File.pathSeparator);
63:                while (st.hasMoreTokens()) {
64:                    paths.add((new File(st.nextToken())).getCanonicalFile()
65:                            .toURL());
66:                }
67:
68:                //System.setProperty("aspectwerkz.transform.verbose", "yes");
69:                //System.setProperty("aspectwerkz.transform.dump", "*");
70:                //System.setProperty("aspectwerkz.definition.file", "...");
71:                //@todo check child of extension classloader instead of boot classloader
72:                ClassLoader cl = new WeavingClassLoader((URL[]) paths
73:                        .toArray(new URL[] {}), ClassLoader
74:                        .getSystemClassLoader().getParent());
75:                Thread.currentThread().setContextClassLoader(cl);
76:                String s = args[0];
77:                String[] args1 = new String[args.length - 1];
78:                if (args1.length > 0) {
79:                    System.arraycopy(args, 1, args1, 0, args.length - 1);
80:                }
81:                Class class1 = Class.forName(s, false, cl);
82:                Method method = class1.getMethod("main",
83:                        new Class[] { String[].class });
84:                method.invoke(null, new Object[] { args1 });
85:            }
86:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.