Source Code Cross Referenced for AJP13ConnectorGBean.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.net.InetAddress;
022:        import java.net.InetSocketAddress;
023:        import java.net.UnknownHostException;
024:        import java.util.Map;
025:
026:        import javax.management.j2ee.statistics.Stats;
027:
028:        import org.apache.geronimo.gbean.GBeanInfo;
029:        import org.apache.geronimo.gbean.GBeanInfoBuilder;
030:        import org.apache.geronimo.management.StatisticsProvider;
031:        import org.apache.geronimo.management.geronimo.WebManager;
032:        import org.apache.geronimo.system.serverinfo.ServerInfo;
033:        import org.apache.geronimo.tomcat.TomcatContainer;
034:        import org.apache.geronimo.tomcat.stats.ConnectorStats;
035:
036:        public class AJP13ConnectorGBean extends ConnectorGBean implements 
037:                Ajp13Protocol, StatisticsProvider {
038:
039:            // JSR77 stats
040:            private ConnectorStats connStatsProvider = new ConnectorStats();
041:
042:            private boolean reset = true;
043:
044:            protected String connectHost;
045:
046:            public AJP13ConnectorGBean(String name, Map initParams,
047:                    String host, int port, TomcatContainer container,
048:                    ServerInfo serverInfo) throws Exception {
049:                super (name, initParams, "AJP/1.3", container, serverInfo);
050:
051:                // Default the host to listen on all address is one was not specified
052:                if (host == null) {
053:                    host = "0.0.0.0";
054:                }
055:
056:                // Must have a port
057:                if (port == 0) {
058:                    throw new IllegalArgumentException("Must declare a port.");
059:                }
060:
061:                connector.setAttribute("address", host);
062:                connector.setPort(port);
063:
064:            }
065:
066:            public String getGeronimoProtocol() {
067:                return WebManager.PROTOCOL_AJP;
068:            }
069:
070:            public String getConnectUrl() {
071:                if (connectHost == null) {
072:                    String host = getAddress();
073:                    if (host == null || host.equals("0.0.0.0")
074:                            || host.equals("0:0:0:0:0:0:0:1")) {
075:                        InetAddress address = null;
076:                        try {
077:                            address = InetAddress.getLocalHost();
078:                        } catch (UnknownHostException e) {
079:                            host = "unknown-host";
080:                        }
081:                        if (address != null) {
082:                            host = address.getCanonicalHostName();
083:                            if (host == null || host.equals("")) {
084:                                host = address.getHostAddress();
085:                            }
086:                        }
087:                    }
088:                    // this host address could be in IPv6 format, 
089:                    // which means we need to wrap it in brackets
090:                    if (host.indexOf(":") >= 0) {
091:                        host = "[" + host + "]";
092:                    }
093:                    connectHost = host;
094:                }
095:                return getScheme().toLowerCase()
096:                        + "://"
097:                        + connectHost
098:                        + (getPort() == getDefaultPort() ? "" : ":" + getPort());
099:            }
100:
101:            public int getDefaultPort() {
102:                return -1;
103:            }
104:
105:            public InetSocketAddress getListenAddress() {
106:                return new InetSocketAddress(getHost(), getPort());
107:            }
108:
109:            public String getAddress() {
110:                Object value = connector.getAttribute("address");
111:                if (value == null) {
112:                    return "0.0.0.0";
113:                } else if (value instanceof  InetAddress) {
114:                    return ((InetAddress) value).getHostAddress();
115:                } else
116:                    return value.toString();
117:            }
118:
119:            public int getBacklog() {
120:                Object value = connector.getAttribute("backlog");
121:                return value == null ? 10 : Integer.parseInt(value.toString());
122:            }
123:
124:            public int getBufferSize() {
125:                Object value = connector.getAttribute("bufferSize");
126:                return value == null ? 2048 : Integer
127:                        .parseInt(value.toString());
128:            }
129:
130:            public int getConnectionTimeout() {
131:                Object value = connector.getAttribute("connectionTimeout");
132:                return value == null ? org.apache.coyote.ajp.Constants.DEFAULT_CONNECTION_TIMEOUT
133:                        : Integer.parseInt(value.toString());
134:            }
135:
136:            public String getExecutor() {
137:                return (String) connector.getAttribute("Executor");
138:            }
139:
140:            public String getHost() {
141:                return getAddress();
142:            }
143:
144:            public int getKeepAliveTimeout() {
145:                Object value = connector.getAttribute("keepAliveTimeout");
146:                return value == null ? getConnectionTimeout() : Integer
147:                        .parseInt(value.toString());
148:            }
149:
150:            public int getMaxThreads() {
151:                Object value = connector.getAttribute("maxThreads");
152:                return value == null ? 200 : Integer.parseInt(value.toString());
153:            }
154:
155:            public int getMaxSpareThreads() {
156:                Object value = connector.getAttribute("maxSpareThreads");
157:                return value == null ? 100 : Integer.parseInt(value.toString());
158:            }
159:
160:            public int getMinSpareThreads() {
161:                Object value = connector.getAttribute("minSpareThreads");
162:                return value == null ? 10 : Integer.parseInt(value.toString());
163:            }
164:
165:            public int getPort() {
166:                return connector.getPort();
167:            }
168:
169:            public boolean getTcpNoDelay() {
170:                Object value = connector.getAttribute("tcpNoDelay");
171:                return value == null ? true : new Boolean(value.toString())
172:                        .booleanValue();
173:            }
174:
175:            public boolean getTomcatAuthentication() {
176:                Object value = connector.getAttribute("tomcatAuthentication");
177:                return value == null ? true : new Boolean(value.toString())
178:                        .booleanValue();
179:            }
180:
181:            public void setAddress(String address) {
182:                connector.setAttribute("address", address);
183:            }
184:
185:            public void setBacklog(int backlog) {
186:                connector.setAttribute("backlog", new Integer(backlog));
187:            }
188:
189:            public void setBufferSize(int bufferSize) {
190:                connector.setAttribute("bufferSize", new Integer(bufferSize));
191:            }
192:
193:            public void setConnectionTimeout(int connectionTimeout) {
194:                connector.setAttribute("connectionTimeout", new Integer(
195:                        connectionTimeout));
196:            }
197:
198:            public void setExecutor(String executor) {
199:                connector.setAttribute("executor", executor);
200:            }
201:
202:            public void setHost(String host) {
203:                setAddress(host);
204:            }
205:
206:            public void setKeepAliveTimeout(int keepAliveTimeout) {
207:                connector.setAttribute("keepAliveTimeout", keepAliveTimeout);
208:            }
209:
210:            public void setMaxThreads(int maxThreads) {
211:                connector.setAttribute("maxThreads", maxThreads);
212:            }
213:
214:            public void setMaxSpareThreads(int maxSpareThreads) {
215:                connector.setAttribute("maxSpareThreads", new Integer(
216:                        maxSpareThreads));
217:            }
218:
219:            public void setMinSpareThreads(int minSpareThreads) {
220:                connector.setAttribute("minSpareThreads", new Integer(
221:                        minSpareThreads));
222:            }
223:
224:            public void setNoCompressionUserAgents(
225:                    String noCompressionUserAgents) {
226:                connector.setAttribute("noCompressionUserAgents",
227:                        noCompressionUserAgents);
228:            }
229:
230:            public void setPort(int port) {
231:                connector.setPort(port);
232:            }
233:
234:            public void setTcpNoDelay(boolean tcpNoDelay) {
235:                connector.setAttribute("tcpNoDelay", new Boolean(tcpNoDelay));
236:            }
237:
238:            public void setTomcatAuthentication(boolean tomcatAuthentication) {
239:                connector.setAttribute("tomcatAuthentication", new Boolean(
240:                        tomcatAuthentication));
241:            }
242:
243:            // Statistics Provider
244:
245:            public boolean isStatisticsProvider() {
246:                return true;
247:            }
248:
249:            public Stats getStats() {
250:                String port = String.valueOf(getPort());
251:                if (reset) {
252:                    reset = false;
253:                    return connStatsProvider.getStats(port);
254:                } else
255:                    return connStatsProvider.updateStats(port);
256:            }
257:
258:            public void resetStats() {
259:                reset = true;
260:            }
261:
262:            public static final GBeanInfo GBEAN_INFO;
263:
264:            static {
265:                GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
266:                        "Tomcat Connector AJP", AJP13ConnectorGBean.class,
267:                        ConnectorGBean.GBEAN_INFO);
268:                infoFactory.addInterface(Ajp13Protocol.class, new String[] {
269:                        //AJP Attributes
270:                        "address", "backlog", "bufferSize",
271:                        "connectionTimeout", "executor", "host",
272:                        "keepAliveTimeout", "maxThreads", "maxSpareThreads",
273:                        "minSpareThreads", "port", "tcpNoDelay",
274:                        "tomcatAuthentication", }, new String[] {
275:                        //AJP Attributes
276:                        "address", "backlog", "bufferSize",
277:                        "connectionTimeout", "executor", "host",
278:                        "keepAliveTimeout", "maxThreads", "maxSpareThreads",
279:                        "minSpareThreads", "port", "tcpNoDelay",
280:                        "tomcatAuthentication", });
281:                infoFactory.setConstructor(new String[] { "name", "initParams",
282:                        "host", "port", "TomcatContainer", "ServerInfo" });
283:                GBEAN_INFO = infoFactory.getBeanInfo();
284:            }
285:
286:            public static GBeanInfo getGBeanInfo() {
287:                return GBEAN_INFO;
288:            }
289:
290:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.