users@glassfish.java.net

howto: How can the same bean multiple times configured differently ?

From: <glassfish_at_javadesktop.org>
Date: Wed, 07 Nov 2007 14:38:51 PST

How can the same bean multiple times configured differently (i.e. listening to different queues) ?

I've tried it but break my bean's @notation resource references. I think I want a configuration sort of like this:

[b]ejb-jar.xml:[/b]

    <session>
        <ejb-name>FabToHubSenderSeattleSBean</ejb-name>
        <business-local>hello.FabToHubSenderLocal</business-local>
        <business-remote>hello.FabToHubSenderRemote</business-remote>
        <ejb-class>hello.FabToHubSenderSBean</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
        <security-identity>
        <use-caller-identity/>
        </security-identity>
    </session>
    <session>
        <ejb-name>FabToHubSenderHongKongSBean</ejb-name>
        <business-local>hello.FabToHubSenderLocal</business-local>
        <business-remote>hello.FabToHubSenderRemote</business-remote>
        <ejb-class>hello.FabToHubSenderSBean</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
        <security-identity>
        <use-caller-identity/>
        </security-identity>
    </session>

[b]sun-ejb-jar.xml:[/b]

    <ejb>
      <ejb-name>FabToHubSenderSeattleSBean</ejb-name>
      <resource-ref>
        <res-ref-name>jms/FabZzzNnFactory</res-ref-name>
        <jndi-name>jms/FabSeattleFactory</jndi-name>
      </resource-ref>
      <message-destination-ref>
        <message-destination-ref-name>jms/FabZzzNnToHubQueue</message-destination-ref-name>
        <jndi-name>jms/FabSeattleToHubQueue</jndi-name>
      </message-destination-ref>
    </ejb>
    <ejb>
      <ejb-name>FabToHubSenderHongKongSBean</ejb-name>
      <resource-ref>
        <res-ref-name>jms/FabZzzNnFactory</res-ref-name>
        <jndi-name>jms/FabHongKongFactory</jndi-name>
      </resource-ref>
      <message-destination-ref>
        <message-destination-ref-name>jms/FabZzzNnToHubQueue</message-destination-ref-name>
        <jndi-name>jms/FabHongKongToHubQueue</jndi-name>
      </message-destination-ref>
    </ejb>

[b]class:[/b]

@Stateless
@Local({FabToHubSenderLocal.class})
@Remote({FabToHubSenderRemote.class})
//_at_EJB(name = "XXX")
public class FabToHubSenderSBean implements FabToHubSenderLocal, FabToHubSenderRemote
{
    @Resource(name = "jms/FabZzzNnFactory")
    private ConnectionFactory connectionFactory;

    @Resource(name = "jms/FabZzzNnToHubQueue")
    private Queue queue;
[Message sent by forum member 'frenchdrip' (frenchdrip)]

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