Source Code Cross Referenced for JarClassLoader.java in  » XML-UI » XUI » net » xoetrope » builder » editor » plugin » 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 » XML UI » XUI » net.xoetrope.builder.editor.plugin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package net.xoetrope.builder.editor.plugin;
02:
03:        import java.net.URL;
04:        import java.net.URLClassLoader;
05:        import java.net.JarURLConnection;
06:        import java.lang.reflect.Method;
07:        import java.lang.reflect.Modifier;
08:        import java.lang.reflect.InvocationTargetException;
09:        import java.util.jar.Attributes;
10:        import java.io.IOException;
11:
12:        /**
13:         * A class loader for loading jar files, both local and remote.
14:         */
15:        class JarClassLoader extends URLClassLoader {
16:            private URL url;
17:
18:            public static final String XUI_PLUGIN_CLASS = "XuiEditorPlugin-Class";
19:
20:            /**
21:             * Creates a new JarClassLoader for the specified url.
22:             *
23:             * @param url the url of the jar file
24:             */
25:            public JarClassLoader(URL url) {
26:                super (new URL[] { url });
27:                this .url = url;
28:            }
29:
30:            /**
31:             * Returns the name of the jar file main class, or null if
32:             * no "Main-Class" manifest attributes was defined.
33:             */
34:            public String getMainClassName() throws IOException {
35:                URL u = new URL("jar", "", url + "!/");
36:                JarURLConnection uc = (JarURLConnection) u.openConnection();
37:                Attributes attr = uc.getMainAttributes();
38:                return attr != null ? attr.getValue(XUI_PLUGIN_CLASS) : null;
39:            }
40:
41:            /**
42:             * Invokes the application in this jar file given the name of the
43:             * main class and an array of arguments. The class must define a
44:             * static method "main" which takes an array of String arguemtns
45:             * and is of return type "void".
46:             *
47:             * @param name the name of the main class
48:             * @param args the arguments for the application
49:             * @exception ClassNotFoundException if the specified class could not
50:             *            be found
51:             * @exception NoSuchMethodException if the specified class does not
52:             *            contain a "main" method
53:             * @exception InvocationTargetException if the application raised an
54:             *            exception
55:             */
56:            public void invokeClass(String name, String[] args)
57:                    throws ClassNotFoundException, NoSuchMethodException,
58:                    InvocationTargetException {
59:                Class c = loadClass(name);
60:                Method m = c.getMethod("main", new Class[] { args.getClass() });
61:                m.setAccessible(true);
62:                int mods = m.getModifiers();
63:                if (m.getReturnType() != void.class || !Modifier.isStatic(mods)
64:                        || !Modifier.isPublic(mods)) {
65:                    throw new NoSuchMethodException("main");
66:                }
67:                try {
68:                    m.invoke(null, new Object[] { args });
69:                } catch (IllegalAccessException e) {
70:                    // This should not happen, as we have disabled access checks
71:                }
72:            }
73:
74:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.