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 17:47:24 UTC
[7/7] opennlp git commit: Update Jersey to 2.25 and use Grizzly HTTP
Server
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/6d1f8244
Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/6d1f8244
Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/6d1f8244
Branch: refs/heads/897
Commit: 6d1f82448ff499193dbc4b738c88b0e545a02218
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 18:45:56 2016 +0100
----------------------------------------------------------------------
opennlp-brat-annotator/pom.xml | 24 ++++---------
.../opennlp/bratann/NameFinderAnnService.java | 36 +++++---------------
2 files changed, 15 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/opennlp/blob/6d1f8244/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/6d1f8244/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..b2dbce4 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 {
@@ -92,28 +94,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);
}
}