Source Code Cross Referenced for JettyDecorator.java in  » J2EE » wicket » nl » openedge » util » 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 » J2EE » wicket » nl.openedge.util.jetty 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: JettyDecorator.java 461192 2006-06-28 08:37:16 +0200 (Wed, 28 Jun 2006)
003:         * ehillenius $ $Revision: 464023 $ $Date: 2006-06-28 08:37:16 +0200 (Wed, 28 Jun
004:         * 2006) $
005:         * 
006:         * ====================================================================
007:         * Copyright (c) 2003, Open Edge B.V. All rights reserved. Redistribution and
008:         * use in source and binary forms, with or without modification, are permitted
009:         * provided that the following conditions are met: Redistributions of source
010:         * code must retain the above copyright notice, this list of conditions and the
011:         * following disclaimer. Redistributions in binary form must reproduce the above
012:         * copyright notice, this list of conditions and the following disclaimer in the
013:         * documentation and/or other materials provided with the distribution. Neither
014:         * the name of OpenEdge B.V. nor the names of its contributors may be used to
015:         * endorse or promote products derived from this software without specific prior
016:         * written permission.
017:         * 
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028:         * POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package nl.openedge.util.jetty;
031:
032:        import junit.framework.Test;
033:
034:        import org.apache.commons.logging.Log;
035:        import org.apache.commons.logging.LogFactory;
036:        import org.mortbay.jetty.Connector;
037:        import org.mortbay.jetty.Server;
038:        import org.mortbay.jetty.nio.SelectChannelConnector;
039:        import org.mortbay.jetty.webapp.WebAppContext;
040:
041:        /**
042:         * JUnit decorator for starting and stopping a local instance Jetty for usage
043:         * with test cases.
044:         * <p>
045:         * It uses property 'jettyConfig' to load the - mandatory - Jetty configuration
046:         * document. Eg '/jetty-test-config.xml' is loaded from the classpath root (so
047:         * providing the configuration document in the root of the test classes folder
048:         * will suffice) but 'file://c:/mydir/myconfig.xml' should work as well. If
049:         * property 'jettyConfig' is not provided (default == null), the properties
050:         * 'port', 'webappContextRoot' and 'contextPath' are used to start a Jetty
051:         * instance.
052:         * </p>
053:         * <p>
054:         * Property useJettyPlus (default == false) is used to decide whether JettyPlus
055:         * should be used, or just the basic version of Jetty. JettyPlus provides
056:         * support for JNDI, datasources, transactions etc.
057:         * </p>
058:         * <p>
059:         * Usage:
060:         * 
061:         * <pre>
062:         *           
063:         *            ...
064:         *              public static Test suite() 
065:         *              {
066:         *           	    TestSuite suite = new TestSuite();
067:         *           	    suite.addTest(new JettyDecoratorWithArgsTest(&quot;testPing&quot;));
068:         *           	    JettyDecorator deco = new JettyDecorator(suite);
069:         *           	    deco.setPort(8098);
070:         *           	    deco.setWebappContextRoot(&quot;src/webapp&quot;);
071:         *           	    deco.setContextPath(&quot;/test&quot;);
072:         *           	    deco.setUseJettyPlus(false);
073:         *           	    return deco;
074:         *              }
075:         *            ...
076:         *            
077:         * </pre>
078:         * 
079:         * Jetty will be started before the tests are actually run, and will be stopped
080:         * afterwards.
081:         * </p>
082:         * 
083:         * @author Eelco Hillenius
084:         */
085:        public class JettyDecorator extends AbstractJettyDecorator {
086:            /** logger. */
087:            private static final Log log = LogFactory
088:                    .getLog(JettyDecorator.class);
089:
090:            /** instance of jetty server. */
091:            private Server server = null;
092:
093:            /**
094:             * construct with test.
095:             * 
096:             * @param test
097:             *            test case
098:             */
099:            public JettyDecorator(final Test test) {
100:                super (test);
101:            }
102:
103:            /**
104:             * Start Jetty.
105:             * 
106:             * @throws Exception
107:             * @see junit.extensions.TestSetup#setUp()
108:             */
109:            public void setUp() throws Exception {
110:                server = new Server();
111:                SelectChannelConnector connector = new SelectChannelConnector();
112:                connector.setPort(getPort());
113:                server.setConnectors(new Connector[] { connector });
114:
115:                WebAppContext web = new WebAppContext();
116:                web.setContextPath(getContextPath());
117:                web.setWar(getWebappContextRoot());
118:                server.addHandler(web);
119:
120:                log.info("Starting Jetty");
121:                server.start();
122:                log.info("Jetty started");
123:            }
124:
125:            /**
126:             * Stop Jetty.
127:             * 
128:             * @see junit.extensions.TestSetup#tearDown()
129:             */
130:            public void tearDown() {
131:                log.info("Stopping Jetty");
132:                try {
133:                    server.stop();
134:                    log.info("Jetty stopped");
135:                } catch (Exception e) {
136:                    log.error(e.getMessage(), e);
137:                }
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.