Class ManagedBeanSingletonResource
- java.lang.Object
-
- org.glassfish.jersey.examples.managedbeans.resources.ManagedBeanSingletonResource
-
@Path("/managedbean/singleton") @Singleton public class ManagedBeanSingletonResource extends ObjectJAX-RS root resource treated as Java EE managed bean in singleton scope.- Author:
- Paul Sandoz, Jakub Podlesak
-
-
Constructor Summary
Constructors Constructor Description ManagedBeanSingletonResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteWidget(int id)Remove widget with given id.StringgetException()Throw a runtime exception, so that it could be mapped.StringgetMessage()Provide textual representation of the internal counter.StringgetWidget(int id)Get JPA widget value.voidputMessage(int i)Reset internal counter.voidputWidget(int id, String val)Set new widget value.
-
-
-
Method Detail
-
getMessage
@GET @Produces("text/plain") public String getMessage()Provide textual representation of the internal counter.- Returns:
- internal counter
Stringrepresentation
-
putMessage
@PUT @Produces("text/plain") public void putMessage(int i)Reset internal counter.- Parameters:
i- new counter value to be set.
-
getException
@Path("exception") public String getException()Throw a runtime exception, so that it could be mapped.- Returns:
- nothing, just throw the custom exception.
-
getWidget
@Path("widget/{id: \\d+}") @GET public String getWidget(@PathParam("id") int id)Get JPA widget value.- Parameters:
id- widget id.- Returns:
- value of the widget or 404 if given widget id is not found.
-
putWidget
@Path("widget/{id: \\d+}") @PUT public void putWidget(@PathParam("id") int id, String val)Set new widget value.- Parameters:
id- widget id.val- new value to be associated with above specified id.
-
deleteWidget
@Path("widget/{id: \\d+}") @DELETE public void deleteWidget(@PathParam("id") int id)Remove widget with given id.- Parameters:
id- id of the widget to be removed.
-
-