Source Code Cross Referenced for ValveBase.java in  » Sevlet-Container » tomcat-catalina » org » apache » catalina » valves » 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 » tomcat catalina » org.apache.catalina.valves 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2001,2004 The Apache Software Foundation.
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:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.catalina.valves;
018:
019:        import java.io.IOException;
020:
021:        import javax.management.MBeanRegistration;
022:        import javax.management.MBeanServer;
023:        import javax.management.MalformedObjectNameException;
024:        import javax.management.ObjectName;
025:        import javax.servlet.ServletException;
026:
027:        import org.apache.catalina.Contained;
028:        import org.apache.catalina.Container;
029:        import org.apache.catalina.Context;
030:        import org.apache.catalina.Engine;
031:        import org.apache.catalina.Host;
032:        import org.apache.catalina.Pipeline;
033:        import org.apache.catalina.Request;
034:        import org.apache.catalina.Response;
035:        import org.apache.catalina.Valve;
036:        import org.apache.catalina.ValveContext;
037:        import org.apache.catalina.Wrapper;
038:        import org.apache.catalina.core.ContainerBase;
039:        import org.apache.catalina.util.StringManager;
040:        import org.apache.commons.logging.Log;
041:        import org.apache.commons.logging.LogFactory;
042:
043:        /**
044:         * Convenience base class for implementations of the <b>Valve</b> interface.
045:         * A subclass <strong>MUST</strong> implement an <code>invoke()</code>
046:         * method to provide the required functionality, and <strong>MAY</strong>
047:         * implement the <code>Lifecycle</code> interface to provide configuration
048:         * management and lifecycle support.
049:         *
050:         * @author Craig R. McClanahan
051:         * @version $Revision: 1.12 $ $Date: 2004/05/26 16:28:23 $
052:         */
053:
054:        public abstract class ValveBase implements  Contained, Valve,
055:                MBeanRegistration {
056:            private static Log log = LogFactory.getLog(ValveBase.class);
057:
058:            //------------------------------------------------------ Instance Variables
059:
060:            /**
061:             * The Container whose pipeline this Valve is a component of.
062:             */
063:            protected Container container = null;
064:
065:            /**
066:             * The debugging detail level for this component.
067:             */
068:            protected int debug = 0;
069:
070:            /**
071:             * Descriptive information about this Valve implementation.  This value
072:             * should be overridden by subclasses.
073:             */
074:            protected static String info = "org.apache.catalina.core.ValveBase/1.0";
075:
076:            /**
077:             * The string manager for this package.
078:             */
079:            protected final static StringManager sm = StringManager
080:                    .getManager(Constants.Package);
081:
082:            //-------------------------------------------------------------- Properties
083:
084:            /**
085:             * Return the Container with which this Valve is associated, if any.
086:             */
087:            public Container getContainer() {
088:
089:                return (container);
090:
091:            }
092:
093:            /**
094:             * Set the Container with which this Valve is associated, if any.
095:             *
096:             * @param container The new associated container
097:             */
098:            public void setContainer(Container container) {
099:
100:                this .container = container;
101:
102:            }
103:
104:            /**
105:             * Return the debugging detail level for this component.
106:             */
107:            public int getDebug() {
108:
109:                return (this .debug);
110:
111:            }
112:
113:            /**
114:             * Set the debugging detail level for this component.
115:             *
116:             * @param debug The new debugging detail level
117:             */
118:            public void setDebug(int debug) {
119:
120:                this .debug = debug;
121:
122:            }
123:
124:            /**
125:             * Return descriptive information about this Valve implementation.
126:             */
127:            public String getInfo() {
128:
129:                return (info);
130:
131:            }
132:
133:            //---------------------------------------------------------- Public Methods
134:
135:            /**
136:             * The implementation-specific logic represented by this Valve.  See the
137:             * Valve description for the normal design patterns for this method.
138:             * <p>
139:             * This method <strong>MUST</strong> be provided by a subclass.
140:             *
141:             * @param request The servlet request to be processed
142:             * @param response The servlet response to be created
143:             * @param context The valve context used to invoke the next valve
144:             *  in the current processing pipeline
145:             *
146:             * @exception IOException if an input/output error occurs
147:             * @exception ServletException if a servlet error occurs
148:             */
149:            public abstract void invoke(Request request, Response response,
150:                    ValveContext context) throws IOException, ServletException;
151:
152:            // -------------------- JMX and Registration  --------------------
153:            protected String domain;
154:            protected ObjectName oname;
155:            protected MBeanServer mserver;
156:            protected ObjectName controller;
157:
158:            public ObjectName getObjectName() {
159:                return oname;
160:            }
161:
162:            public void setObjectName(ObjectName oname) {
163:                this .oname = oname;
164:            }
165:
166:            public String getDomain() {
167:                return domain;
168:            }
169:
170:            public ObjectName preRegister(MBeanServer server, ObjectName name)
171:                    throws Exception {
172:                oname = name;
173:                mserver = server;
174:                domain = name.getDomain();
175:
176:                return name;
177:            }
178:
179:            public void postRegister(Boolean registrationDone) {
180:            }
181:
182:            public void preDeregister() throws Exception {
183:            }
184:
185:            public void postDeregister() {
186:            }
187:
188:            public ObjectName getController() {
189:                return controller;
190:            }
191:
192:            public void setController(ObjectName controller) {
193:                this .controller = controller;
194:            }
195:
196:            /** From the name, extract the parent object name
197:             *
198:             * @param valveName The valve name
199:             * @return ObjectName The parent name
200:             */
201:            public ObjectName getParentName(ObjectName valveName) {
202:
203:                return null;
204:            }
205:
206:            public ObjectName createObjectName(String domain, ObjectName parent)
207:                    throws MalformedObjectNameException {
208:                Container container = this .getContainer();
209:                if (container == null || !(container instanceof  ContainerBase))
210:                    return null;
211:                ContainerBase containerBase = (ContainerBase) container;
212:                Pipeline pipe = containerBase.getPipeline();
213:                Valve valves[] = pipe.getValves();
214:
215:                /* Compute the "parent name" part */
216:                String parentName = "";
217:                if (container instanceof  Engine) {
218:                } else if (container instanceof  Host) {
219:                    parentName = ",host=" + container.getName();
220:                } else if (container instanceof  Context) {
221:                    String path = ((Context) container).getPath();
222:                    if (path.length() < 1) {
223:                        path = "/";
224:                    }
225:                    Host host = (Host) container.getParent();
226:                    parentName = ",path=" + path + ",host=" + host.getName();
227:                } else if (container instanceof  Wrapper) {
228:                    Context ctx = (Context) container.getParent();
229:                    String path = ctx.getPath();
230:                    if (path.length() < 1) {
231:                        path = "/";
232:                    }
233:                    Host host = (Host) ctx.getParent();
234:                    parentName = ",servlet=" + container.getName() + ",path="
235:                            + path + ",host=" + host.getName();
236:                }
237:                log.debug("valve parent=" + parentName + " " + parent);
238:
239:                String className = this .getClass().getName();
240:                int period = className.lastIndexOf('.');
241:                if (period >= 0)
242:                    className = className.substring(period + 1);
243:
244:                int seq = 0;
245:                for (int i = 0; i < valves.length; i++) {
246:                    // Find other valves with the same name
247:                    if (valves[i] == this ) {
248:                        break;
249:                    }
250:                    if (valves[i] != null
251:                            && valves[i].getClass() == this .getClass()) {
252:                        log.debug("Duplicate " + valves[i] + " " + this  + " "
253:                                + container);
254:                        seq++;
255:                    }
256:                }
257:                String ext = "";
258:                if (seq > 0) {
259:                    ext = ",seq=" + seq;
260:                }
261:
262:                ObjectName objectName = new ObjectName(domain
263:                        + ":type=Valve,name=" + className + ext + parentName);
264:                log.debug("valve objectname = " + objectName);
265:                return objectName;
266:            }
267:
268:            // -------------------- JMX data  --------------------
269:
270:            public ObjectName getContainerName() {
271:                if (container == null)
272:                    return null;
273:                return ((ContainerBase) container).getJmxName();
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.