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


001:        //========================================================================
002:        //$Id:  $
003:        //JBoss Jetty Integration
004:        //------------------------------------------------------------------------
005:        //Licensed under LGPL.
006:        //See license terms at http://www.gnu.org/licenses/lgpl.html
007:        //========================================================================
008:        package org.jboss.jetty;
009:
010:        import java.lang.reflect.Method;
011:
012:        import javax.management.MBeanRegistration;
013:        import javax.management.MBeanServer;
014:        import javax.management.ObjectName;
015:
016:        import org.jboss.deployment.DeploymentException;
017:        import org.jboss.deployment.DeploymentInfo;
018:        import org.jboss.deployment.SubDeployerExt;
019:        import org.jboss.mx.util.MBeanProxyExt;
020:        import org.jboss.system.ServiceControllerMBean;
021:        import org.jboss.web.AbstractWebContainer;
022:        import org.jboss.web.AbstractWebDeployer;
023:        import org.jboss.web.WebApplication;
024:        import org.w3c.dom.Element;
025:
026:        //------------------------------------------------------------------------------
027:        /**
028:         * JettyService
029:         * A service to launch jetty as the webserver for JBoss.
030:         *
031:         *
032:         * @jmx:mbean name="jboss.jetty:service=Jetty"
033:         *            extends="org.jboss.web.AbstractWebContainerMBean"
034:         *
035:         * @todo convert to use JMXDoclet...
036:         * 
037:         */
038:
039:        public class JettyService extends AbstractWebContainer implements 
040:                JettyServiceMBean, MBeanRegistration {
041:            public static final String NAME = "Jetty";
042:
043:            protected MBeanServer _server = null;
044:            protected Jetty _jetty = null;
045:            protected Element _jettyConfig = null;
046:            protected boolean _supportJSR77;
047:            protected String _webDefaultResource;
048:            protected SubDeployerExt subDeployerProxy = null;
049:
050:            /**
051:             * ConfigurationData
052:             *
053:             * Holds info that the jboss API sets on the
054:             * AbstractWebContainer but is needed by the
055:             * AbstractWebDeployer.
056:             */
057:            public static class ConfigurationData {
058:                private boolean _loaderCompliance;
059:                private boolean _unpackWars;
060:                private boolean _lenientEjbLink;
061:                private String _subjectAttributeName;
062:                private String _defaultSecurityDomain;
063:                private boolean _acceptNonWarDirs;
064:                private String _webDefaultResource;
065:                private boolean _supportJSR77;
066:                private String _mbeanDomain;
067:
068:                /**
069:                 * @return the _webDefaultResource
070:                 */
071:                public String getWebDefaultResource() {
072:                    return _webDefaultResource;
073:                }
074:
075:                /**
076:                 * @param defaultResource the _webDefaultResource to set
077:                 */
078:                public void setWebDefaultResource(String defaultResource) {
079:                    _webDefaultResource = defaultResource;
080:                }
081:
082:                public void setJava2ClassLoadingCompliance(
083:                        boolean loaderCompliance) {
084:                    _loaderCompliance = loaderCompliance;
085:                }
086:
087:                public boolean getJava2ClassLoadingCompliance() {
088:                    return _loaderCompliance;
089:                }
090:
091:                public boolean getUnpackWars() {
092:                    return _unpackWars;
093:                }
094:
095:                public void setUnpackWars(boolean unpackWars) {
096:                    _unpackWars = unpackWars;
097:                }
098:
099:                public void setLenientEjbLink(boolean lenientEjbLink) {
100:                    _lenientEjbLink = lenientEjbLink;
101:                }
102:
103:                public boolean getLenientEjbLink() {
104:                    return _lenientEjbLink;
105:                }
106:
107:                public String getSubjectAttributeName() {
108:                    return _subjectAttributeName;
109:                }
110:
111:                /**
112:                 * @jmx:managed-attribute
113:                 */
114:                public void setSubjectAttributeName(String subjectAttributeName) {
115:                    _subjectAttributeName = subjectAttributeName;
116:                }
117:
118:                /**
119:                 * @return the _defaultSecurityDomain
120:                 */
121:                public String getDefaultSecurityDomain() {
122:                    return _defaultSecurityDomain;
123:                }
124:
125:                /**
126:                 * @param securityDomain the _defaultSecurityDomain to set
127:                 */
128:                public void setDefaultSecurityDomain(String securityDomain) {
129:                    _defaultSecurityDomain = securityDomain;
130:                }
131:
132:                /**
133:                 * @return the _acceptNonWarDirs
134:                 */
135:                public boolean getAcceptNonWarDirs() {
136:                    return _acceptNonWarDirs;
137:                }
138:
139:                /**
140:                 * @param nonWarDirs the _acceptNonWarDirs to set
141:                 */
142:                public void setAcceptNonWarDirs(boolean nonWarDirs) {
143:                    _acceptNonWarDirs = nonWarDirs;
144:                }
145:
146:                /**
147:                 * @return the _supportJSR77
148:                 */
149:                public boolean getSupportJSR77() {
150:                    return _supportJSR77;
151:                }
152:
153:                /**
154:                 * @param _supportjsr77 the _supportJSR77 to set
155:                 */
156:                public void setSupportJSR77(boolean _supportjsr77) {
157:                    _supportJSR77 = _supportjsr77;
158:                }
159:
160:                /**
161:                 * @return the _mbeanDomain
162:                 */
163:                public String getMBeanDomain() {
164:                    return _mbeanDomain;
165:                }
166:
167:                /**
168:                 * @param domain the _mbeanDomain to set
169:                 */
170:                public void setMBeanDomain(String domain) {
171:                    _mbeanDomain = domain;
172:                }
173:            }
174:
175:            /** 
176:             * Constructor
177:             */
178:            public JettyService() {
179:                super ();
180:                _jetty = new Jetty(this );
181:            }
182:
183:            /** 
184:             * Listen for our registration as an mbean and remember our name.
185:             * @see org.jboss.system.ServiceMBeanSupport#preRegister(javax.management.MBeanServer, javax.management.ObjectName)
186:             */
187:            public ObjectName preRegister(MBeanServer server, ObjectName name)
188:                    throws Exception {
189:                super .preRegister(server, name);
190:                name = getObjectName(server, name);
191:                _server = server;
192:                return name;
193:            }
194:
195:            /** 
196:             * Listen for post-mbean registration and set up the jetty
197:             * mbean infrastructure so it can generate mbeans according
198:             * to the elements contained in the <configuration> element
199:             * of the jboss-service.xml file.
200:             * @see org.jboss.system.ServiceMBeanSupport#postRegister(java.lang.Boolean)
201:             */
202:            public void postRegister(Boolean done) {
203:                super .postRegister(done);
204:                try {
205:                    log.debug("Setting up mbeanlistener on Jetty");
206:                    _jetty.getContainer().addEventListener(
207:                            new JBossMBeanContainer(_server));
208:                } catch (Throwable e) {
209:                    log.error("could not create MBean peers", e);
210:                }
211:            }
212:
213:            /** 
214:             * @see org.jboss.system.ServiceMBeanSupport#getName()
215:             */
216:            public String getName() {
217:                return NAME;
218:            }
219:
220:            /** 
221:             * @see org.jboss.deployment.SubDeployerSupport#createService()
222:             */
223:            public void createService() throws Exception {
224:                super .createService();
225:                if (_jettyConfig != null)
226:                    _jetty.setConfigurationElement(_jettyConfig);
227:            }
228:
229:            /** 
230:             * Start up the jetty service. Also, as we need to be able
231:             * to have interceptors injected into us to support jboss.ws:service=WebService,
232:             * we need to create a proxy to ourselves and register that proxy with the
233:             * mainDeployer.
234:             * See <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=SubDeployerInterceptorSupport">SubDeployerInterceptorSupport</a>
235:             * @see org.jboss.web.AbstractWebContainer#startService()
236:             */
237:            public void startService() throws Exception {
238:                //do what AbstractWebContainer.startService() would have done
239:                serviceController = (ServiceControllerMBean) MBeanProxyExt
240:                        .create(ServiceControllerMBean.class,
241:                                ServiceControllerMBean.OBJECT_NAME, server);
242:
243:                //instead of calling mainDeployer.addDeployer(this) as SubDeployerSupport super class does,
244:                //we register instead a proxy to oursevles so we can support dynamic addition of interceptors
245:                subDeployerProxy = (SubDeployerExt) MBeanProxyExt.create(
246:                        SubDeployerExt.class, super .getServiceName(), super 
247:                                .getServer());
248:                mainDeployer.addDeployer(subDeployerProxy);
249:                _jetty.start();
250:            }
251:
252:            public void stopService() throws Exception {
253:                mainDeployer.removeDeployer(subDeployerProxy);
254:                _jetty.stop();
255:            }
256:
257:            public void destroyService() throws Exception {
258:                super .destroyService();
259:                _jetty.stop();
260:                _jetty = null;
261:            }
262:
263:            /**
264:             * @jmx:managed-attribute
265:             */
266:            public boolean getSupportJSR77() {
267:                return _supportJSR77;
268:            }
269:
270:            /**
271:             * @jmx:managed-attribute
272:             */
273:            public void setSupportJSR77(boolean supportJSR77) {
274:                if (log.isDebugEnabled())
275:                    log.debug("set SupportJSR77 to " + supportJSR77);
276:
277:                _supportJSR77 = supportJSR77;
278:            }
279:
280:            /**
281:             * Get the custom webdefault.xml file.
282:             * @jmx:managed-attribute
283:             */
284:            public String getWebDefaultResource() {
285:                return _webDefaultResource;
286:            }
287:
288:            /**
289:             * Set a custom webdefault.xml file.
290:             * @jmx:managed-attribute
291:             */
292:            public void setWebDefaultResource(String webDefaultResource) {
293:                if (log.isDebugEnabled())
294:                    log
295:                            .debug("set WebDefaultResource to "
296:                                    + webDefaultResource);
297:
298:                _webDefaultResource = webDefaultResource;
299:            }
300:
301:            /**
302:             * Get the extended Jetty configuration XML fragment
303:             * 
304:             * @jmx:managed-attribute
305:             * @return Jetty XML fragment embedded in jboss-service.xml
306:             */
307:
308:            public Element getConfigurationElement() {
309:                return _jettyConfig;
310:            }
311:
312:            /**
313:             * Configure Jetty
314:             * 
315:             * @param configElement XML fragment from jboss-service.xml
316:             * @jmx:managed-attribute
317:             */
318:            public void setConfigurationElement(Element configElement) {
319:                log.debug("Saving Configuration to xml fragment");
320:                this ._jettyConfig = configElement;
321:            }
322:
323:            /**
324:             * Old deployment method from AbstractWebContainer.
325:             * 
326:             * TODO remove this?
327:             * @param webApp
328:             * @param warUrl
329:             * @param parser
330:             * @throws DeploymentException
331:             */
332:            public void performDeploy(WebApplication webApp, String warUrl,
333:                    WebDescriptorParser parser) throws DeploymentException {
334:                //TODO: backwards compatibility?
335:                throw new UnsupportedOperationException(
336:                        "Backward compatibility not implemented");
337:            }
338:
339:            /**
340:             * Old undeploy method from AbstractWebContainer.
341:             * 
342:             * TODO remove?
343:             * @param warUrl
344:             * @throws DeploymentException
345:             */
346:            public void performUndeploy(String warUrl)
347:                    throws DeploymentException {
348:                //TODO backwards compatibility?
349:                throw new UnsupportedOperationException(
350:                        "Backward compatibility not implemented");
351:            }
352:
353:            /** 
354:             * @see org.jboss.web.AbstractWebContainer#getDeployer(org.jboss.deployment.DeploymentInfo)
355:             */
356:            public AbstractWebDeployer getDeployer(DeploymentInfo di)
357:                    throws Exception {
358:                JettyDeployer deployer = new JettyDeployer(_jetty, di);
359:                ConfigurationData configData = new ConfigurationData();
360:                configData.setMBeanDomain("jboss.jetty");
361:                configData.setAcceptNonWarDirs(getAcceptNonWarDirs());
362:                configData
363:                        .setJava2ClassLoadingCompliance(getJava2ClassLoadingCompliance());
364:                configData.setLenientEjbLink(getLenientEjbLink());
365:                configData.setSubjectAttributeName(getSubjectAttributeName());
366:                configData.setSupportJSR77(getSupportJSR77());
367:                configData.setUnpackWars(getUnpackWars());
368:                configData.setWebDefaultResource(getWebDefaultResource());
369:                //defaultSecurityDomain was added at a certain point, so do it
370:                //this way so we have backwards compatibility
371:                try {
372:                    Method method = AbstractWebContainer.class
373:                            .getDeclaredMethod("getDefaultSecurityDomain",
374:                                    new Class[0]);
375:                    String defaultSecurityDomain = (String) method.invoke(
376:                            JettyService.this , new Object[0]);
377:                    configData.setDefaultSecurityDomain(defaultSecurityDomain);
378:                } catch (Exception e) {
379:                    // ignore - it means the currently executing version of jboss
380:                    // does not support this method
381:                    log
382:                            .info("Getter/setter for DefaultSecurityDomain not available in this version of JBoss");
383:                }
384:                deployer.setServer(_server);
385:                deployer.init(configData);
386:                return deployer;
387:            }
388:
389:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.