Reading system (mbean) property in smooks configuration
rimarvladimir Apr 8, 2011 9:33 AMHi 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