Also another thing that poped out.
In the XSD the property is defined like this:
<xsd:element name="property"> <xsd:annotation> <xsd:documentation xml:lang="en">A simple name-value pair.</xsd:documentation> </xsd:annotation> <xsd:complexType> <xsd:complexContent> <xsd:extension base="xsd:anyType"> <xsd:attribute name="name" use="required" type="xsd:string"/> <xsd:attribute name="value" type="xsd:string"/> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:element>
But in the Message Action Guide we have this section:
<action name="routeAction? class="org.jboss.soa.esb.actions.StaticRouter"> <property name="destinations"> <route-to service-category="ExpressShipping" service-name="ExpressShippingService"/> <route-to service-category="NormalShipping" service-name="NormalShippingService"/> </property> </action>
Which off course works fine, and guess what, I have to generate exactly this kind of code :(. But I can't, because the Property class only knows about the XSD definition (Name + Value, both String).
Unfortunately, I don't have any help/answers for your inquiry but I do have a related question. :-)
Why are you doing this? Are you building tool to generate a jboss-esb.xml for developers? End-users?
I am building a tool that will generate an entire jboss-esb.xml file. In fact it will generate later on an entire .esb archive & deploy it on a JBoss Server (that means also some other xml files will need generated...).
Unfortunatelly I stumbled upon those 2 problems, which so far have no answer.
One question. Do the jboss-esb.xml you're using for samples & so on pass the validation against the XSD? Since I have found no "route-to" element described in the XSD, my guess would be "no"?
1. In fact the entire jbossesb-xml is validated against the xsd.
2. The action configuration takes properties. That's all what is validated. I mean if you take a look at:
<property name="destinations"> <route-to service-category="ExpressShipping" service-name="ExpressShippingService"/> <route-to service-category="NormalShipping" service-name="NormalShippingService"/> </property>
You can see this action only has one property with name "destination". They maker of the action may decide what needs to go IN the property.
Here we have 2 route-to subelements. The subelements are NOT in the xsd, only the property element is.
3. an ftp-provider is a provider as defined in the xsd:
<xsd:element name="ftp-provider" substitutionGroup="jesb:provider">
So xmlbeans is somewhat right to turn this into a provider. I'm a little surprised though that it wouldn't take the more specific version of the provider (ftp-provider) when it writes out the xml. This may be an xmlbeans bug.
In our next major release we will likely move to JAXB. So you could try using that, maybe it will give you better results.
Well hopefully this will help you in the right direction.
Yes, I saw that you can put all kind of stuff into the property, which is ok, and we have used it to define some stuff too, my problem is that in the XSD the property element is defined as having 2 attributes: name & value (as i mentioned in a previous post). And that the Property java object (which was generated from the XSD, as far as I know about xmlbeans) contains methods for those two attributes. So, the java code doesn't allow me to add inner XML code to the property. And in fact that is what I would need. So the Property class has to change a bit?
About the other objects: The behavior is similar in many of them. I tried for example to "print" each object as it gets populated, and the result differ very much.
See here is some code extracted from various objects:
This would be the Java code, and below is the result.
//jmsBus is a JmsBusDocument.JmsBus object already filled with data System.out.println("#1"); JmsBusDocument jmsBusDoc = JmsBusDocument.Factory.newInstance(); jmsBusDoc.setJmsBus(jmsBus); System.out.println(jmsBusDoc.toString()); System.out.println("#2"); jmsProvider.getBusList().add(jmsBus); JmsProviderDocument jmsProviderDoc = JmsProviderDocument.Factory.newInstance(); jmsProviderDoc.setJmsProvider(jmsProvider); System.out.println(jmsProviderDoc.toString()); System.out.println("#3");
And the result:
#1 // -> here the tag is correct (jms-bus) <jms-bus busid="myJmsQueue" xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"> <jms-message-filter dest-name="queue/myJmsQueue" dest-type="QUEUE"/> </jms-bus> #2 // -> here the tag is no longer correct (bus). But it keeps all the attributes <jms-provider name="myJmsQueue" connection-factory="ConnectionFactory" jndi-context-factory="org.jnp.interfaces.NamingContextFactory" jndi-URL="localhost" jndi-pkg-prefix="" xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"> <bus busid="myJmsQueue"> <jms-message-filter dest-name="queue/myJmsQueue" dest-type="QUEUE"/> </bus> </jms-provider> #3
If I extract code from a parent of the JmsProvider then also the jms-provider tag changes into provider. I don't know if it's an xmlbeans bug or is something from inside you're code, I started to play with xmlbeans a few days ago.
I'll probably take a look at JAXB, although I can generate the file by using a plain StringBuffer as well.
I have two comments:
1. It's the 'value' that is set in the property tags. If that is not clear in the xsd then we should fix that.
2. All the classes (like JmsBusDocument) are generated from the xsd using xmlbeans. So it's not really our code..
you can always modify the underlying xml (if you want to add "custom content") by getting the XmlBeans objects' domNode and working from there.. ie
Element elm = (Element)jmsBus.getDomNode();
.. standard dom manipulation stuff, add attributes, children etc. ...
Hope this helps!
thanks, that helps me with the problem mentioned in the #2 post. I still don't have any solution for the problem mentioned in my #1 post...
I was looking at creating a JAXB model for the Eclipse tooling stuff, so we may want to coordinate on this. I know you can feed JAXB an XSD and it will generate an annotated object model. It does handle the xsd:anyType elements pretty well (hands you a generic DOM node if I remember). Anyway, I am supposed to be porting the existing Flex config editor over to Eclipse in the next couple of weeks, so we may be able to share the underlying JAXB model.
Thanks Derek. An Eclipse plug-in would be a great way to go with this.
i am new to Jbossesb, i want to create one esb service where i want to read FTP parameters from database whenever there is any change in the ftp parameters (hostname, username, password, diractory etc) in database configuration file jboss-esb.xml should be updated automatically.
If any one can provide me sample code to implement this would be very much helpfull for me.
Thanks in advance.