geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: JMS Connection Factory / JNDI Naming
Date Sat, 18 Mar 2006 00:40:17 GMT

On Mar 17, 2006, at 4:09 PM, Oli Kessler wrote:

> Hello,
>
> I'm trying to write a GBean that depends on a JMS configuration
> initialized with a resource group configuration plan as indicated  
> in the
> book by Aaron Mulder on chariotsolutions.com.
>
> The file contains a connection factory object named
> "MyConnectionFactory" indicated in the connectiondefition-instance  
> and a
> topic called "MyTopic" (message-destination-name). When deployed,  
> those
> 2 objects can be seen and verified in the web console.
>
> Now, my GBean needs to publish to the topic "MyTopic" using a  
> connection
> from the factory object. How would I get the factory object in my code
> with JNDI? Opposed to a web-application or EJB, I can not count on
> configured resource references in web.xml or similar, right?
>
> I tried the simple
>
> (..)
> InitialContext context = new InitialContext();
> Object obj = context.lookup("MyConnectionFactory);
> (..)
>
> but this did not work out. Is there any prefix I should use?

Jndi won't work within a gbean, you should use a gbean reference.   
Here's an example from the system datasource plan, and the gbean  
referenced can show you how to code it.  The reference to emulate  
here is ManagedConnectionFactoryWrapper

     <gbean name="NonTransactionalThreadPooledTimer"  
class="org.apache.geronimo.timer.jdbc.JDBCStoreThreadPooledNonTransactio 
nalTimer">
         <reference  
name="TransactionContextManager"><moduleType>J2EEModule</ 
moduleType><module>geronimo/j2ee-server/${pom.currentVersion}/car</ 
module><name>TransactionContextManager</name></reference>
         <reference  
name="ManagedConnectionFactoryWrapper"><moduleType>JCAResource</ 
moduleType><name>SystemDatasource</name></reference>
         <reference name="ThreadPool"><moduleType>J2EEModule</ 
moduleType><module>geronimo/j2ee-server/${pom.currentVersion}/car</ 
module><name>DefaultThreadPool</name></reference>
         <!--TODO remove moduleType when gbeans get the moduleType of  
the plan they are in -->
         <reference name="DerbySystem"><moduleType>J2EEModule</ 
moduleType><name>DerbySystem</name></reference>
     </gbean>

thanks
david jencks

>
>
> Cheers,
> Oli Kessler
>
> -- 
> ncode solutions gmbh
> http://www.ncode.ch
>
> tel +41 43 817 01 88
> fax +41 43 817 02 88
> Zurich / Switzerland


Mime
View raw message