How do I configure a binding set without having it injected in JBoss EAP 5.x

Solution Verified - Updated -

Environment

JBoss Enterprise Application Platform (EAP) 5.1.2

Issue

  • Is there a way to configure the binding set so that it only injects the bean for the binding set the running instance has selected? We need a a global template which ties applications to specific binding sets and are looking to have hundreds of instances installed.
  • Is there a best practise guide for configuring the Service Binding Manager (SBM) in EAP 5?

Resolution

1) Edit $JBOSS_HOME/server/$PROFILE/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml and add

   .. .. ..
   <bean name="ServiceBindingManager" class="org.jboss.services.binding.ServiceBindingManager">
    .. .. ..
    .. .. ..
   </bean>

    <bean name="CustomOffsetMap"  class="java.util.Hashtable">
      <constructor>
        <map class="java.util.Hashtable" keyClass="java.lang.String" valueClass="java.lang.String">

          <entry>
              <key>ports-default</key>
               <value>0</value>
          </entry>
          <entry>
              <key>ports-training</key>
               <value>100</value>
          </entry>
          <entry>
              <key>ports-qa</key>
              <value>200</value>
          </entry>
         </map>
        </constructor>
     </bean>
    .. .. ..
    .. .. ..
   <bean name="ServiceBindingManagementObject" 
         class="org.jboss.services.binding.managed.ServiceBindingManagementObject">

      <constructor>
         <!-- The name of the set of bindings to use for this server -->
         <parameter>${jboss.service.binding.set:ports-default}</parameter>

         <!--  The binding sets -->
         <parameter>
            <set>
               <inject bean="PortsDefaultBindings"/>
               <inject bean="SystemPropertiesConfigured"/>
            </set>
         </parameter>

         <!-- Base binding metadata that is used to create bindings for each set -->
         <parameter><inject bean="StandardBindings"/></parameter>

      </constructor>
   </bean>

  <bean name="SystemPropertiesConfigured"  class="org.jboss.services.binding.impl.ServiceBindingSet">
        <constructor>
         <parameter>${jboss.service.binding.set:ports-default}</parameter>
         <parameter>${jboss.bind.address}</parameter>
         <parameter>
            <value-factory bean="CustomOffsetMap" method="get">
                 <parameter>${jboss.service.binding.set:ports-default}</parameter>
            </value-factory>
          </parameter>
          <parameter><null/></parameter>
       </constructor>
   </bean>
   <!-- The ports-default bindings are obtained by taking the base bindings and adding 0 to each port value  -->
   <bean name="PortsDefaultBindings"  class="org.jboss.services.binding.impl.ServiceBindingSet">
      <constructor>
         <!--  The name of the set -->
         <parameter>ports-default</parameter>
         <!-- Default host name -->
         <parameter>${jboss.bind.address}</parameter>
         <!-- The port offset -->
         <parameter>0</parameter>
         <!-- Set of bindings to which the "offset by X" approach can't be applied -->
         <parameter><null/></parameter>
      </constructor>
   </bean> 
   .. .. ..
   .. .. ..

2) Start the jboss instance with selecting the preferred binding set e.g

./run.sh -c QA-Profile -Djboss.service.binding.set=ports-qa 

or

./run.sh -c UAT-Profile  -Djboss.service.binding.set=ports-uat

Key things to note:
1) Port offset configured in section CustomOffsetMap
2) SystemPropertiesConfigured
3) PortsDefaultBindings is the only binding set, from the default configuration, that needs to remain

Attachments

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.