Source Code Cross Referenced for Holder.java in  » Sevlet-Container » jetty-modules » org » mortbay » jetty » servlet » 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 » Sevlet Container » jetty modules » org.mortbay.jetty.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // ========================================================================
002:        // Copyright 1996-2005 Mort Bay Consulting Pty. Ltd.
003:        // ------------------------------------------------------------------------
004:        // Licensed under the Apache License, Version 2.0 (the "License");
005:        // you may not use this file except in compliance with the License.
006:        // You may obtain a copy of the License at 
007:        // http://www.apache.org/licenses/LICENSE-2.0
008:        // Unless required by applicable law or agreed to in writing, software
009:        // distributed under the License is distributed on an "AS IS" BASIS,
010:        // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011:        // See the License for the specific language governing permissions and
012:        // limitations under the License.
013:        // ========================================================================
014:
015:        package org.mortbay.jetty.servlet;
016:
017:        import java.io.Serializable;
018:        import java.util.Collections;
019:        import java.util.Enumeration;
020:        import java.util.HashMap;
021:        import java.util.Map;
022:
023:        import javax.servlet.UnavailableException;
024:
025:        import org.mortbay.component.AbstractLifeCycle;
026:        import org.mortbay.log.Log;
027:        import org.mortbay.util.Loader;
028:
029:        /* --------------------------------------------------------------------- */
030:        /** 
031:         * @author Greg Wilkins
032:         */
033:        public class Holder extends AbstractLifeCycle implements  Serializable {
034:            protected transient Class _class;
035:            protected String _className;
036:            protected String _displayName;
037:            protected Map _initParams;
038:            protected boolean _extInstance;
039:
040:            /* ---------------------------------------------------------------- */
041:            protected String _name;
042:            protected ServletHandler _servletHandler;
043:
044:            protected Holder() {
045:            }
046:
047:            /* ---------------------------------------------------------------- */
048:            protected Holder(Class held) {
049:                _class = held;
050:                if (held != null) {
051:                    _className = held.getName();
052:                    _name = held.getName();
053:                }
054:            }
055:
056:            /* ------------------------------------------------------------ */
057:            public void doStart() throws Exception {
058:                //if no class already loaded and no classname, make servlet permanently unavailable
059:                if (_class == null
060:                        && (_className == null || _className.equals("")))
061:                    throw new UnavailableException(
062:                            "No class for Servlet or Filter", -1);
063:
064:                //try to load class
065:                if (_class == null) {
066:                    try {
067:                        _class = Loader.loadClass(Holder.class, _className);
068:                        if (Log.isDebugEnabled())
069:                            Log.debug("Holding {}", _class);
070:                    } catch (Exception e) {
071:                        throw new UnavailableException(e.getMessage(), -1);
072:                    }
073:                }
074:            }
075:
076:            /* ------------------------------------------------------------ */
077:            public void doStop() {
078:                if (!_extInstance)
079:                    _class = null;
080:            }
081:
082:            /* ------------------------------------------------------------ */
083:            public String getClassName() {
084:                return _className;
085:            }
086:
087:            /* ------------------------------------------------------------ */
088:            public Class getHeldClass() {
089:                return _class;
090:            }
091:
092:            /* ------------------------------------------------------------ */
093:            public String getDisplayName() {
094:                return _displayName;
095:            }
096:
097:            /* ---------------------------------------------------------------- */
098:            public String getInitParameter(String param) {
099:                if (_initParams == null)
100:                    return null;
101:                return (String) _initParams.get(param);
102:            }
103:
104:            /* ------------------------------------------------------------ */
105:            public Enumeration getInitParameterNames() {
106:                if (_initParams == null)
107:                    return Collections.enumeration(Collections.EMPTY_LIST);
108:                return Collections.enumeration(_initParams.keySet());
109:            }
110:
111:            /* ---------------------------------------------------------------- */
112:            public Map getInitParameters() {
113:                return _initParams;
114:            }
115:
116:            /* ------------------------------------------------------------ */
117:            public String getName() {
118:                return _name;
119:            }
120:
121:            /* ------------------------------------------------------------ */
122:            /**
123:             * @return Returns the servletHandler.
124:             */
125:            public ServletHandler getServletHandler() {
126:                return _servletHandler;
127:            }
128:
129:            /* ------------------------------------------------------------ */
130:            public synchronized Object newInstance()
131:                    throws InstantiationException, IllegalAccessException {
132:                if (_class == null)
133:                    throw new InstantiationException("!" + _className);
134:                return _class.newInstance();
135:            }
136:
137:            /* ------------------------------------------------------------ */
138:            /**
139:             * @param className The className to set.
140:             */
141:            public void setClassName(String className) {
142:                _className = className;
143:                _class = null;
144:            }
145:
146:            /* ------------------------------------------------------------ */
147:            /**
148:             * @param className The className to set.
149:             */
150:            public void setHeldClass(Class held) {
151:                _class = held;
152:                _className = held != null ? held.getName() : null;
153:            }
154:
155:            /* ------------------------------------------------------------ */
156:            public void setDisplayName(String name) {
157:                _displayName = name;
158:            }
159:
160:            /* ------------------------------------------------------------ */
161:            public void setInitParameter(String param, String value) {
162:                if (_initParams == null)
163:                    _initParams = new HashMap(3);
164:                _initParams.put(param, value);
165:            }
166:
167:            /* ---------------------------------------------------------------- */
168:            public void setInitParameters(Map map) {
169:                _initParams = map;
170:            }
171:
172:            /* ------------------------------------------------------------ */
173:            /**
174:             * @param name The name to set.
175:             */
176:            public void setName(String name) {
177:                _name = name;
178:            }
179:
180:            /* ------------------------------------------------------------ */
181:            /**
182:             * @param servletHandler The {@link ServletHandler} that will handle requests dispatched to this servlet.
183:             */
184:            public void setServletHandler(ServletHandler servletHandler) {
185:                _servletHandler = servletHandler;
186:            }
187:
188:            /* ------------------------------------------------------------ */
189:            public String toString() {
190:                return _name;
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.