-
1. Re: Generate jboss-esb.xml using XmlBeans
anescu Sep 10, 2007 11:37 AM (in response to anescu)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).
Help! Anybody? -
2. Re: Generate jboss-esb.xml using XmlBeans
burrsutter Sep 10, 2007 3:03 PM (in response to anescu)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?
Burr -
3. Re: Generate jboss-esb.xml using XmlBeans
anescu Sep 11, 2007 4:20 AM (in response to anescu)Yes,
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"? -
4. Re: Generate jboss-esb.xml using XmlBeans
kurtstam Sep 11, 2007 9:57 AM (in response to anescu)Hi Anescu,
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.
--Kurt -
5. Re: Generate jboss-esb.xml using XmlBeans
anescu Sep 11, 2007 10:26 AM (in response to anescu)Hello Kurt,
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. -
6. Re: Generate jboss-esb.xml using XmlBeans
kurtstam Sep 11, 2007 10:32 AM (in response to anescu)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..
--Kurt -
7. Re: Generate jboss-esb.xml using XmlBeans
omatzura Sep 11, 2007 10:42 AM (in response to anescu)Hi,
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!
regards,
/Ole
eviware.com -
8. Re: Generate jboss-esb.xml using XmlBeans
anescu Sep 11, 2007 10:47 AM (in response to anescu)Hello,
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... -
9. Re: Generate jboss-esb.xml using XmlBeans
derek.adams Sep 11, 2007 11:27 AM (in response to anescu)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.
-
10. Re: Generate jboss-esb.xml using XmlBeans
marklittle Sep 11, 2007 11:42 AM (in response to anescu)Thanks Derek. An Eclipse plug-in would be a great way to go with this.
-
11. Re: Generate jboss-esb.xml using XmlBeans
ashok_1979 Oct 7, 2008 10:29 AM (in response to anescu)Hi All,
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.