Source Code Cross Referenced for ConnectorGBean.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » tomcat » connector » 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 geronimo » plugins » org.apache.geronimo.tomcat.connector 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         *
010:         *  http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:        package org.apache.geronimo.tomcat.connector;
020:
021:        import java.util.HashMap;
022:        import java.util.Map;
023:
024:        import javax.management.j2ee.statistics.Stats;
025:
026:        import org.apache.catalina.LifecycleException;
027:        import org.apache.catalina.connector.Connector;
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.apache.geronimo.gbean.GBeanInfo;
031:        import org.apache.geronimo.gbean.GBeanInfoBuilder;
032:        import org.apache.geronimo.gbean.GBeanLifecycle;
033:        import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
034:        import org.apache.geronimo.management.geronimo.NetworkConnector;
035:        import org.apache.geronimo.system.serverinfo.ServerInfo;
036:        import org.apache.geronimo.tomcat.BaseGBean;
037:        import org.apache.geronimo.tomcat.ObjectRetriever;
038:        import org.apache.geronimo.tomcat.TomcatContainer;
039:
040:        public abstract class ConnectorGBean extends BaseGBean implements 
041:                CommonProtocol, GBeanLifecycle, ObjectRetriever,
042:                TomcatWebConnector {
043:
044:            private static final Log log = LogFactory
045:                    .getLog(ConnectorGBean.class);
046:
047:            public final static String CONNECTOR_CONTAINER_REFERENCE = "TomcatContainer";
048:
049:            protected final ServerInfo serverInfo;
050:
051:            protected final Connector connector;
052:
053:            private final TomcatContainer container;
054:
055:            private String name;
056:
057:            public ConnectorGBean(String name, Map initParams,
058:                    String tomcatProtocol, TomcatContainer container,
059:                    ServerInfo serverInfo) throws Exception {
060:
061:                //Relief for new Tomcat-only parameters that may come in the future
062:                if (initParams == null) {
063:                    initParams = new HashMap();
064:                }
065:
066:                // Do we really need this?? For Tomcat I don't think so...
067:                // validateProtocol(protocol);
068:
069:                if (name == null) {
070:                    throw new IllegalArgumentException("name cannot be null.");
071:                }
072:
073:                if (container == null) {
074:                    throw new IllegalArgumentException(
075:                            "container cannot be null.");
076:                }
077:
078:                if (serverInfo == null) {
079:                    throw new IllegalArgumentException(
080:                            "serverInfo cannot be null.");
081:                }
082:
083:                tomcatProtocol = validateProtocol(tomcatProtocol);
084:
085:                this .name = name;
086:                this .container = container;
087:                this .serverInfo = serverInfo;
088:
089:                // Create the Connector object
090:                connector = new Connector(tomcatProtocol);
091:
092:                setParameters(connector, initParams);
093:
094:            }
095:
096:            public void doFail() {
097:                log.warn(name + " connector failed");
098:                doStop();
099:            }
100:
101:            public void doStart() throws LifecycleException {
102:                container.addConnector(connector);
103:                connector.start();
104:                if (log.isDebugEnabled())
105:                    log.debug(name + " connector started");
106:            }
107:
108:            public void doStop() {
109:                try {
110:                    connector.stop();
111:                } catch (LifecycleException e) {
112:                    log.error(e);
113:                }
114:
115:                container.removeConnector(connector);
116:
117:                if (log.isDebugEnabled())
118:                    log.debug(name + " connector stopped");
119:            }
120:
121:            /**
122:             * Ensures that this implementation can handle the requested protocol.
123:             * @param protocol
124:             */
125:            protected String validateProtocol(String tomcatProtocol) {
126:                return tomcatProtocol;
127:            }
128:
129:            public abstract int getDefaultPort();
130:
131:            public abstract String getGeronimoProtocol();
132:
133:            public abstract Stats getStats();
134:
135:            public abstract void resetStats();
136:
137:            public Object getInternalObject() {
138:                return connector;
139:            }
140:
141:            public String getName() {
142:                return name;
143:            }
144:
145:            public void setAllowTrace(boolean allow) {
146:                connector.setAllowTrace(allow);
147:            }
148:
149:            public boolean getAllowTrace() {
150:                return connector.getAllowTrace();
151:            }
152:
153:            public void setEmptySessionPath(boolean emptySessionPath) {
154:                connector.setEmptySessionPath(emptySessionPath);
155:            }
156:
157:            public void setEnableLookups(boolean enabled) {
158:                connector.setEnableLookups(enabled);
159:            }
160:
161:            public int getMaxPostSize() {
162:                int value = connector.getMaxPostSize();
163:                return value == 0 ? 2097152 : value;
164:            }
165:
166:            public void setMaxPostSize(int bytes) {
167:                connector.setMaxPostSize(bytes);
168:            }
169:
170:            public String getProtocol() {
171:                //This is totally wrong on the Geronimo side and needs to be re-thought out.
172:                //This was done to shoe horn in gerneric Geronimo protocols which should have no relation
173:                //to the container's scheme.  This whole idea needs rework.
174:                return getGeronimoProtocol();
175:            }
176:
177:            public String getTomcatProtocol() {
178:                return connector.getProtocol();
179:            }
180:
181:            public String getProxyName() {
182:                return connector.getProxyName();
183:            }
184:
185:            public int getProxyPort() {
186:                return connector.getProxyPort();
187:            }
188:
189:            public int getRedirectPort() {
190:                return connector.getRedirectPort();
191:            }
192:
193:            public String getScheme() {
194:                return connector.getScheme();
195:            }
196:
197:            public boolean getSecure() {
198:                return connector.getSecure();
199:            }
200:
201:            public String getUriEncoding() {
202:                return connector.getURIEncoding();
203:            }
204:
205:            public boolean getUseBodyEncodingForURI() {
206:                return connector.getUseBodyEncodingForURI();
207:            }
208:
209:            public boolean getUseIPVHosts() {
210:                return connector.getUseIPVHosts();
211:            }
212:
213:            public void setMaxSavePostSize(int maxSavePostSize) {
214:                connector.setMaxSavePostSize(maxSavePostSize);
215:            }
216:
217:            public void setProxyName(String proxyName) {
218:                if (proxyName.equals(""))
219:                    proxyName = null;
220:                connector.setProxyName(proxyName);
221:            }
222:
223:            public void setProxyPort(int port) {
224:                connector.setProxyPort(port);
225:            }
226:
227:            public void setRedirectPort(int port) {
228:                connector.setRedirectPort(port);
229:            }
230:
231:            public void setScheme(String scheme) {
232:                connector.setScheme(scheme);
233:            }
234:
235:            public void setSecure(boolean secure) {
236:                connector.setSecure(secure);
237:            }
238:
239:            public boolean getSslEnabled() {
240:                Object value = connector.getAttribute("SSLEnabled");
241:                return value == null ? false : new Boolean(value.toString())
242:                        .booleanValue();
243:            }
244:
245:            public void setSslEnabled(boolean sslEnabled) {
246:                connector.setAttribute("SSLEnabled", sslEnabled);
247:            }
248:
249:            public void setUriEncoding(String uriEncoding) {
250:                connector.setURIEncoding(uriEncoding);
251:            }
252:
253:            public void setUseBodyEncodingForURI(boolean useBodyEncodingForURI) {
254:                connector.setUseBodyEncodingForURI(useBodyEncodingForURI);
255:            }
256:
257:            public void setUseIPVHosts(boolean useIPVHosts) {
258:                connector.setUseIPVHosts(useIPVHosts);
259:            }
260:
261:            public void setXpoweredBy(boolean xpoweredBy) {
262:                connector.setXpoweredBy(xpoweredBy);
263:            }
264:
265:            public boolean getEnableLookups() {
266:                return connector.getEnableLookups();
267:            }
268:
269:            public int getMaxSavePostSize() {
270:                int value = connector.getMaxSavePostSize();
271:                return value == 0 ? 4096 : value;
272:            }
273:
274:            public boolean getEmptySessionPath() {
275:                return connector.getEmptySessionPath();
276:            }
277:
278:            public boolean getXpoweredBy() {
279:                return connector.getXpoweredBy();
280:            }
281:
282:            public static final GBeanInfo GBEAN_INFO;
283:
284:            static {
285:                GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
286:                        "Tomcat Connector", ConnectorGBean.class);
287:
288:                infoFactory.addAttribute("name", String.class, true);
289:                infoFactory.addAttribute("initParams", Map.class, true);
290:                infoFactory.addAttribute("protocol", String.class, true);
291:                infoFactory.addReference(CONNECTOR_CONTAINER_REFERENCE,
292:                        TomcatContainer.class, NameFactory.GERONIMO_SERVICE);
293:                infoFactory.addReference("ServerInfo", ServerInfo.class,
294:                        "GBean");
295:                infoFactory.addInterface(ObjectRetriever.class);
296:                infoFactory.addInterface(TomcatWebConnector.class);
297:                infoFactory.addInterface(CommonProtocol.class,
298:
299:                new String[] { "allowTrace", "emptySessionPath",
300:                        "enableLookups", "maxPostSize", "maxSavePostSize",
301:                        "protocol", "tomcatProtocol", "proxyName", "proxyPort",
302:                        "redirectPort", "scheme", "secure", "sslEnabled",
303:                        "uriEncoding", "useBodyEncodingForURI", "useIPVHosts",
304:                        "xpoweredBy" },
305:
306:                new String[] { "allowTrace", "emptySessionPath",
307:                        "enableLookups", "maxPostSize", "maxSavePostSize",
308:                        "protocol", "tomcatProtocol", "proxyName", "proxyPort",
309:                        "redirectPort", "scheme", "secure", "sslEnabled",
310:                        "uriEncoding", "useBodyEncodingForURI", "useIPVHosts",
311:                        "xpoweredBy" });
312:                infoFactory.setConstructor(new String[] { "name", "initParams",
313:                        "protocol", "TomcatContainer", "ServerInfo" });
314:                GBEAN_INFO = infoFactory.getBeanInfo();
315:            }
316:
317:            public static GBeanInfo getGBeanInfo() {
318:                return GBEAN_INFO;
319:            }
320:
321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.