Source Code Cross Referenced for ClientLauncher.java in  » EJB-Server-JBoss-4.2.1 » ejb3 » org » jboss » ejb3 » client » 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 » EJB Server JBoss 4.2.1 » ejb3 » org.jboss.ejb3.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
004:         * by the @authors tag. See the copyright.txt in the distribution for a
005:         * full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.ejb3.client;
023:
024:        import java.io.IOException;
025:        import java.net.URL;
026:        import java.net.URLClassLoader;
027:        import java.util.ArrayList;
028:        import java.util.List;
029:
030:        //import org.jboss.client.AppClientLauncher;
031:        import org.jboss.ejb3.metamodel.ApplicationClientDD;
032:        import org.jboss.ejb3.metamodel.ApplicationClientDDObjectFactory;
033:        import org.jboss.ejb3.metamodel.JBossClientDDObjectFactory;
034:        import org.jboss.util.NotImplementedException;
035:        import org.jboss.xb.binding.JBossXBException;
036:
037:        /**
038:         * This class launches a JavaEE 5 application client.
039:         * 
040:         * The first argument is either a jar file containing the client deployment files or the application client class name.
041:         * The manifest file Main-Class attribute must point to the application client class.
042:         * It must also contain an application client deployment descriptor file (META-INF/application-client.xml).
043:         *
044:         * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
045:         * @version $Revision: $
046:         */
047:        public class ClientLauncher
048:        //   implements AppClientLauncher
049:        {
050:            private static URL findResource(String resourceName) {
051:                URL url;
052:                if (Thread.currentThread().getContextClassLoader() instanceof  URLClassLoader)
053:                    url = ((URLClassLoader) Thread.currentThread()
054:                            .getContextClassLoader())
055:                            .findResource(resourceName);
056:                else
057:                    url = Thread.currentThread().getContextClassLoader()
058:                            .getResource(resourceName);
059:                return url;
060:            }
061:
062:            /**
063:             * Convenience method for launching a client container.
064:             * 
065:             * @param xml
066:             * @param mainClassName
067:             * @param applicationClientName
068:             * @param args
069:             * @throws Exception
070:             */
071:            public static void launch(ApplicationClientDD xml,
072:                    String mainClassName, String applicationClientName,
073:                    String args[]) throws Exception {
074:                Class mainClass = Class.forName(mainClassName);
075:
076:                ClientContainer container = new ClientContainer(xml, mainClass,
077:                        applicationClientName);
078:
079:                // TODO: postContruct
080:
081:                container.invokeMain(args);
082:
083:                // TODO: preDestroy
084:            }
085:
086:            /**
087:             * Convenience method to load the XML descriptor.
088:             * 
089:             * @return
090:             * @throws IOException 
091:             * @throws JBossXBException 
092:             */
093:            public static ApplicationClientDD loadXML()
094:                    throws JBossXBException, IOException {
095:                URL url = findResource("META-INF/application-client.xml");
096:                URL jbossClientURL = findResource("META-INF/jboss-client.xml");
097:                return loadXML(url, jbossClientURL);
098:            }
099:
100:            @Deprecated
101:            public static ApplicationClientDD loadXML(String urlSpec)
102:                    throws JBossXBException, IOException {
103:                URL url = new URL(urlSpec);
104:                return loadXML(url, null);
105:            }
106:
107:            public static ApplicationClientDD loadXML(URL url,
108:                    URL jbossClientURL) throws JBossXBException, IOException {
109:                ApplicationClientDD dd = ApplicationClientDDObjectFactory
110:                        .parse(url);
111:                dd = JBossClientDDObjectFactory.parse(jbossClientURL, dd);
112:                return dd;
113:            }
114:
115:            /**
116:             * Work in progress.
117:             * 
118:             * @param args   the arguments for the launcher
119:             */
120:            public static void main(String[] args) {
121:                try {
122:                    if (args.length < 1)
123:                        throw new IllegalArgumentException(
124:                                "expected a jar filename as argument");
125:
126:                    Class<?> mainClass;
127:
128:                    String name = args[0];
129:                    if (name.endsWith(".jar")) {
130:                        throw new NotImplementedException();
131:                        //            JarFile jarFile = new JarFile(jarName);
132:                    } else {
133:                        String mainClassName = name;
134:                        mainClass = Class.forName(mainClassName);
135:                    }
136:
137:                    URL appXmlURL = mainClass.getClassLoader().getResource(
138:                            "META-INF/application-client.xml");
139:                    if (appXmlURL == null)
140:                        throw new RuntimeException(
141:                                "Can't find META-INF/application-client.xml");
142:
143:                    ApplicationClientDD xml = ApplicationClientDDObjectFactory
144:                            .parse(appXmlURL);
145:
146:                    // FIXME: j2ee.clientName
147:
148:                    List<String> newArgs = new ArrayList<String>();
149:                    for (int i = 1; i < args.length; i++) {
150:                        newArgs.add(args[i]);
151:                    }
152:                    args = newArgs.toArray(args);
153:
154:                    // FIXME: when jar gets implemented this won't work anymore
155:                    String mainClassName = name;
156:                    launch(xml, mainClassName, "FIXME", args);
157:                } catch (Exception e) {
158:                    e.printStackTrace();
159:                    System.exit(1);
160:                }
161:            }
162:
163:            /**
164:             * The AppClientLauncher method for launching a client container.
165:             * 
166:             * @param mainClassName - the class whose main(String[]) will be invoked
167:             * @param clientName - the client name that maps to the server side JNDI ENC
168:             * @param args - the args to pass to main method
169:             * @throws Throwable
170:             */
171:            public void launch(String mainClassName, String clientName,
172:                    String args[]) throws Throwable {
173:                ApplicationClientDD xml = loadXML();
174:                launch(xml, mainClassName, clientName, args);
175:            }
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.