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


001:        //========================================================================
002:        //$Id: Jetty6PluginServer.java 860 2006-08-31 22:23:51Z janb $
003:        //Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
004:        //------------------------------------------------------------------------
005:        //Licensed under the Apache License, Version 2.0 (the "License");
006:        //you may not use this file except in compliance with the License.
007:        //You may obtain a copy of the License at 
008:        //http://www.apache.org/licenses/LICENSE-2.0
009:        //Unless required by applicable law or agreed to in writing, software
010:        //distributed under the License is distributed on an "AS IS" BASIS,
011:        //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        //See the License for the specific language governing permissions and
013:        //limitations under the License.
014:        //========================================================================
015:
016:        package org.mortbay.jetty.plugin;
017:
018:        import org.mortbay.jetty.Connector;
019:        import org.mortbay.jetty.Handler;
020:        import org.mortbay.jetty.RequestLog;
021:        import org.mortbay.jetty.Server;
022:        import org.mortbay.jetty.handler.ContextHandlerCollection;
023:        import org.mortbay.jetty.handler.DefaultHandler;
024:        import org.mortbay.jetty.handler.HandlerCollection;
025:        import org.mortbay.jetty.handler.RequestLogHandler;
026:        import org.mortbay.jetty.nio.SelectChannelConnector;
027:        import org.mortbay.jetty.plugin.util.JettyPluginServer;
028:        import org.mortbay.jetty.plugin.util.JettyPluginWebApplication;
029:        import org.mortbay.jetty.plugin.util.PluginLog;
030:        import org.mortbay.jetty.security.UserRealm;
031:        import org.mortbay.resource.Resource;
032:
033:        /**
034:         * Jetty6PluginServer
035:         * 
036:         * Jetty6 version of a wrapper for the Server class.
037:         * 
038:         */
039:        public class Jetty6PluginServer implements  JettyPluginServer {
040:            public static int DEFAULT_PORT = 8080;
041:            public static int DEFAULT_MAX_IDLE_TIME = 30000;
042:            private Server server;
043:            private Connector[] connectors;
044:            private UserRealm[] realms;
045:            private ContextHandlerCollection contexts; //the list of ContextHandlers
046:            HandlerCollection handlers; //the list of lists of Handlers
047:            private RequestLogHandler requestLogHandler; //the request log handler
048:            private DefaultHandler defaultHandler; //default handler
049:
050:            private RequestLog requestLog; //the particular request log implementation
051:
052:            /**
053:             * @see org.mortbay.jetty.plugin.util.JettyPluginServer#create()
054:             */
055:            public Jetty6PluginServer() {
056:                this .server = new Server();
057:                this .server.setStopAtShutdown(true);
058:                //make sure Jetty does not use URLConnection caches with the plugin
059:                Resource.setDefaultUseCaches(false);
060:            }
061:
062:            /**
063:             * @see org.mortbay.jetty.plugin.util.JettyPluginServer#setConnectorNames(org.mortbay.jetty.plugin.util.JettyPluginConnector[])
064:             */
065:            public void setConnectors(Object[] connectors) {
066:                this .connectors = new Connector[connectors.length];
067:                for (int i = 0; i < connectors.length; i++) {
068:                    this .connectors[i] = (Connector) connectors[i];
069:                    PluginLog.getLog().debug(
070:                            "Setting Connector: "
071:                                    + this .connectors[i].getClass().getName()
072:                                    + " on port "
073:                                    + this .connectors[i].getPort());
074:                }
075:                this .server.setConnectors(this .connectors);
076:            }
077:
078:            /**
079:             *
080:             * 
081:             * @see org.mortbay.jetty.plugin.util.JettyPluginServer#getConnectors()
082:             */
083:            public Object[] getConnectors() {
084:                return this .connectors;
085:            }
086:
087:            /**
088:             * 
089:             * 
090:             * @see org.mortbay.jetty.plugin.JettyPluginServer#setUserRealms(org.mortbay.jetty.plugin.JettyPluginUserRealm[])
091:             */
092:            public void setUserRealms(Object[] realms) throws Exception {
093:                if (realms == null)
094:                    this .realms = null;
095:                else {
096:                    this .realms = new UserRealm[realms.length];
097:                    for (int i = 0; i < realms.length; i++)
098:                        this .realms[i] = (UserRealm) realms[i];
099:                }
100:
101:                this .server.setUserRealms(this .realms);
102:            }
103:
104:            /**
105:             * 
106:             * @see org.mortbay.jetty.plugin.util.JettyPluginServer#getUserRealms()
107:             */
108:            public Object[] getUserRealms() {
109:                return this .realms;
110:            }
111:
112:            public void setRequestLog(Object requestLog) {
113:                this .requestLog = (RequestLog) requestLog;
114:            }
115:
116:            public Object getRequestLog() {
117:                return this .requestLog;
118:            }
119:
120:            /**
121:             * @see org.mortbay.jetty.plugin.util.JettyPluginServer#start()
122:             */
123:            public void start() throws Exception {
124:                PluginLog.getLog().info(
125:                        "Starting jetty "
126:                                + this .server.getClass().getPackage()
127:                                        .getImplementationVersion() + " ...");
128:                this .server.start();
129:            }
130:
131:            /**
132:             * @see org.mortbay.jetty.plugin.util.Proxy#getProxiedObject()
133:             */
134:            public Object getProxiedObject() {
135:                return this .server;
136:            }
137:
138:            /**
139:             * @see org.mortbay.jetty.plugin.util.JettyPluginServer#addWebApplication(java.lang.Object)
140:             */
141:            public void addWebApplication(JettyPluginWebApplication webapp)
142:                    throws Exception {
143:                contexts.addHandler((Handler) webapp.getProxiedObject());
144:            }
145:
146:            /**
147:             * Set up the handler structure to receive a webapp.
148:             * Also put in a DefaultHandler so we get a nice page
149:             * than a 404 if we hit the root and the webapp's
150:             * context isn't at root.
151:             * @throws Exception
152:             */
153:            public void configureHandlers() throws Exception {
154:                this .defaultHandler = new DefaultHandler();
155:                this .requestLogHandler = new RequestLogHandler();
156:                if (this .requestLog != null)
157:                    this .requestLogHandler.setRequestLog(this .requestLog);
158:
159:                this .contexts = (ContextHandlerCollection) server
160:                        .getChildHandlerByClass(ContextHandlerCollection.class);
161:                if (this .contexts == null) {
162:                    this .contexts = new ContextHandlerCollection();
163:                    this .handlers = (HandlerCollection) server
164:                            .getChildHandlerByClass(HandlerCollection.class);
165:                    if (this .handlers == null) {
166:                        this .handlers = new HandlerCollection();
167:                        this .server.setHandler(handlers);
168:                        this .handlers.setHandlers(new Handler[] {
169:                                this .contexts, this .defaultHandler,
170:                                this .requestLogHandler });
171:                    } else {
172:                        this .handlers.addHandler(this .contexts);
173:                    }
174:                }
175:            }
176:
177:            /**
178:             * @see org.mortbay.jetty.plugin.JettyPluginServer#createDefaultConnector()
179:             */
180:            public Object createDefaultConnector(String portnum)
181:                    throws Exception {
182:                SelectChannelConnector connector = new SelectChannelConnector();
183:                connector = new SelectChannelConnector();
184:                int port = ((portnum == null || portnum.equals("")) ? DEFAULT_PORT
185:                        : Integer.parseInt(portnum.trim()));
186:                connector.setPort(port);
187:                connector.setMaxIdleTime(DEFAULT_MAX_IDLE_TIME);
188:
189:                return connector;
190:            }
191:
192:            /**
193:             * @see org.mortbay.jetty.plugin.util.JettyPluginServer#createWebApplication()
194:             */
195:            public JettyPluginWebApplication createWebApplication()
196:                    throws Exception {
197:                return new Jetty6PluginWebApplication();
198:            }
199:
200:            public void join() throws Exception {
201:                this.server.getThreadPool().join();
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.