moving Griworks to use the Butterfly webapp framework (this will allow us to make gw more extensible without excessive complexity... as a bonus we gain server side javascript support which might end up being useful)
git-svn-id: http://google-refine.googlecode.com/svn/trunk@940 7d457c2a-affb-35e4-300a-418c747d4874
@ -3,6 +3,7 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="tests/server/src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/butterfly-trunk-r14.jar" />
|
||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-codec-1.4.jar" sourcepath="webapp/WEB-INF/lib-src/commons-codec-1.4-sources.jar"/>
|
||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-lang-2.5.jar" sourcepath="webapp/WEB-INF/lib-src/commons-lang-2.5-sources.jar"/>
|
||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-fileupload-1.2.1.jar" sourcepath="webapp/WEB-INF/lib-src/commons-fileupload-1.2.1-sources.jar"/>
|
||||
|
@ -9,7 +9,6 @@ import java.util.TimerTask;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@ -18,7 +17,9 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.commands.Command;
|
||||
|
||||
public class GridworksServlet extends HttpServlet {
|
||||
import edu.mit.simile.butterfly.Butterfly;
|
||||
|
||||
public class GridworksServlet extends Butterfly {
|
||||
|
||||
static private final String VERSION = "1.0";
|
||||
|
||||
@ -31,7 +32,7 @@ public class GridworksServlet extends HttpServlet {
|
||||
// timer for periodically saving projects
|
||||
static private Timer _timer;
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("servlet");
|
||||
final static Logger logger = LoggerFactory.getLogger("gridworks");
|
||||
|
||||
// TODO: This belongs in an external config file somewhere
|
||||
private static final String[][] commandNames = {
|
||||
@ -132,6 +133,8 @@ public class GridworksServlet extends HttpServlet {
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
super.init();
|
||||
|
||||
logger.trace("> initialize");
|
||||
|
||||
String data = getInitParameter("gridworks.data");
|
||||
@ -168,40 +171,41 @@ public class GridworksServlet extends HttpServlet {
|
||||
|
||||
this.config = null;
|
||||
|
||||
super.destroy();
|
||||
|
||||
logger.trace("< destroy");
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
String commandName = getCommandName(request);
|
||||
Command command = commands.get(commandName);
|
||||
if (command != null) {
|
||||
logger.trace("> GET {}", commandName);
|
||||
command.doGet(request, response);
|
||||
logger.trace("< GET {}", commandName);
|
||||
@Override
|
||||
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
if (request.getPathInfo().startsWith("/command")) {
|
||||
String commandName = getCommandName(request);
|
||||
Command command = commands.get(commandName);
|
||||
if (command != null) {
|
||||
if (request.getMethod().equals("GET")) {
|
||||
logger.trace("> GET {}", commandName);
|
||||
command.doGet(request, response);
|
||||
logger.trace("< GET {}", commandName);
|
||||
} else if (request.getMethod().equals("POST")) {
|
||||
logger.trace("> POST {}", commandName);
|
||||
command.doPost(request, response);
|
||||
logger.trace("< POST {}", commandName);
|
||||
} else {
|
||||
response.sendError(405);
|
||||
}
|
||||
} else {
|
||||
response.sendError(404);
|
||||
}
|
||||
} else {
|
||||
response.sendError(404);
|
||||
super.service(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
String commandName = getCommandName(request);
|
||||
Command command = commands.get(commandName);
|
||||
if (command != null) {
|
||||
logger.trace("> POST {}", commandName);
|
||||
command.doPost(request, response);
|
||||
logger.trace("< POST {}", commandName);
|
||||
} else {
|
||||
response.sendError(404);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String getCommandName(HttpServletRequest request) {
|
||||
// Remove extraneous path segments that might be there for other purposes,
|
||||
// e.g., for /export-rows/filename.ext, export-rows is the command while
|
||||
// filename.ext is only for the browser to prompt a convenient filename.
|
||||
String commandName = request.getPathInfo().substring(1);
|
||||
String commandName = request.getPathInfo().substring("/command/".length());
|
||||
int slash = commandName.indexOf('/');
|
||||
return slash > 0 ? commandName.substring(0, slash) : commandName;
|
||||
}
|
||||
|
28
main/webapp/WEB-INF/butterfly.properties
Normal file
@ -0,0 +1,28 @@
|
||||
#
|
||||
# Butterfly Configuration
|
||||
#
|
||||
# NOTE: properties passed to the JVM using '-Dkey=value' from the command line
|
||||
# override the settings in this file.
|
||||
|
||||
# indicates the URL path where butterfly is available in the proxy URL space
|
||||
# as there is no way of knowing otherwise as this information is not
|
||||
# transferred thru the HTTP protocol or otherwise (different story if
|
||||
# the appserver is connected thru a different protocol such as AJP)
|
||||
|
||||
butterfly.url = /
|
||||
|
||||
# ---------- Miscellaneous ----------
|
||||
|
||||
#butterfly.locale.language = en
|
||||
#butterfly.locale.country = US
|
||||
#butterfly.timeZone = GMT+09:00
|
||||
|
||||
# ---------- Module ------
|
||||
|
||||
butterfly.modules.path = modules
|
||||
butterfly.modules.wirings = WEB-INF/modules.properties
|
||||
|
||||
# ---------- Clustering ----
|
||||
|
||||
#butterfly.routing.cookie.maxage = -1
|
||||
|
BIN
main/webapp/WEB-INF/lib/butterfly-trunk-r14.jar
Normal file
BIN
main/webapp/WEB-INF/lib/commons-collections-3.2.1.jar
Normal file
BIN
main/webapp/WEB-INF/lib/commons-io-1.4.jar
Normal file
BIN
main/webapp/WEB-INF/lib/rhino-1.7R2.jar
Normal file
BIN
main/webapp/WEB-INF/lib/velocity-1.5.jar
Normal file
5
main/webapp/WEB-INF/modules.properties
Normal file
@ -0,0 +1,5 @@
|
||||
#
|
||||
# Butterfly Modules Configuration
|
||||
#
|
||||
|
||||
core = /
|
11
main/webapp/WEB-INF/velocity.properties
Normal file
@ -0,0 +1,11 @@
|
||||
runtime.log.logsystem.class=org.apache.velocity.runtime.log.SimpleLog4JLogSystem
|
||||
runtime.log.logsystem.log4j.category=Velocity
|
||||
|
||||
parser.pool.size=5
|
||||
|
||||
velocimacro.context.localscope=false
|
||||
velocimacro.library.autoreload=false
|
||||
velocimacro.permissions.allow.inline.local.scope=true
|
||||
|
||||
input.encoding=UTF-8
|
||||
output.encoding=UTF-8
|
@ -5,6 +5,19 @@
|
||||
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
|
||||
|
||||
<web-app>
|
||||
|
||||
<!--+
|
||||
| This forces all the session cookies to default to the root path.
|
||||
| to allow sessions to work even when butterfly is handling
|
||||
| multiple zones.
|
||||
| NOTE: this is jetty-specific, so other web-app servers
|
||||
| might require different parameters.
|
||||
+-->
|
||||
<context-param>
|
||||
<param-name>org.mortbay.jetty.servlet.SessionPath</param-name>
|
||||
<param-value>/</param-value>
|
||||
</context-param>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>gridworks</servlet-name>
|
||||
<servlet-class>com.metaweb.gridworks.GridworksServlet</servlet-class>
|
||||
@ -12,11 +25,7 @@
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>gridworks</servlet-name>
|
||||
<url-pattern>/command/*</url-pattern>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
|
||||
</web-app>
|
||||
|
Before Width: | Height: | Size: 384 B After Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 142 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 568 B After Width: | Height: | Size: 568 B |
Before Width: | Height: | Size: 770 B After Width: | Height: | Size: 770 B |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 176 B |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 832 B After Width: | Height: | Size: 832 B |
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 115 B |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 847 B After Width: | Height: | Size: 847 B |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 528 B After Width: | Height: | Size: 528 B |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 155 B |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 465 B After Width: | Height: | Size: 465 B |
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 211 B |