X hits on this document

364 views

0 shares

0 downloads

0 comments

99 / 120

XML in preparation to use the JNI XML bridge to the legacy COBOL application. Table

9.5 contains an abbreviated listing of the updated to JsimpleCalculator.java. Note that

the call to method smplCalcXmlInterface is commented out. This is a call to the JNI

XML bridge which will be implemented in a later step.

Table 9.5. Updates to JSimpleCalculator.java in support of JAXB marshalling.

01: public long doAdd(int

1stOp, int

2ndOp)

_

_

02: 03:

{

SMPLCALCINTERFACE addResult = invokeXmlInterface("+",

1stOp,

_

2ndOp);

_ 04: 05: 06:

}

return addResult.getSIRESULT().longValue();

createSMPLCALCINTERFACE();

10: 11: 12: 13: 14: 15:

inputData.setSIOPERATION(calcType); inputData.setSIOPERAND1(BigInteger.valueOf(_1stOp)); inputData.setSIOPERAND2(BigInteger.valueOf(_2ndOp)); inputData.setSIRESULTMESSAGE(""); inputData.setSIRESULT(BigInteger.valueOf(0)); String inputXml = SmplCalcJaxbMarshaller.serializeXML(inputData);

16: 17:

// TODO JNI: String outputXml = smplCalcXmlInterface(inputXml); SMPLCALCINTERFACE outputData = SmplCalcJaxbMarshaller.

loadXML(outputXml);

18:

return outputData;

19:

}

07: public SMPLCALCINTERFACE invokeXmlInterface(String calcType, int

new SmplCalcJaxbFactory().

=

1stOp, int

2ndOp)

_ 08: 09:

SMPLCALCINTERFACE inputData

{

_

  • 6)

    Write a small C/C++ JNI program Java2CblXmlBridge.cpp which exports a method “Java2SmplCalc” which:

    • a)

      Invokes XML2CALC.cbl (see Step 7), passing the XML document received from JSimpleCalculator.java.

    • b)

      Returns the XML document generated by XML2CALC.cbl (see Step 7) on return from SMPLCALC.cbl to JSimpleCalculator.java Sun's Java SDK includes the command-line utility javah that generates

appropriate C/C++ header files for a native method declaration in a Java class. The

91

Document info
Document views364
Page views365
Page last viewedThu Dec 08 10:10:10 UTC 2016
Pages120
Paragraphs2913
Words25794

Comments