Suppose I have a JAX-RS web service like this:
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
@Path("/somePath/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class SomeObject {
    @PathParam("id")
    private String id;
    @GET
    @Path("/something")
    public String something() {
        DbObject dbObject = new DbObject(id);
        // return something
    }
    @POST
    @Path("/somethingElse")
    public void somethingElse(Arg1 arg1, Arg2 arg2) {
        DbObject dbObject  = new DbObject(id);
        // do something else with it
    }
    ...
}
The very first line in almost all my methods is creating my dbObject.
Is there a way to do that immediately after id is set?
Can I do that in the id setter? Will the setId method be called instead of populating the value of the id variable?
Or what other option do I have?
 
    