Class ManagedBeanSingletonResource


  • @Path("/managedbean/singleton")
    @Singleton
    public class ManagedBeanSingletonResource
    extends Object
    JAX-RS root resource treated as Java EE managed bean in singleton scope.
    Author:
    Paul Sandoz, Jakub Podlesak
    • Constructor Detail

      • ManagedBeanSingletonResource

        public ManagedBeanSingletonResource()
    • Method Detail

      • getMessage

        @GET
        @Produces("text/plain")
        public String getMessage()
        Provide textual representation of the internal counter.
        Returns:
        internal counter String representation
      • 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.