Source Code Cross Referenced for JOnASStandardContext.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » web » catalina55 » 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.catalina55 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2005 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:         * Initial developer(s): Philippe Coq
022:         * --------------------------------------------------------------------------
023:         * $Id: JOnASStandardContext.java 9906 2007-01-09 10:25:37Z benoitf $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas.web.catalina55;
026:
027:        import java.net.URL;
028:
029:        import javax.management.MalformedObjectNameException;
030:        import javax.management.ObjectName;
031:
032:        import org.apache.catalina.LifecycleException;
033:        import org.apache.catalina.core.StandardContext;
034:        import org.apache.catalina.deploy.ContextEnvironment;
035:        import org.apache.catalina.deploy.ContextResource;
036:        import org.objectweb.jonas.common.Log;
037:        import org.objectweb.jonas.jmx.J2eeObjectName;
038:        import org.objectweb.jonas.service.ServiceManager;
039:        import org.objectweb.jonas.web.wrapper.CatalinaJWebContainerService;
040:        import org.objectweb.util.monolog.api.BasicLevel;
041:        import org.objectweb.util.monolog.api.Logger;
042:
043:        /**
044:         * Define a JOnAS context. It is used to check if a context has been defined in
045:         * server.xml and to use this context while deploying the war instead of
046:         * creating a new one
047:         * @author Florent Benoit
048:         * @author Philippe Coq (Tomcat 4.0)
049:         */
050:
051:        public final class JOnASStandardContext extends StandardContext {
052:
053:            /**
054:             * UID for the serialization.
055:             */
056:            private static final long serialVersionUID = 1L;
057:
058:            /**
059:             * Unique instance of Catalina
060:             */
061:            private static CatalinaJWebContainerService catalinaService = null;
062:
063:            /**
064:             * Logger for this service.
065:             */
066:            private static Logger logger = null;
067:
068:            /**
069:             * URL of the ear
070:             */
071:            private URL earURL = null;
072:
073:            /**
074:             * We are in ear case or not ?
075:             */
076:            private boolean inEarCase = false;
077:
078:            /**
079:             * This context was configured in server.xml ?
080:             */
081:            private boolean inServerXml = false;
082:
083:            /**
084:             * Java 2 delegation model is use or not ?
085:             */
086:            private boolean java2DelegationModel = false;
087:
088:            /**
089:             * JOnAS deployment descriptor
090:             */
091:            private String jonasDeploymentDescriptor = null;
092:
093:            /**
094:             * Context was started ?
095:             */
096:            private boolean startedJStdx = false;
097:
098:            /**
099:             * URL of the war
100:             */
101:            private URL warURL = null;
102:
103:            /**
104:             * J2EEApplication MBean OBJECT_NAME in ear case
105:             */
106:            private String earON = null;
107:
108:            /**
109:             * Constructor of the Context
110:             */
111:            public JOnASStandardContext() {
112:                this (true, true, false);
113:            }
114:
115:            /**
116:             * Constructor of the Context
117:             * @param inServerXml this context was defined in server.xml
118:             * @param java2DelegationModel delegation model for classloader is true ?
119:             * @param inEarCase if we are or not in EAR case
120:             */
121:            public JOnASStandardContext(final boolean inServerXml,
122:                    final boolean java2DelegationModel, final boolean inEarCase) {
123:                super ();
124:                this .inServerXml = inServerXml;
125:                this .java2DelegationModel = java2DelegationModel;
126:                this .inEarCase = inEarCase;
127:                logger = Log.getLogger(Log.JONAS_WEB_PREFIX);
128:                try {
129:                    catalinaService = (CatalinaJWebContainerService) ServiceManager
130:                            .getInstance().getWebContainerService();
131:                } catch (Exception e) {
132:                    if (logger.isLoggable(BasicLevel.ERROR)) {
133:                        logger.log(BasicLevel.ERROR,
134:                                "Cannot get Web container service");
135:                    }
136:                }
137:            }
138:
139:            /**
140:             * @return Returns the earURL.
141:             */
142:            public URL getEarURL() {
143:                return earURL;
144:            }
145:
146:            /**
147:             * Gets the deployment descriptor content of jonas-web.xml file
148:             * @return the content of jonas-web.xml file
149:             */
150:            public String getJonasDeploymentDescriptor() {
151:                return jonasDeploymentDescriptor;
152:            }
153:
154:            /**
155:             * @return Returns the warURL.
156:             */
157:            public URL getWarURL() {
158:                return warURL;
159:            }
160:
161:            /**
162:             * @return true if this web module is a part of a EAR
163:             */
164:            public boolean isInEarCase() {
165:                return inEarCase;
166:            }
167:
168:            /**
169:             * This context was defined in server.xml ?
170:             * @return true if this context was defined in server.xml
171:             */
172:            public boolean isInServerXml() {
173:                return inServerXml;
174:            }
175:
176:            /**
177:             * @return true if the Java2 delegation model is used
178:             */
179:            public boolean isJava2DelegationModel() {
180:                return java2DelegationModel;
181:            }
182:
183:            /**
184:             * @param earURL The earURL to set.
185:             */
186:            protected void setEarURL(URL earURL) {
187:                this .earURL = earURL;
188:                // Determine the corresponding J2EEApplication ObjectName
189:                ObjectName j2eeAppOn = null;
190:                // Catalina StandardContext provides setter and getter for j2eeApplication attribute
191:                // The setter was called in CatalinaJWebContainerServiceImpl.doRegisterWar method
192:                // befor the call to this setter
193:                String appName = getJ2EEApplication();
194:                // setServer() was called before this setter
195:                String serverON = getServer();
196:                if (appName != null && serverON != null) {
197:                    ObjectName serverOn;
198:                    try {
199:                        serverOn = ObjectName.getInstance(serverON);
200:                        String domainName = serverOn.getDomain();
201:                        String serverName = serverOn.getKeyProperty("name");
202:                        j2eeAppOn = J2eeObjectName.J2EEApplication(domainName,
203:                                serverName, appName);
204:                    } catch (MalformedObjectNameException e) {
205:                        // TODO Auto-generated catch block
206:                        //e.printStackTrace();
207:                    }
208:                }
209:                if (j2eeAppOn != null) {
210:                    earON = j2eeAppOn.toString();
211:                }
212:            }
213:
214:            /**
215:             * @param inEarCase The inEarCase to set.
216:             */
217:            protected void setInEarCase(boolean inEarCase) {
218:                this .inEarCase = inEarCase;
219:            }
220:
221:            /**
222:             * @param java2DelegationModel The java2DelegationModel to set.
223:             */
224:            protected void setJava2DelegationModel(boolean java2DelegationModel) {
225:                this .java2DelegationModel = java2DelegationModel;
226:            }
227:
228:            /**
229:             * Set the deployment descriptor content of jonas-web.xml file
230:             * @param jonasDeploymentDescriptor the content of jonas-web.xml
231:             */
232:            public void setJonasDeploymentDescriptor(
233:                    String jonasDeploymentDescriptor) {
234:                this .jonasDeploymentDescriptor = jonasDeploymentDescriptor;
235:            }
236:
237:            /**
238:             * @param warURL The warURL to set.
239:             */
240:            protected void setWarURL(URL warURL) {
241:                this .warURL = warURL;
242:            }
243:
244:            /**
245:             * Start the JOnAS context if catalina is started
246:             * @throws LifecycleException if the context can't be started
247:             */
248:            public synchronized void start() throws LifecycleException {
249:                if (logger.isLoggable(BasicLevel.DEBUG)) {
250:                    logger.log(BasicLevel.DEBUG, "");
251:                }
252:                if (catalinaService != null
253:                        && catalinaService.isTomcatStarted()) {
254:                    if (logger.isLoggable(BasicLevel.DEBUG)) {
255:                        logger
256:                                .log(BasicLevel.DEBUG,
257:                                        "Tomcat in Web container service is started, starting the context...");
258:                    }
259:                    startedJStdx = true;
260:                    super .start();
261:                }
262:
263:            }
264:
265:            /**
266:             * Stop this Context component.
267:             * @exception LifecycleException if a shutdown error occurs
268:             */
269:            public synchronized void stop() throws LifecycleException {
270:                if (logger.isLoggable(BasicLevel.DEBUG)) {
271:                    logger.log(BasicLevel.DEBUG, "");
272:                }
273:                if (startedJStdx) {
274:                    startedJStdx = false;
275:                    super .stop();
276:                }
277:
278:            }
279:
280:            /**
281:             * Add a resource reference for this web application.
282:             * Do nothing when running inside JOnAS. Resources are managed by JOnAS
283:             * @param resource New resource reference
284:             */
285:            public void addResource(ContextResource resource) {
286:            }
287:
288:            /**
289:             * Add an environment entry for this web application.
290:             * Do nothing when running inside JOnAS. ENC environment is managed by JOnAS
291:             * @param environment New environment entry
292:             */
293:            public void addEnvironment(ContextEnvironment environment) {
294:            }
295:
296:            /**
297:             * Set the parent class loader for this web application.
298:             * Do it only if it is not started.
299:             * @param parent The new parent class loader
300:             */
301:            public void setParentClassLoader(ClassLoader parent) {
302:                // Do it only if the context is not already started
303:                if (!startedJStdx) {
304:                    super .setParentClassLoader(parent);
305:                }
306:            }
307:
308:            /**
309:             *
310:             * @return OBJECT_NAME of the parent J2EEApplication MBean
311:             */
312:            public String getEarON() {
313:                return earON;
314:            }
315:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.