users@glassfish.java.net

Re: EJB Module & JMS

From: <glassfish_at_javadesktop.org>
Date: Mon, 29 Oct 2007 17:20:08 PST

Resource injection on util class is not supported. You can inject the resource into a component class that supports injection (e.g., bean class, interceptors, or their superclasses), and look up these resources from a util class that is in the same environment naming context as the component.
<code>
@Stateless
@Resource(mappedName = "jms/OutboundTopicConnectionFactory",
                      name="jms/OutboundTopicConnectionFactory",
                      type=javax.jms.TopicConnectionFactory)
public class FooBean implements Foo {
    public void doFoo() {
        Util.bar();
    }
}

public class Util {
    public static void bar() {
        Context ic = new InitialContext();
        Topic topic = (Topic) ic.lookup("java:comp/env/jms/OutboundTopicConnectionFactory");

</code>

Or you can declare these resources in ejb-jar.xml and use the plain old JNDI lookup.

-cheng
[Message sent by forum member 'cf126330' (cf126330)]

http://forums.java.net/jive/thread.jspa?messageID=242809