[jboss-user] [EJB3] - Re: How does a @EJB dependency injection work on a Stateless Bean? Will that injected class behave like an instance variable in that stateless session bean?
Adheep M
do-not-reply at jboss.com
Fri Jun 22 05:21:05 EDT 2012
Adheep M [https://community.jboss.org/people/adheep] created the discussion
"Re: How does a @EJB dependency injection work on a Stateless Bean? Will that injected class behave like an instance variable in that stateless session bean?"
To view the discussion, visit: https://community.jboss.org/message/743609#743609
--------------------------------------------------------------
@ https://community.jboss.org/people/viggo.navarsete Viggo Navarsete: Thanks for your reply.
But this brings me an another question, Supose if a method in "PrimaryStatelessBean" is annotated with REST will it work the same way, because we will not create a new instance for the PrimaryStatelessBean if it is invoked as a RESTful webservice.
@Stateless
public class PrimaryStatelessBean {
@EJB
SecodaryStatelessBean secondaryStatelessBean;
@EJB
SimpleSingletonBean simpleSingletonBean;
@POST
@Path("/requestService")
@Consumes("*/*")
@Produces("*/*")
public String processRequest ( ) {
.....
secondaryStatelessBean.getValue(); //(After making a first request) When I make another request will i get the same value "Testing Value" here
simpleSingletonBean.getAnotherValue();
secondaryStatelessBean.setValue("Testing Value"); // set values for secondaryStatelessBean in the first request
....
}
}
On the first request to my to "processRequest" service using REST, if i change the value of a member variable in SecondaryStatelessBean by
secondaryStatelessBean.setValue("Testing Value"); // set values for secondaryStatelessBean in the first request
and on the next request, will i get the value "Testing Value" here ?
secondaryStatelessBean.getValue(); //(After making a first request) When I make another request will i get the same value "Testing Value" here
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/743609#743609]
Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120622/1496fb92/attachment-0001.html
More information about the jboss-user
mailing list