Skip to main content

Injection within ACC

4 replies [Last post]
isana
Offline
Joined: 2005-11-10

Hello,

The following article describes that 'you can also perform resource injection in an application client's main class'.
http://java.sun.com/developer/EJTechTips/2005/tt0930.html#1

I'd like to make it clear whether resource injection is performed to the variables ONLY in a client's main class, or it's performed NOT ONLY in main class.

In other words, I'd like to know how to make resource injection performed in classes other than main class (if I can do such a thing).

Thank you.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ss141213
Offline
Joined: 2005-03-30

Only application client main class can be used for resource injection. The fields or getter methods must not be [b]final[/b] and must be [b]static[/b]. Some container may allow other classes to be used for resource injection, but that's non-portable.

Thanks,
Sahoo

isana
Offline
Joined: 2005-11-10

Hello,

Thank you for information.

I understand that the only portable way is to make use of resource injection only with the static non-final variables in the main class.

I wish someday this specification changes and I can benefit from injection anywhere in client applications (like WEB applications)...

Thank you.

ss141213
Offline
Joined: 2005-03-30

Not sure why you mentioned about web application. You must ne knowing that resource injection is supported in web applications as well, but they are limited to certain kind of classes, like Servlets, Listeners, TagHandlers etc. Have a look at chapter #5 of Java EE 5 platform spec (http://jcp.org/en/jsr/detail?id=244). are you talking about resource injection in any kind of class bundled as part of .war file?

-- Sahoo

isana
Offline
Joined: 2005-11-10

Hello, Shahoo.

I'm sorry for my loose expression.

I meant that, in WEB application, I can have resouces injected into classes which are more specific to certain usecases (like JSF managed beans).

In ACC case, it seems that I have to have all the EJB references injected in the very beginning of the application. But I want to get an EJB reference just before it's necessary. Now, I have one session bean injected in the main class and get another session beans through the first session bean's methods whith create EJB reference using traditional InitialContext.lookup.

Thanks.