开发者

lifecycle callbacks for JAX-RS resources?

开发者 https://www.devze.com 2023-01-26 06:47 出处:网络
suppose i have a jax-rs resource class that looks like this: @Path(\"/nodes\") public class NodeResource {

suppose i have a jax-rs resource class that looks like this:

@Path("/nodes")
public class NodeResource { 
   //Temp - those injections should work
   @EJB
   ListNodesLocal nodeList;
   //stuff
}

and i want some sort of lifecycle callback so i can manually lookup that field via JNDI because injection isnt working for me yet (using jboss 6 m5. see this issue : https://jira.jboss.org/browse/JBAS-8575). ideally im looking for something like

@PostConstruct
private void init() {
    //manual JNDI to 开发者_如何学Gocome here
}

can i do this somehow ? i've tried javax.annotation.PostConstruct to no avail. is there something that works?


Since you linked to jboss in your question this answer assumes you're using the Resteasy implementation of JAX-RS. You can register interceptors to hook into the lifecycle. See here. That's how I was able to use Shiro annotations to authorize clients who want to invoke my API.

0

精彩评论

暂无评论...
验证码 换一张
取 消