Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Embedded Jetty Runner #28

Merged
merged 7 commits into from
Aug 23, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Features
* [#1](https://github.com/dblock/waffle/pull/1): Adjusted logging from info to debug to reduce noise level - [@mcfly83](https://github.com/mcfly83).
* [#17](https://github.com/dblock/waffle/pull/17): JAR manifest information includes specification and implementation details, such as GIT revision - [@ryantxu](https://github.com/ryantxu).
* [#23] Added `waffle.util.WaffleInfo` which collects system information useful for debugging - [@ryantxu](https://github.com/ryantxu).
* [#28] Added `waffle-jetty` project. This lets developers run Waffle directly within the IDE - [@ryantxu](https://github.com/ryantxu).


Interface Changes
-----------------
Expand Down
14 changes: 14 additions & 0 deletions Docs/SettingUpDevelopmentEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ c:\source\Waffle\trunk> build all

Output is placed in the `target\Debug|Release` directories.


Running the demos within Eclipse
--------------------------------

To run the demos within the IDE, you can simply: Right Click on "StartEmbeddedJetty" > Run As (or Debug As) > Java Appliction

![start-jetty-in-eclipse](https://raw.github.com/ryantxu/waffle/8643a0de5b5ef4bf5de645a866bb1ae3c8b833f8/Docs/imgs/eclipse-start-jetty.png)

To change which demo you are running, change:
```
String path = "../demo/waffle-filter";
```


Contributing
------------

Expand Down
Binary file added Docs/imgs/eclipse-start-jetty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Source/JNA/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ant dir="waffle-tomcat5" target="${ant.target}" />
<ant dir="waffle-tomcat6" target="${ant.target}" />
<ant dir="waffle-tomcat7" target="${ant.target}" />
<ant dir="waffle-jetty" target="${ant.target}" />
<ant dir="waffle-spring-security2" target="${ant.target}" />
<ant dir="waffle-spring-security3" target="${ant.target}" />
</target>
Expand Down
23 changes: 23 additions & 0 deletions Source/JNA/waffle-jetty/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/.svn|**/.svn/*" kind="src" path="src"/>
<classpathentry excluding="**/.svn|**/.svn/*" kind="src" path="src-test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/ch.qos.logback/1.0.6/logback-classic-1.0.6.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/ch.qos.logback/1.0.6/logback-core-1.0.6.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.slf4j/1.6.6/slf4j-api-1.6.6.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/junit/4.10/junit-4.10.jar"/>
<classpathentry kind="lib" path="/thirdparty/net.java.dev.jna/3.4.2/jna.jar"/>
<classpathentry kind="lib" path="/thirdparty/net.java.dev.jna/3.4.2/platform.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/waffle-jna"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.eclipse.jetty.aggregate/7.6.5.v20120716/jetty-all-7.6.5.v20120716.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/javax.servlet/2.5/servlet-api-2.5.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.eclipse.jetty.orbit/com.sun.el-1.0.0.v201105211818.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.eclipse.jetty.orbit/javax.el-2.1.0.v201105211819.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.eclipse.jetty.orbit/javax.servlet.jsp-2.1.0.v201105211820.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.eclipse.jetty.orbit/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.eclipse.jetty.orbit/org.apache.jasper.glassfish-2.1.0.v201110031002.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.eclipse.jetty.orbit/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar"/>
<classpathentry kind="lib" path="/thirdparty/_lib/jar/org.eclipse.jetty.orbit/org.eclipse.jdt.core-3.7.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Source/JNA/waffle-jetty/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>waffle-jetty</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
28 changes: 28 additions & 0 deletions Source/JNA/waffle-jetty/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="waffle-jetty" default="build" basedir=".">
<import file="${basedir}/../build/common.xml" />
<property name="project.jar" value="waffle-jetty" />
<path id="waffle-jna.classpath" location="${common.build}/waffle-jna.jar" />
<import file="${basedir}/../build/build.xml" />
<path id="javax.classpath">
<fileset dir="${thirdparty.dir}/_lib/jar/javax.servlet/2.5">
<include name="*.jar" />
</fileset>
</path>
<path id="jetty.classpath">
<fileset dir="${thirdparty.dir}/_lib/jar/org.eclipse.jetty.aggregate/7.6.5.v20120716">
<include name="*.jar" />
</fileset>
<!-- For JSP Support -->
<fileset dir="${thirdparty.dir}/_lib/jar/org.eclipse.jetty.orbit">
<include name="*.jar" />
</fileset>
</path>
<path id="project.classpath">
<path refid="waffle-jna.classpath" />
<path refid="jetty.classpath" />
<path refid="javax.classpath" />
</path>
<path id="project.test.classpath">
</path>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*******************************************************************************
* Waffle (https://github.com/dblock/waffle)
*
* Copyright (c) 2010 Application Security, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Application Security, Inc.
*******************************************************************************/
package waffle.jetty;

import java.io.File;
import java.io.FileNotFoundException;

import org.apache.jasper.servlet.JspServlet;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.bio.SocketConnector;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.webapp.WebAppContext;


/**
* A simple embedded server that lets us run directly within Eclipse
*/
public class StartEmbeddedJetty
{
public static void main(String[] args) throws Exception
{
String path = "../demo/waffle-filter";

File dir = new File( path );
if(!dir.exists()) {
throw new FileNotFoundException("Can not find webapp: "+dir.getAbsolutePath());
}

Server server = new Server();
SocketConnector connector = new SocketConnector();

// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(8080);
connector.setRequestHeaderSize(20*1044); // 20K for big request headers
server.setConnectors(new Connector[] { connector });

WebAppContext context = new WebAppContext();
context.setServer(server);
context.setContextPath("/");
context.setWar(path);

// Try adding JSP
try {
ServletHolder jsp = context.addServlet(JspServlet.class, "*.jsp");
jsp.setInitParameter("classpath", context.getClassPath());
}
catch( Exception ex) {
System.err.println("Error adding JSP Support: "+ex.toString());
}

server.setHandler(context);

try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(100);
}
}
}
7 changes: 7 additions & 0 deletions Source/JNA/waffle-jetty/src/waffle/jetty/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Nothing for now, but in the future, this would include:
*
* <a href="http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/jetty-security/src/main/java/org/eclipse/jetty/security/Authenticator.java">org/eclipse/jetty/security/Authenticator.java</a><br/>
* <a href="http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/jetty-security/src/main/java/org/eclipse/jetty/security/LoginService.java">org/eclipse/jetty/security/LoginService.java</a><br/>
*/
package waffle.jetty;
15 changes: 14 additions & 1 deletion Source/ThirdParty/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<echo>Waffle Third Party Dependencies</echo>
</target>

<target name="dist" depends="clean, install-ivy, dependencies, report">
<target name="dist" depends="clean, install-ivy, dependencies, getjsp, report">

</target>

Expand Down Expand Up @@ -40,6 +40,19 @@
<ivy:resolve file="${basedir}/ivy2.xml" />
<ivy:retrieve pattern="_lib/[type]/[organisation]/[revision]/[artifact]-[revision].[ext]" sync="false" />
</target>

<!-- TODO, this should be done with ivy, but ivy does not work with the jetty 'orbit' configs. Fixed in IVY-899 -->
<target name="getjsp">
<property name="jetty.jsp.dir" value="${basedir}/_lib/jar/org.eclipse.jetty.orbit" />
<mkdir dir="${jetty.jsp.dir}" />
<get dest="${jetty.jsp.dir}" src="http://central.maven.org/maven2/org/eclipse/jetty/orbit/com.sun.el/1.0.0.v201105211818/com.sun.el-1.0.0.v201105211818.jar"/>
<get dest="${jetty.jsp.dir}" src="http://central.maven.org/maven2/org/eclipse/jetty/orbit/javax.el/2.1.0.v201105211819/javax.el-2.1.0.v201105211819.jar"/>
<get dest="${jetty.jsp.dir}" src="http://central.maven.org/maven2/org/eclipse/jetty/orbit/javax.servlet.jsp.jstl/1.2.0.v201105211821/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar" />
<get dest="${jetty.jsp.dir}" src="http://central.maven.org/maven2/org/eclipse/jetty/orbit/javax.servlet.jsp/2.1.0.v201105211820/javax.servlet.jsp-2.1.0.v201105211820.jar"/>
<get dest="${jetty.jsp.dir}" src="http://central.maven.org/maven2/org/eclipse/jetty/orbit/org.apache.jasper.glassfish/2.1.0.v201110031002/org.apache.jasper.glassfish-2.1.0.v201110031002.jar"/>
<get dest="${jetty.jsp.dir}" src="http://central.maven.org/maven2/org/eclipse/jetty/orbit/org.apache.taglibs.standard.glassfish/1.2.0.v201112081803/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar" />
<get dest="${jetty.jsp.dir}" src="http://central.maven.org/maven2/org/eclipse/jetty/orbit/org.eclipse.jdt.core/3.7.1/org.eclipse.jdt.core-3.7.1.jar" />
</target>

<target name="report">
<mkdir dir="${basedir}/_report" />
Expand Down
8 changes: 8 additions & 0 deletions Source/ThirdParty/ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
<dependency org="org.apache.tomcat" name="tomcat-servlet-api" rev="7.0.29" transitive="false"/>
<dependency org="org.apache.tomcat" name="tomcat-util" rev="7.0.29" transitive="false"/>

<!-- Jetty -->
<dependency org="org.eclipse.jetty.aggregate" name="jetty-all" rev="7.6.5.v20120716" transitive="false"/>
<!--
See ../build.xml#getjsp for the hack around
https://issues.apache.org/jira/browse/IVY-899
When this is part of IVY, we can put the depenencies here rather then using <get
-->

<!-- logging -->
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.6" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.6" transitive="false"/>
Expand Down