Applied a bunch of patches from Tom Morris (Issue 25, 26 and 27)

- make java6 dependency explicit in eclipse project files
- avoid using NotImplementException especially the sun.* one
- avoid using internal sun signal handling and rely on standard java.* APIs
 (I tested this one and it seems to be working fine)


git-svn-id: http://google-refine.googlecode.com/svn/trunk@756 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-05-13 21:02:19 +00:00
parent a096fae7a0
commit ea459aed07
12 changed files with 28 additions and 85 deletions

View File

@ -3,7 +3,7 @@
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/server/java"/>
<classpathentry kind="src" path="tests/java/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<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="lib/servlet-api-2.5.jar" sourcepath="lib-src/servlet-api-2.5-sources.jar"/>
<classpathentry kind="lib" path="lib/jetty-6.1.22.jar" sourcepath="lib-src/jetty-6.1.22-sources.jar"/>
<classpathentry kind="lib" path="lib/jetty-util-6.1.22.jar" sourcepath="lib-src/jetty-util-6.1.22-sources.jar"/>

View File

@ -1,12 +1,12 @@
#Sat Feb 06 22:08:10 PST 2010
#Thu May 13 14:23:04 EDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -10,7 +10,6 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.NotImplementedException;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONWriter;
@ -36,13 +35,13 @@ public abstract class Command {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
throw new NotImplementedException();
throw new UnsupportedOperationException();
};
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
throw new NotImplementedException();
throw new UnsupportedOperationException();
};
/**

View File

@ -10,7 +10,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang.NotImplementedException;
import org.apache.poi.common.usermodel.Hyperlink;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@ -39,7 +38,7 @@ public class ExcelImporter implements Importer {
}
public void read(Reader reader, Project project, Properties options) throws Exception {
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
public void read(InputStream inputStream, Project project, Properties options) throws Exception {
@ -53,7 +52,7 @@ public class ExcelImporter implements Importer {
new XSSFWorkbook(inputStream) :
new HSSFWorkbook(new POIFSFileSystem(inputStream));
} catch (IOException e) {
throw new IOException(
throw new Exception(
"Attempted to parse file as Excel file but failed. " +
"Try to use Excel to re-save the file as a different Excel version or as TSV and upload again.",
e

View File

@ -8,7 +8,6 @@ import java.io.OutputStream;
import java.io.Reader;
import java.util.Properties;
import org.apache.commons.lang.NotImplementedException;
import org.marc4j.MarcPermissiveStreamReader;
import org.marc4j.MarcWriter;
import org.marc4j.MarcXmlWriter;
@ -25,7 +24,7 @@ public class MarcImporter implements Importer {
public void read(Reader reader, Project project, Properties options)
throws Exception {
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
public void read(

View File

@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang.StringUtils;
import com.metaweb.gridworks.importers.parsers.CSVRowParser;
@ -94,7 +93,7 @@ public class TsvCsvImporter implements Importer {
}
public void read(InputStream inputStream, Project project, Properties options) throws Exception {
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
public boolean takesReader() {

View File

@ -6,8 +6,6 @@ import java.io.PushbackInputStream;
import java.io.Reader;
import java.util.Properties;
import org.apache.commons.lang.NotImplementedException;
import com.metaweb.gridworks.importers.XmlImportUtilities.ImportColumnGroup;
import com.metaweb.gridworks.model.Project;
@ -22,7 +20,7 @@ public class XmlImporter implements Importer {
public void read(Reader reader, Project project, Properties options)
throws Exception {
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
public void read(

View File

@ -2,8 +2,6 @@ package com.metaweb.gridworks.model;
import java.util.Properties;
import org.apache.commons.lang.NotImplementedException;
import com.metaweb.gridworks.Jsonizable;
import com.metaweb.gridworks.history.HistoryEntry;
import com.metaweb.gridworks.process.Process;
@ -24,10 +22,10 @@ abstract public class AbstractOperation implements Jsonizable {
}
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
protected String getBriefDescription(Project project) {
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
}

View File

@ -11,8 +11,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONWriter;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import com.metaweb.gridworks.browsing.Engine;
import com.metaweb.gridworks.browsing.FilteredRows;
import com.metaweb.gridworks.browsing.RowVisitor;
@ -260,7 +258,7 @@ public class ColumnSplitOperation extends EngineDependentOperation {
}
protected List<Serializable> split(String s) {
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
protected Serializable stringToValue(String s) {

View File

@ -29,9 +29,12 @@ import org.mortbay.util.Scanner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.metaweb.util.signal.AbstractSignalHandler;
import com.metaweb.util.threads.ThreadPoolExecutorAdapter;
/**
* Main class for Gridworks server application. Starts an instance of the
* Jetty HTTP server / servlet container (inner class Gridworks Server).
*/
public class Gridworks {
static private final String VERSION = "1.0";
@ -113,7 +116,8 @@ public class Gridworks {
}
// hook up the signal handlers
new ShutdownSignalHandler("TERM", server);
Runtime.getRuntime().addShutdownHook(
new Thread(new ShutdownSignalHandler(server)));
server.join();
}
@ -300,18 +304,16 @@ class GridworksClient extends JFrame implements ActionListener {
}
}
class ShutdownSignalHandler extends AbstractSignalHandler {
class ShutdownSignalHandler implements Runnable {
private Server _server;
public ShutdownSignalHandler(String sigName, Server server) {
super(sigName);
public ShutdownSignalHandler(Server server) {
this._server = server;
}
public boolean handle(String signame) {
//System.err.println("Received Signal: " + signame);
@Override
public void run() {
// Tell the server we want to try and shutdown gracefully
// this means that the server will stop accepting new connections
@ -327,8 +329,7 @@ class ShutdownSignalHandler extends AbstractSignalHandler {
e.printStackTrace();
System.exit(1);
}
return true;
}
}

View File

@ -1,20 +0,0 @@
package com.metaweb.util.signal;
public abstract class AbstractSignalHandler {
public AbstractSignalHandler(final String signalName) {
try {
new SignalHandlerWrapper(signalName, this);
} catch (Throwable e) {
throw new java.lang.RuntimeException("Signal handling facilities are not available in this JVM.", e);
}
}
/**
* The method that handles the signal this handler has been registered for.
* If the method returns false or throws, the chain of invocation is stopped;
* this includes the handlers the JVM already registered for those signals.
*/
public abstract boolean handle(String signame);
}

View File

@ -1,28 +0,0 @@
package com.metaweb.util.signal;
import sun.misc.Signal;
import sun.misc.SignalHandler;
/*
* This class allows our own SignalHandler class to fail more gracefully
* in case the "sun.misc.Signal*" classes are not found in the current jvm.
*/
final class SignalHandlerWrapper implements SignalHandler {
private transient final SignalHandler existingHandler;
private transient final AbstractSignalHandler handler;
SignalHandlerWrapper(final String signalName, final AbstractSignalHandler handler) {
this.handler = handler;
final Signal signal = new Signal(signalName);
existingHandler = Signal.handle(signal, this);
}
public void handle(final Signal sig) {
if (handler.handle(sig.getName()) && (existingHandler != null)) {
existingHandler.handle(sig);
}
}
}