-
1. Re: Component.getInstance(...) problem
swd847 Feb 28, 2009 12:02 AM (in response to sherkan777)if SGUniNewsAction is the bean class, you need to use the local interface in your code. Post the bean src and I will give an example if you are still hacing trouble.
-
2. Re: Component.getInstance(...) problem
sherkan777 Feb 28, 2009 2:09 AM (in response to sherkan777)Jep, this is STSB
My bean which I want to get:
@Stateful @Scope(ScopeType.APPLICATION) @Name("sguniNewsAction") public class SGUniNewsAction extends GameSystem implements SGUniNewsConsole { ..... @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void loadHotNews() {...} }
My bean from which i want to get SGUniNewsAction:
@Stateful @Scope(ScopeType.CONVERSATION) @Restrict("#{s:hasRole('moderator')}") @Name("newsAction") public class NewsAction extends PersonSystem implements NewsConsole { ..... @End @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void addNews() { .... SGUniNewsAction action = (SGUniNewsAction)Component.getInstance(SGUniNewsAction.class, false); action.loadHotNews(); }
-
3. Re: Component.getInstance(...) problem
swd847 Feb 28, 2009 2:39 AM (in response to sherkan777)This is what you want:
SGUniNewsConsole action = (SGUniNewsConsole)Component.getInstance(SGUniNewsAction.class, false);
With ejbs you always reference them through the Local or Remote interface, this is because the object that is returned is not an SGUniNewsAction, but a proxy that implements SGUniNewsConsole and wraps a SGUniNewsAction instance, with several layers of interceptors in between (this is how it provides all those neat things such as dependency injection and container managed transactions).
-
4. Re: Component.getInstance(...) problem
sherkan777 Feb 28, 2009 10:22 AM (in response to sherkan777)hmmmm, so...how can I get it if this is proxy?
Can u show me pls, a small example?
-
5. Re: Component.getInstance(...) problem
swd847 Feb 28, 2009 9:10 PM (in response to sherkan777)You call it like this:
SGUniNewsConsole action = (SGUniNewsConsole)Component.getInstance("sguniNewsAction", false);
-
6. Re: Component.getInstance(...) problem
sherkan777 Feb 28, 2009 11:06 PM (in response to sherkan777)Thanks Stuart, you got beer! :)