2 Replies Latest reply on Apr 27, 2009 12:46 AM by jmesnil

    Hashtable Bean in microcontainer XML configuration

    jmesnil

      Hi,

      I've several POJOs deployed from the microcontainer which requires a Hashtable in their constructor (JNDI properties fwiw).
      I looked in the doc but I've not found a way to declare a Bean which is a Hashtable with all the required properties.
      So I use a map in all the POJO's constructor:

       <bean name="SourceDestinationFactory" class="org.jboss.messaging.jms.bridge.impl.JNDIDestinationFactory">
       <constructor>
       <parameter>
       <map class="java.util.Hashtable" keyClass="java.lang.String" valueClass="java.lang.String">
       <entry>
       <key>java.naming.factory.initial</key>
       <value>org.jnp.interfaces.NamingContextFactory</value>
       </entry>
       <entry>
       <key>java.naming.provider.url</key>
       <value>jnp://localhost:1099</value>
       </entry>
       <entry>
       <key>java.naming.factory.url.pkgs</key>
       <value>org.jboss.naming:org.jnp.interfaces"</value>
       </entry>
       </map>
       </parameter>
       <parameter>/queue/source</parameter>
       </constructor>
       </bean>
      


      What I'd like is to define a "JNDI" bean and inject it directly in my POJOs instead:
       <bean name="SourceDestinationFactory" class="org.jboss.messaging.jms.bridge.impl.JNDIDestinationFactory">
       <constructor>
       <parameter>
       <inject bean="JNDI" />
       </parameter>
       <parameter>/queue/source</parameter>
       </constructor>
       </bean>
      


      where JNDI bean is a Hashtable where I filled in the JNDI properties

      Is it possible to do that? Where can I find an example/doc about that?

      thanks!


        • 1. Re: Hashtable Bean in microcontainer XML configuration
          alesj

           

          "jmesnil" wrote:

          Is it possible to do that?

          Sure it is.

          Hashtable is just the name of the class for what MC knows.
          OK, the trick is still to get those entries in. ;-)

          <bean name="JNDI" class="java.util.Hashtable">
           <install method="put">
           <parameter>java.naming.provider.url</parameter>
           <parameter>jnp://localhost:1099</parameter>
           </install>
          </bean>
          


          or

          <bean name="JNDI" class="java.util.Hashtable">
           <constructor class="java.util.Map">
           <map class="java.util.Hashtable" keyClass="java.lang.String" valueClass="java.lang.String">
           <entry> <key>java.naming.factory.initial</key> <value>org.jnp.interfaces.NamingContextFactory</value>
           </entry>
           <entry>
           <key>java.naming.provider.url</key>
           <value>jnp://localhost:1099</value>
           </entry>
           <entry>
           <key>java.naming.factory.url.pkgs</key>
           <value>org.jboss.naming:org.jnp.interfaces"</value>
           </entry>
           </map>
           </constructor>
          </bean>
          


          "jmesnil" wrote:

          Where can I find an example/doc about that?

          There is no such (exact) example.
          Unless you expect us to cover every bean possible. :-)

          • 2. Re: Hashtable Bean in microcontainer XML configuration
            jmesnil

             

            "alesj" wrote:

            There is no such (exact) example.
            Unless you expect us to cover every bean possible. :-)


            Isn't that too much too ask? ;)

            Thansk for the answer Ales, I did not know about the install element but I should have thought about using the Hashtable's constructor to populate my properties.