You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cmoulliard <cm...@gmail.com> on 2008/03/17 17:55:38 UTC

How declare a bean as a JNDI ref in Spring

Hi,

In different part of the documentation, it is mentioned that a bean can be
declared as a jndi reference. This could be done through Java coding as
using spring configuration file. Can you help me and show me how to
transpose the following code into a spring jndi bean declaration ?

"The object instance that is used to consume messages must be explicitly
registered with the Registry. For example if you are using Spring you must
define the bean in the spring.xml; or if you don't use Spring then put the
bean in JNDI."

// lets populate the context with the services we need
// note that we could just use a spring.xml file to avoid this step
JndiContext context = new JndiContext();
context.bind("myBean", new SayService("Good Bye!"));

Regards,

Charles




-- 
View this message in context: http://www.nabble.com/How-declare-a-bean-as-a-JNDI-ref-in-Spring-tp16096930s22882p16096930.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How declare a bean as a JNDI ref in Spring

Posted by James Strachan <ja...@gmail.com>.
On 17/03/2008, cmoulliard <cm...@gmail.com> wrote:
>
>  Hi,
>
>  In different part of the documentation, it is mentioned that a bean can be
>  declared as a jndi reference. This could be done through Java coding as
>  using spring configuration file.

The idea is that if you can use JNDI as the registry of beans if you
are not using Spring.

If you are using Spring then its easier to use that as the 'registry'.

>  Can you help me and show me how to
>  transpose the following code into a spring jndi bean declaration ?
>
>  "The object instance that is used to consume messages must be explicitly
>  registered with the Registry. For example if you are using Spring you must
>  define the bean in the spring.xml; or if you don't use Spring then put the
>  bean in JNDI."
>
>  // lets populate the context with the services we need
>  // note that we could just use a spring.xml file to avoid this step
>  JndiContext context = new JndiContext();
>  context.bind("myBean", new SayService("Good Bye!"));

<bean id="myBean" class="com.acme.SayService'>
  <constructor-arg value="Good Bye!"/>
</bean>

If you really wanna use Spring and JNDI you can use the JNDI factory
bean in Spring to lookup a bean in JNDI


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com