Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
2.2. Using JNDI
Overview Copier lienLien copié sur presse-papiers!
Spring JEE JNDI lookup Copier lienLien copié sur presse-papiers!
- Add the following namespace declaration to your
beans
element in your service unit's configuration.xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jee="http://www.springframework.org/schema/jee"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add a
jee:jndi-lookup
element to your service unit's configuration.Thejee:jndi-lookup
element has two attributes. They are described in Table 2.4, “Attributes for Using Spring's JEE JNDI Lookup”. - Add a
jee:environment
child element to thejee:jndi-lookup
element.Thejee:environment
element contains a collection of Java properties that are used to access the JNDI provider. These properties will be provided by your JNDI provider's documentation.
Example 2.4. Getting the WebLogic Connection Factory Using Spring's JEE JNDI Look-up
Spring JNDI Templates Copier lienLien copié sur presse-papiers!
JndiTemplate
bean. Using this approach, you configure an instance of the JndiTemple
bean and then use the bean to perform all of your JNDI look-ups using a JndiObjectFactoryBean
bean.
- Add a
bean
element to your configuration for the JNDI template.- Set the
bean
element'sid
attribute to a unique identifier. - Set the
bean
element'sclass
attribute toorg.springframework.jndi.JndiTemplate
. - Add a
property
child element to thebean
element.Theproperty
element will contain the properties for accessing the JNDI provider. - Set the
property
element'sname
attribute toenvironment
. - Add a
props
child to theproperty
element. - Add a
prop
child element to theprops
element for each Java property needed to connect to the JNDI provider.Aprop
element has a single attribute calledkey
whose value is the name of the Java property being set. The value of the element is the value of the Java property being set. Example 2.5, “Setting a Java Property” shows aprop
element for setting the java.naming.factory.initial property.Example 2.5. Setting a Java Property
<prop key="java.naming.factory.initial"> com.sun.jndi.fscontext.RefFSContextFactory </prop>
<prop key="java.naming.factory.initial"> com.sun.jndi.fscontext.RefFSContextFactory </prop>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe properties you need to set will be determined by your JNDI provider. Check its documentation.
- Add a
bean
element to your configuration to retrieve the JMS connection factory using the JNDI template.- Set the
bean
element'sid
attribute to a unique identifier. - Set the
bean
element'sclass
attribute toorg.springframework.jndi.JndiObjectFactoryBean
. - Add a
property
child element to thebean
element.Thisproperty
element loads the JNDI template to be used for the look-up. You must set itsname
attribute tojndiTemplate
. The value of itsref
attribute is taken from thename
attribute of thebean
element that configured the JNDI template. - Add a second
property
child element to thebean
element.Thisproperty
element specifies the JNDI name of the connection factory. You must set itsname
attribute tojndiTemplate
. - Add a
value
child element to theproperty
element.The value of the element is the JNDI name of the connection factory.
Example 2.6. Using a JNDI Template to Look Up a Connection Factory