Source Code Cross Referenced for WebManagerWrapper.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_web » deployment » lib » wrapper » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_web.deployment.lib.wrapper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: WebManagerWrapper.java 4799 2004-05-25 14:26:36Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_web.deployment.lib.wrapper;
025:
026:        import java.lang.reflect.InvocationTargetException;
027:        import java.lang.reflect.Method;
028:        import java.net.URL;
029:        import java.net.URLClassLoader;
030:
031:        import org.objectweb.jonas_web.deployment.api.WebContainerDeploymentDesc;
032:        import org.objectweb.jonas_web.deployment.api.WebContainerDeploymentDescException;
033:
034:        import org.objectweb.jonas.common.Log;
035:        import org.objectweb.jonas.server.LoaderManager;
036:
037:        import org.objectweb.util.monolog.api.BasicLevel;
038:        import org.objectweb.util.monolog.api.Logger;
039:
040:        /**
041:         * Wrap the WebDeploymentDescManager to solve ClassLoader problems linked to
042:         * Digester.
043:         *
044:         * @author Guillaume Sauthier
045:         */
046:        public class WebManagerWrapper {
047:
048:            /**
049:             * logger
050:             */
051:            private static Logger logger = Log.getLogger(Log.JONAS_EAR_PREFIX);
052:
053:            /**
054:             * WebDeploymentDescManager classname
055:             */
056:            private static final String WEBMANAGER_CLASSNAME = "org.objectweb.jonas_web.deployment.lib.WebDeploymentDescManager";
057:
058:            /**
059:             * Private Empty constructor for utility class
060:             */
061:            private WebManagerWrapper() {
062:            }
063:
064:            /**
065:             * Wrap the WebDeploymentDescManager.getInstance().getDeploymentDesc() call.
066:             *
067:             * @param url WebApp URL
068:             * @param moduleCL WebApp module ClassLoader
069:             * @param earCL Application ClassLoader
070:             *
071:             * @return the WebContainerDeploymentDesc of the given WebApp
072:             *
073:             * @throws WebContainerDeploymentDescException When WebContainerDeploymentDesc cannot be instanciated
074:             */
075:            public static WebContainerDeploymentDesc getDeploymentDesc(URL url,
076:                    ClassLoader moduleCL, ClassLoader earCL)
077:                    throws WebContainerDeploymentDescException {
078:                LoaderManager lm = LoaderManager.getInstance();
079:                WebContainerDeploymentDesc webDD = null;
080:
081:                try {
082:                    ClassLoader tools = lm.getToolsLoader();
083:                    Class manager = tools.loadClass(WEBMANAGER_CLASSNAME);
084:                    Method m = manager.getDeclaredMethod("getInstance",
085:                            new Class[] {});
086:                    Object instance = m.invoke(null, new Object[] {});
087:                    m = manager.getDeclaredMethod("getDeploymentDesc",
088:                            new Class[] { URL.class, ClassLoader.class,
089:                                    ClassLoader.class });
090:                    webDD = (WebContainerDeploymentDesc) m.invoke(instance,
091:                            new Object[] { url, moduleCL, earCL });
092:                } catch (InvocationTargetException ite) {
093:                    Throwable t = ite.getTargetException();
094:                    if (WebContainerDeploymentDescException.class.isInstance(t)) {
095:                        throw (WebContainerDeploymentDescException) ite
096:                                .getTargetException();
097:                    } else {
098:                        throw new WebContainerDeploymentDescException(
099:                                "WebDeploymentDescManager.getDeploymentDesc fails",
100:                                t);
101:                    }
102:                } catch (Exception e) {
103:                    // TODO add i18n here
104:                    throw new WebContainerDeploymentDescException(
105:                            "Problems when using reflection on WebDeploymentDescManager",
106:                            e);
107:                }
108:
109:                return webDD;
110:            }
111:
112:            /**
113:             * Wrap the WebDeploymentDescManager.getInstance().setAltDD() call.
114:             *
115:             * @param earClassLoader Application ClassLoader
116:             * @param warUrls Array of WebApp URLs
117:             * @param warsAltDDs Array of Alternatives WebApp Descriptor URL
118:             */
119:            public static void setAltDD(URLClassLoader earClassLoader,
120:                    URL[] warUrls, URL[] warsAltDDs) {
121:                LoaderManager lm = LoaderManager.getInstance();
122:
123:                try {
124:                    ClassLoader tools = lm.getToolsLoader();
125:                    Class manager = tools.loadClass(WEBMANAGER_CLASSNAME);
126:                    Method m = manager.getDeclaredMethod("getInstance",
127:                            new Class[] {});
128:                    Object instance = m.invoke(null, new Object[] {});
129:                    m = manager.getDeclaredMethod("setAltDD", new Class[] {
130:                            ClassLoader.class, URL[].class, URL[].class });
131:                    m.invoke(instance, new Object[] { earClassLoader, warUrls,
132:                            warsAltDDs });
133:                } catch (Exception e) {
134:                    // Should never occurs
135:                    logger.log(BasicLevel.ERROR, e);
136:                }
137:            }
138:
139:            /**
140:             * Wrap the WebDeploymentDescManager.setParsingWithValidation() call.
141:             *
142:             * @param b true/false
143:             */
144:            public static void setParsingWithValidation(boolean b) {
145:                LoaderManager lm = LoaderManager.getInstance();
146:
147:                try {
148:                    ClassLoader tools = lm.getToolsLoader();
149:                    Class manager = tools.loadClass(WEBMANAGER_CLASSNAME);
150:                    Method m = manager.getDeclaredMethod(
151:                            "setParsingWithValidation",
152:                            new Class[] { boolean.class });
153:                    m.invoke(null, new Object[] { new Boolean(b) });
154:                } catch (Exception e) {
155:                    // Should never occurs
156:                    logger.log(BasicLevel.ERROR, e);
157:                }
158:            }
159:
160:            /**
161:             * Wrap the WebDeploymentDescManager.getInstance().removeCache() call.
162:             *
163:             * @param classLoader WebApp ClassLoader
164:             */
165:            public static void removeCache(ClassLoader classLoader) {
166:                LoaderManager lm = LoaderManager.getInstance();
167:
168:                try {
169:                    ClassLoader tools = lm.getToolsLoader();
170:                    Class manager = tools.loadClass(WEBMANAGER_CLASSNAME);
171:                    Method m = manager.getDeclaredMethod("getInstance",
172:                            new Class[] {});
173:                    Object instance = m.invoke(null, new Object[] {});
174:                    m = manager.getDeclaredMethod("removeCache",
175:                            new Class[] { ClassLoader.class });
176:                    m.invoke(instance, new Object[] { classLoader });
177:                } catch (Exception e) {
178:                    // Should never occurs
179:                    logger.log(BasicLevel.ERROR, e);
180:                }
181:            }
182:
183:            /**
184:             * Wrap the WebDeploymentDescManager.getDeploymentDesc() call.
185:             *
186:             * @param warName war filename
187:             * @param cl WebApp ClassLoader
188:             *
189:             * @return the WebContainerDeploymentDesc of the given WebApp
190:             *
191:             * @throws WebContainerDeploymentDescException When WebContainerDeploymentDesc cannot be instanciated
192:             */
193:            public static WebContainerDeploymentDesc getDeploymentDesc(
194:                    String warName, ClassLoader cl)
195:                    throws WebContainerDeploymentDescException {
196:                LoaderManager lm = LoaderManager.getInstance();
197:                WebContainerDeploymentDesc desc = null;
198:
199:                try {
200:                    ClassLoader tools = lm.getToolsLoader();
201:                    Class manager = tools.loadClass(WEBMANAGER_CLASSNAME);
202:                    Method m = manager.getDeclaredMethod("getDeploymentDesc",
203:                            new Class[] { String.class, ClassLoader.class });
204:                    desc = (WebContainerDeploymentDesc) m.invoke(null,
205:                            new Object[] { warName, cl });
206:                } catch (InvocationTargetException ite) {
207:                    Throwable t = ite.getTargetException();
208:                    if (WebContainerDeploymentDescException.class.isInstance(t)) {
209:                        throw (WebContainerDeploymentDescException) ite
210:                                .getTargetException();
211:                    } else {
212:                        throw new WebContainerDeploymentDescException(
213:                                "WebDeploymentDescManager.getDeploymentDesc fails",
214:                                t);
215:                    }
216:                } catch (Exception e) {
217:                    // TODO add i18n here
218:                    throw new WebContainerDeploymentDescException(
219:                            "Problems when using reflection on WebDeploymentDescManager",
220:                            e);
221:                }
222:
223:                return desc;
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.