2 Replies Latest reply on May 3, 2011 3:57 AM by Vladimir Rimar

    Reading system (mbean)  property in smooks configuration

    Vladimir Rimar Newbie

      Hi all,

       

      Is it possible to read a property defined as an MBean in Smooks config file? Based on documentation, specific environment (dev, prod) properties should be defined in SystemPropertiesService. This approach has worked for me in the past projects, but now I have a problem.

       

      Below is the MBean configuration

       

      <server>
      
        <!--=========================================================================  -->
        <!-- Netcool EventPublisher - Property Service for DEVELOPMENT ENVIRONMENT     -->
        <!--=========================================================================  -->
          <mbeancode="org.jboss.varia.property.SystemPropertiesService"
             name="com.xxx.nep:type=Service,name=nepProperties">
             <attribute name="Properties">
                 nep.tibcoEndpointURL=http://localhost:8088/tibco
                 nep.objectServer=CAMIP_SCS
              </attribute>
         </mbean>
      
      </server>
      

       

      ASAIK, in jboss-esb.xml you can simply use placeholders in order to get the value of the attribute. This actually works great.

      e.g.:

      <service name="event-publisher-webservice-consumer" category="nep" description="Webservice Requests to TIBCO" invmScope="GLOBAL">
          <actions mep="OneWay">
              <action class="org.jboss.soa.esb.actions.SystemPrintln" name="println: createTroubleTicketByValueRequest">
                  <property name="message" value="TIBCO:createTroubleTicketByValueRequest" />
              </action>
      
              <action class="com.frox.nep.scs.tibco.ws.consumer.CustomHttpRouter" name="tibco-ws-request-createTT">
                  <property name="method" value="POST" />
                  <property name="endpointUrl" value="${nep.tibcoEndpointURL}" />
              </action>
      

       

      I'm now trying to read the variable (nep.objectServer) in Smooks config. Is this the correct approach?

      <?xml version="1.0" encoding="UTF-8"?>
      <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
          xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
          xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd"
          xmlns:frag="http://www.milyn.org/xsd/smooks/fragment-routing-1.2.xsd"
          xmlns:esbr="http://www.jboss.org/xsd/jbossesb/smooks/routing-1.0.xsd">
      
          <!-- Create the split messages for each order item... -->
          <frag:serialize fragment="/map/entry/map" bindTo="singleObjectServer" />
      
          <!-- Capture some data from each order item… used in routing conditional... -->
          <jb:bean beanId="oServer" class="java.util.HashMap" createOnElement="/map/entry">
              <jb:value property="osName" data="/map/entry/string"/>
          </jb:bean>
      
          <esbr:routeBean routeOnElement="/map/entry" beanIdRef="singleObjectServer" toServiceCategory="nep" toServiceName="event-publisher-mapper-1">
              <condition><!-- oServer.osName == ${nep.objectServer} --></condition>
          </esbr:routeBean>
      

       

      If I hard-code the oServer.osName, then it works fine:

      <esbr:routeBean routeOnElement="/map/entry" beanIdRef="singleObjectServer" toServiceCategory="nep" toServiceName="event-publisher-mapper-1">
              <condition><!-- oServer.osName == 'CAMIP_SCS' --></condition>
          </esbr:routeBean>
      

       

      If anyone has an experience how to read the MBean attribute in Smooks configuration, I would be happy to hear the answer. Other suggestions would be appreciated as well.

       

      Thanks a lot for the replies,

       

      Vladimir

        • 1. Reading system (mbean)  property in smooks configuration
          Tom Fennelly Master

          If I understand what you are asking here... I think you'd need to implement a custom Smooks Visitor extension to lookup the MBean and bind it into the Smooks BeanContext.  See the smooks user guide for details on implementing a custom visitor.

          1 of 1 people found this helpful
          • 2. Re: Reading system (mbean)  property in smooks configuration
            Vladimir Rimar Newbie

            Hello Tom,

             

            I have also looked at Smooks custom vistior, but it does not seem it can handle my requirement. The sample is simply replacing xml tag in a sample message, I'm not really looking for that. Basically the example is modifying JBoss message, but I need to modify Smooks config file, based on configured MBean.

             

            At the end I have found the solution that is working:

            <?xml version="1.0" encoding="UTF-8"?>
            <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
                xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
                xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd"
                xmlns:frag="http://www.milyn.org/xsd/smooks/fragment-routing-1.2.xsd"
                xmlns:esbr="http://www.jboss.org/xsd/jbossesb/smooks/routing-1.0.xsd">
            
                <!-- Create the split messages for each order item... -->
                <frag:serialize fragment="/map/entry/map" bindTo="singleObjectServer" />
            
                <!-- Capture some data from each order item… used in routing conditional... -->
                <jb:bean beanId="oServer" class="java.util.HashMap" createOnElement="/map/entry">
                    <jb:value property="osName" data="/map/entry/string"/>
                </jb:bean>
            
                <esbr:routeBean routeOnElement="/map/entry" beanIdRef="singleObjectServer" toServiceCategory="nep" toServiceName="event-publisher-mapper-1">
                     <condition>
                        <!-- oServer.osName == System.getProperty("ftsm.nco.server.name-1") -->
                    </condition>
                </esbr:routeBean>
            
                <esbr:routeBean routeOnElement="/map/entry" beanIdRef="singleObjectServer" toServiceCategory="nep" toServiceName="event-publisher-mapper-2">
                     <condition>
                        <!-- oServer.osName == System.getProperty("ftsm.nco.server.name-2") -->
                    </condition>
                </esbr:routeBean>
            
            </smooks-resource-list>