org.glassfish.jersey.examples.managedbeans.resources
Class ManagedBeanSingletonResource

java.lang.Object
  extended by org.glassfish.jersey.examples.managedbeans.resources.ManagedBeanSingletonResource

@Path(value="/managedbean/singleton")
@Singleton
public class ManagedBeanSingletonResource
extends Object

JAX-RS root resource treated as Java EE managed bean in singleton scope.

Author:
Paul Sandoz (paul.sandoz at oracle.com), Jakub Podlesak (jakub.podlesak at oracle.com)

Constructor Summary
ManagedBeanSingletonResource()
           
 
Method Summary
 void deleteWidget(int id)
          Remove widget with given id.
 String getException()
          Throw a runtime exception, so that it could be mapped.
 String getMessage()
          Provide textual representation of the internal counter.
 String getWidget(int id)
          Get JPA widget value.
 void putMessage(int i)
          Reset internal counter.
 void putWidget(int id, String val)
          Set new widget value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagedBeanSingletonResource

public ManagedBeanSingletonResource()
Method Detail

getMessage

@GET
@Produces(value="text/plain")
public String getMessage()
Provide textual representation of the internal counter.

Returns:

putMessage

@PUT
@Produces(value="text/plain")
public void putMessage(int i)
Reset internal counter.

Parameters:
i - new counter value to be set.

getException

@Path(value="exception")
public String getException()
Throw a runtime exception, so that it could be mapped.

Returns:
nothing, just throw the custom exception.

getWidget

@Path(value="widget/{id: \\d+}")
@GET
public String getWidget(@PathParam(value="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(value="widget/{id: \\d+}")
@PUT
public void putWidget(@PathParam(value="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(value="widget/{id: \\d+}")
@DELETE
public void deleteWidget(@PathParam(value="id")
                                     int id)
Remove widget with given id.

Parameters:
id - id of the widget to be removed.


Copyright © 2007-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.