Guice WebServer Module - backed by latest Jetty, Jersey and Jackson.
Guice WebServer Module - backed by latest Jetty, Jersey and Jackson. Without HK2-Guice bridge.
Library is useful for lite web services. Following JAX-RS convention it’s so easy to write from simple to very complex REST endpoints. Library is simple, fast with small footprint. The library is written to fully support JSON as input and output format.
In your POM file, add following dependency:
<dependency><groupId>com.sorskod.webserver</groupId><artifactId>webserver</artifactId><version>1.1.0</version></dependency>
Note: You may want to check for the latest version.
For the latest snapshot version, you need to add add OSS Sonartype repository to your POM file and the following dependency:
<project><repositories><repository><id>oss-sonatype</id><name>oss-sonatype</name><url>https://oss.sonatype.org/content/repositories/snapshots/</url><snapshots><enabled>true</enabled></snapshots></repository></repositories><dependencies><dependency><groupId>com.sorskod.webserver</groupId><artifactId>webserver</artifactId><version>1.1-SNAPSHOT</version></dependency></dependencies></project>
There is a working example in test package. However, here is the short guideline:
@Path will be registered in Jersey’s context. Jersey’s auto-discovery feature is disabled.)WebServerModuleHTTPConnectorModule or/and HTTPSConnectorModuleConfigurator implementationServer and call start()
public class MyModule extends AbstractModule {protected void configure() {// Bind @Path annotated classesbind(MyHttpResource.class);}@Provides@DefaultConnectorConfigurator configuratorProvider() {return () -> 8080; // WebServer port}@ProvidesIntoSetFeature customJaxrsFeature() {// Provide custom features, register filters, etcreturn (context) -> {};}}Injector injector = Guice.createInjector(new WebServerModule(),new HTTPConnectorModule(),new MyModule());injector.getInstance(Server.class).start();
Library is written for fun and test purposes. Pull requests and improvement ideas are welcome.