Back to Use Encoders In POJOSE, or Use Encoders In POJOSE Info
| At line 11 added 3 lines. |
| ** [Create a POJO Class|UseEncodersInPOJOSE#CreateAPOJOClass] |
| ** [Include Jar Files for Custom Encoder|UseEncodersInPOJOSE#IncludeJarFilesForCustomEncoder] |
| ** [Invoke Decoding in POJO|UseEncodersInPOJOSE#InvokeDecodingInPOJO] |
| At line 19 added 1 line. |
| * [Source Code|UseEncodersInPOJOSE#SourceCode] |
| At line 43 changed 11 lines. |
| To test the invocation of the custom encoder in POJO SE, we need to have a XSD metadata with custom encoding information and input data in native format. In this sample, we'll create a custom defined structure with encoding information and a sample text delimited data as input. |
| [{Image src='image005.png'align='top' }] |
| Let’s name this custom defined structure as “customDefined1”. This will create the customDefined1.xsd file in the specified location. |
| [{Image src='image007.png'align='top' }] |
| Apply custom encoding. |
| [{Image src='image009.png'align='top' }] |
| As an example, we have following structure defined (the root node contains 2 groups nodes “group1” and “group2” which are delimited by the delimiter of ‘|’. The first group node contains 2 delimited fields “delimited1” and “delimited2” which are delimited by the delimiter of ‘,’, and the second group node contains 2 fixed-length fields “fixed1” and “fixed2” which are 10 and 15 bytes long, respectively) with custom encoding information. |
| [{Image src='image011.png'align='top' }] |
| The root node is selected as the “Top” node, and there are 2 levels of delimiters defined there as follows: |
| [{Image src='image013.png'align='top' }] |
| You can click on the double-down arrow to validate the customDefine1.xsd for XML conformity. |
| To test the invocation of the custom encoder in POJO SE, we need to have a XSD metadata with custom encoding information and input data in native format. |
| Please refer to [Create a Custom Structure and Test it] for creating the sample custom defined structure and test it using Encoder Tester. |
| At line 55 removed 10 lines. |
| ! Launch the Encoder Tester |
| Launch the Encoder Tester to test customDefine1.xsd on an input data. As an example, we create a text delimited input data file “customDefined1.dat” with data “a,b|0123456789|abcde12345ABCDE”. |
| [{Image src='image015.png'align='top' }] |
| Then launch the tester by right clicking on the xsd and selecting "Encoding -> Test". |
| [{Image src='image017.png'align='top' }] |
| Select input data file “customDefined1.dat” in the "Test Encoding" dialog. |
| [{Image src='image019.png'align='top' }] |
| After successful decoding, you should see the decoded XML output as “customDefined1.xml" |
| [{Image src='image021.png'align='top' }] |
| \\ |
| At line 52 added 1 line. |
| !! Invoke Custom Encoder in POJO SE |
| At line 79 changed 1 line. |
| * Input: String |
| * Input: String (text delimited message) |
| * Return type: String (decoded XML, or Decoding Exception Details) |
| At line 84 changed 1 line. |
| ! Include Jar Files for the Custom Encoder |
| ! Include Jar Files for Custom Encoder |
| At line 86 changed 1 line. |
| Now we need to include the set of jars for the custom encoder into the POJO java project. |
| Please refer to [Include Jar Files for Custom Encoder] for details on how to include the set of jars for the custom encoder into the POJO java project. |
| At line 88 changed 17 lines. |
| Unzip the encoderlib.jar (which may be found in $GlassFishESB_INSTALL_ROOT\glassfish\addons\jbi-components\encoderlib.jar) which contains following 6 jar files into a temporary directory. |
| [{Image src='image031.png'align='top' }] |
| The list of jar files are: |
| # custom.jar |
| # customencoder-xsdextension.jar |
| # encoderfrmwk-xsdextension.jar |
| # encoderfwrt.jar |
| # jsr173_api.jar |
| # xbean.jar |
| Now add these 6 jars files into the Libraries of the POJO java project. |
| [{Image src='image033.png'align='top' }] |
| You should now see these jars are included in the “Libraries” in the POJO java project. |
| [{Image src='image035.png'align='top' }] |
| ! Invoke Decoding in POJO |
| At line 445 added 7 lines. |
| !! Source Code |
| \\ |
| The complete NetBean Projects are available to download from [here (zip)|UseEncoderInPojose.zip] |
| \\ |
| * Any questions/feebacks? |
| \\ |
| Please email: [soabi-encoders@sun.com|mailto:soabi-encoders@sun.com] |