You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2016/12/23 18:48:03 UTC
opennlp git commit: Update Jersey to 2.25 and use Grizzly HTTP Server
Repository: opennlp
Updated Branches:
refs/heads/trunk c49a87abd -> 1d1c41945
Update Jersey to 2.25 and use Grizzly HTTP Server
See issue OPENNNLP-897
Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo
Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/1d1c4194
Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/1d1c4194
Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/1d1c4194
Branch: refs/heads/trunk
Commit: 1d1c41945a50a740519131bfff4e1875de69dd6b
Parents: c49a87a
Author: Joern Kottmann <jo...@apache.org>
Authored: Wed Dec 21 14:55:24 2016 +0100
Committer: Kottmann <jo...@apache.org>
Committed: Fri Dec 23 19:47:24 2016 +0100
----------------------------------------------------------------------
opennlp-brat-annotator/pom.xml | 24 +++---------
.../opennlp/bratann/NameFinderAnnService.java | 41 ++++++--------------
2 files changed, 18 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1d1c4194/opennlp-brat-annotator/pom.xml
----------------------------------------------------------------------
diff --git a/opennlp-brat-annotator/pom.xml b/opennlp-brat-annotator/pom.xml
index 65e3b69..1007f61 100644
--- a/opennlp-brat-annotator/pom.xml
+++ b/opennlp-brat-annotator/pom.xml
@@ -33,27 +33,15 @@
<dependencies>
<dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>9.2.3.v20140905</version>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-grizzly2-http</artifactId>
+ <version>2.25</version>
</dependency>
<dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlet</artifactId>
- <version>9.2.3.v20140905</version>
- </dependency>
-
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-bundle</artifactId>
- <version>1.18.1</version>
- </dependency>
-
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-json</artifactId>
- <version>1.18.1</version>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-json-jackson</artifactId>
+ <version>2.25</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1d1c4194/opennlp-brat-annotator/src/main/java/opennlp/bratann/NameFinderAnnService.java
----------------------------------------------------------------------
diff --git a/opennlp-brat-annotator/src/main/java/opennlp/bratann/NameFinderAnnService.java b/opennlp-brat-annotator/src/main/java/opennlp/bratann/NameFinderAnnService.java
index 60d2a1b..8e2aef8 100644
--- a/opennlp-brat-annotator/src/main/java/opennlp/bratann/NameFinderAnnService.java
+++ b/opennlp-brat-annotator/src/main/java/opennlp/bratann/NameFinderAnnService.java
@@ -18,13 +18,11 @@
package opennlp.bratann;
import java.io.File;
+import java.net.URI;
import java.util.Arrays;
import java.util.List;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-
+import com.sun.net.httpserver.HttpServer;
import opennlp.tools.namefind.NameFinderME;
import opennlp.tools.namefind.TokenNameFinder;
import opennlp.tools.namefind.TokenNameFinderModel;
@@ -37,6 +35,10 @@ import opennlp.tools.tokenize.Tokenizer;
import opennlp.tools.tokenize.TokenizerME;
import opennlp.tools.tokenize.TokenizerModel;
import opennlp.tools.tokenize.WhitespaceTokenizer;
+import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
+import org.glassfish.jersey.server.ResourceConfig;
+
+import javax.ws.rs.core.UriBuilder;
public class NameFinderAnnService {
@@ -47,9 +49,10 @@ public class NameFinderAnnService {
public static void main(String[] args) throws Exception {
if (args.length == 0) {
+ System.out.println("Usage:");
System.out.println(
- "[-serverPort port] [-tokenizerModel file] [-ruleBasedTokenizer whitespace|simple] [-sentenceDetectorModel file] "
- + "namefinderFile|nameFinderURI");
+ "[NameFinderAnnService -serverPort port] [-tokenizerModel file] [-ruleBasedTokenizer whitespace|simple] " +
+ "[-sentenceDetectorModel file] namefinderFile|nameFinderURI");
return;
}
@@ -92,28 +95,8 @@ public class NameFinderAnnService {
nameFinders = new TokenNameFinder[] { new NameFinderME(
new TokenNameFinderModel(new File(args[args.length - 1]))) };
- ServletContextHandler context = new ServletContextHandler(
- ServletContextHandler.SESSIONS);
- context.setContextPath("/");
-
- Server jettyServer = new Server(serverPort);
- jettyServer.setHandler(context);
-
- ServletHolder jerseyServlet = context
- .addServlet(com.sun.jersey.spi.container.servlet.ServletContainer.class, "/*");
- jerseyServlet.setInitParameter("com.sun.jersey.config.property.packages",
- "opennlp.bratann");
- jerseyServlet.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
- jerseyServlet.setInitOrder(0);
-
- jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
- NameFinderResource.class.getCanonicalName());
-
- try {
- jettyServer.start();
- jettyServer.join();
- } finally {
- jettyServer.destroy();
- }
+ URI baseUri = UriBuilder.fromUri("http://localhost/").port(serverPort).build();
+ ResourceConfig config = new ResourceConfig(NameFinderResource.class);
+ GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
}
}