myyron latorilla wrote:If I only have 1 MDB instance, does it make sense to just instantiate the Session Bean class and not inject it. Given that both are packaged on a single EJB module project. Thanks in advance.
Why was the session bean class made an EJB?
Does it have container services provided for it like being a target for injection, transaction management, security, managed resource access?
Those should have been the reasons used to make it an EJB. If it requires any of those then you lose those services if you instantiate it yourself.
If it doesn't use those services then it should never have been an EJB in the first place.
myyron latorilla wrote:But then, for the purpose of the topic, it is okay to instantiate than to inject for that purpose?
What exactly does instantiate mean? Are you talking about using the new() operator to do that? If yes, then never ever use the new() operator for "managed" components (like EJBs, servlets, managed beans etc...). Using the new() operator will just create instances of those classes as plain Java objects and they will not have any container managed capabilities.
i guess the answer for me is it is okay to instantiate (use new operator) for that sole purpose as the method doesnt need any container managed capabilities as i can always use the transaction management from the MDB. But then I wont do that, instead move the method out of the session bean. I hope you guys agree on this sense. thanks.