Created
July 8, 2012 12:33
-
-
Save justinwyer/3070769 to your computer and use it in GitHub Desktop.
Java EE 6 Web Profile without the app server. Part 2.
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
@Path("/deed") | |
@RequestScoped | |
public class DeedService | |
{ | |
@Inject | |
private GoodStuff goodStuff; | |
@POST | |
@Path("/good") | |
public Response doGoodDeed() | |
{ | |
goodStuff.doSomethingGood(); | |
try | |
{ | |
return Response.created(new URI("http://www.lifeasageek.com")).build(); | |
} | |
catch (URISyntaxException ex) | |
{ | |
return Response.serverError().build(); | |
} | |
} | |
} |
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
public class RestConfig extends Application | |
{ | |
@Override | |
public Set<Class<?>> getClasses() | |
{ | |
Set<Class<?>> classes = new HashSet<>(); | |
classes.add(DeedService.class); | |
return classes; | |
} | |
} |
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
<servlet> | |
<servlet-name>jersey-serlvet</servlet-name> | |
<servlet-class> | |
com.sun.jersey.spi.container.servlet.ServletContainer | |
</servlet-class> | |
<init-param> | |
<param-name>javax.ws.rs.Application</param-name> | |
<param-value>com.lifeasageek.goodstuffexample.RestConfig</param-value> | |
</init-param> | |
<load-on-startup>1</load-on-startup> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>jersey-serlvet</servlet-name> | |
<url-pattern>/rest/*</url-pattern> | |
</servlet-mapping> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment