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
This commit is contained in:
Stefano Mazzocchi 2010-06-05 00:50:18 +00:00
parent 0648e8725e
commit af48cb799e
126 changed files with 91 additions and 33 deletions

View File

@ -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"/>

View File

@ -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;
}

View 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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,5 @@
#
# Butterfly Modules Configuration
#
core = /

View 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

View File

@ -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>

View File

Before

Width:  |  Height:  |  Size: 142 B

After

Width:  |  Height:  |  Size: 142 B

View File

Before

Width:  |  Height:  |  Size: 139 B

After

Width:  |  Height:  |  Size: 139 B

View File

Before

Width:  |  Height:  |  Size: 568 B

After

Width:  |  Height:  |  Size: 568 B

View File

Before

Width:  |  Height:  |  Size: 770 B

After

Width:  |  Height:  |  Size: 770 B

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

View File

Before

Width:  |  Height:  |  Size: 832 B

After

Width:  |  Height:  |  Size: 832 B

View File

Before

Width:  |  Height:  |  Size: 115 B

After

Width:  |  Height:  |  Size: 115 B

View File

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 127 B

View File

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 847 B

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 528 B

After

Width:  |  Height:  |  Size: 528 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 166 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 465 B

After

Width:  |  Height:  |  Size: 465 B

View File

Before

Width:  |  Height:  |  Size: 211 B

After

Width:  |  Height:  |  Size: 211 B

Some files were not shown because too many files have changed in this diff Show More