Last active
November 23, 2015 16:53
-
-
Save shamoh/42b799f79b0e2a644be1 to your computer and use it in GitHub Desktop.
JAX-RS Hello World Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.inject.Singleton; | |
import javax.ws.rs.Consumes; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.POST; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
@Path("helloworld") | |
@Singleton | |
public class HelloWorldResource { | |
private String hello = "Hello World!"; | |
@GET | |
@Produces("text/plain") | |
public String getHello() { | |
return hello; | |
} | |
@POST | |
@Consumes("text/plain") | |
public void postHello(String hello) { | |
this.hello = hello; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Set; | |
import java.util.HashSet; | |
import javax.ws.rs.ApplicationPath; | |
import javax.ws.rs.core.Application; | |
@ApplicationPath("/") | |
public class JaxRsApplication extends Application { | |
@Override | |
public Set<Class<?>> getClasses() { | |
Set<Class<?>> classes = new HashSet<>(); | |
classes.add(HelloWorldResource.class); | |
return classes; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment