0

I am building a Java application using JPA2 and Hibernate 4.0 I have a XML file describing the complex data types that the APIs take as input or give as output. Sample below. I want to use this XML to generate java classes (or a jar) that I can use in my APIs as parameters and return types. Also I want to put in this jar in the SpringMVC powered front end so that I may use these types to attach data to call my APIs with. I can change the format of the XML if needed. What tool(s) can I use for this. I don't write this XML to be mentioned in my APIs or any other code, the tool should let me create stubs and then forget about the XML.

  <documentation target="loginValidation" >
    Returns the result of login validation.
    Will return LoginValidationResults object if login correct, else a null object.
  </documentation>  
  <operation name="loginValidation">
    <input target="LoginValidationArgs" />
    <output target="LoginValidationResults" />
  </operation>

  <structure name="LoginValidationArgs">
    <member name="userName" target="String" />
    <member name="hashedPassword" target="String" />
    <member name="schoolID" target="PositiveInteger" />
  </structure>
  <required target="LoginValidationArgs$schoolID" />
  <required target="LoginValidationArgs$userName" />
  <required target="LoginValidationArgs$hashedPassword" />

  <structure name="LoginValidationResults">
    <member name="userID" target="PositiveInteger" />
    <member name="userType" target="String" />
    <member name="userDisplayName" target="String" />
    <member name="schoolID" target="Long" />
  </structure>
  <required target="LoginValidationResults$schoolID" />
  <required target="LoginValidationResults$userID" />
  <required target="LoginValidationResults$userType" />
  <required target="LoginValidationResults$userName" />
user1755645
  • 935
  • 2
  • 13
  • 22

1 Answers1

1

Look at my answer to a similar, but not duplicate, question

The answer is to use Eclipse's M2T-JET. That's what it was designed and built for.

Community
  • 1
  • 1
Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
  • Thanks, I am looking into M2T-JET. Does this sound like a good representation of my parameter/return data types ? – user1755645 Nov 02 '12 at 20:30
  • I would model the information you need to type in to the source (think fill in the blank) as that will make for easy templating (This is the implementation model and only contains things that are different from class to class). If you have a different model, perhaps a higher-level or architectural model in mind, then I would transform that model into the first "implementation" model before invoking JET. So I turn the question back to you. Are these the strings you'd expect to see in the generated code? If so, then you've probably modeled it correctly. – Chris Gerken Nov 02 '12 at 20:36
  • Yup that's the end parameter/ return types I want to use in my APIs. – user1755645 Nov 02 '12 at 20:43