How To... Cr eat e Modul es f or t he J EE Adapt er Engi ne
Appl i c abl e Rel eases: SAP Net Weaver Pr oc ess I nt egr at i on 7.1
Topi c Ar ea: SOA Mi ddl ew ar e Capabi l i t y: Ser vi c e Bus
Ver si on 1.1 J une 2008
Copyright 2008 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, OpenPower and PowerPC are trademarks or registered trademarks of IBM Corporation. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages. SAP NetWeaver How-to Guides are intended to simplify the product implementation. While specific product features and procedures typically are explained in a practical business context, it is not implied that those features and procedures are the only approach in solving a specific business problem using SAP NetWeaver. Should you wish to receive additional information, clarification or support, please refer to SAP Consulting. Any software coding and/or code lines / strings (Code) included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent. Disclaimer Some components of this product are based on Java. Any code change in these components may cause unpredictable and severe malfunctions and is therefore expressively prohibited, as is any decompilation of these components. Any Java Source Code delivered with this product is only to be used by SAPs Support Services and may not be modified or altered in any way.
Doc ument Hi st or y Document Version Description 1.10 Update for PI 7.1 1.00 First official release of this guide
Typogr aphi c Convent i ons Type Style Description Example Text Words or characters quoted from the screen. These include field names, screen titles, pushbuttons labels, menu names, menu paths, and menu options. Cross-references to other documentation Example text Emphasized words or phrases in body text, graphic titles, and table titles Exampl e t ext File and directory names and their paths, messages, names of variables and parameters, source text, and names of installation, upgrade and database tools. Example text User entry texts. These are words or characters that you enter in the system exactly as they appear in the documentation. <Example text> Variable user entry. Angle brackets indicate that you replace these words and characters with appropriate entries to make entries in the system. EXAMPLE TEXT Keys on the keyboard, for example, F2 or ENTER. I c ons Icon Description
Caution
Note or Important
Example
Recommendation or Tip
Tabl e of Cont ent s 1. Business Scenario............................................................................................................... 1 2. Background Information..................................................................................................... 1 3. Prerequisites ........................................................................................................................ 2 4. Step-by-Step Procedure...................................................................................................... 3 4.1 Obtain the library (or jar) files necessary for development........................................... 3 4.2 Include the jar files in the library classpath of SAP Netweaver Developer Studio....... 3 4.3 Create EJ B and EAR projects for the User-Module..................................................... 5 4.4 Create an Enterprise Bean in the EJ B project.............................................................. 9 4.5 Examine and verify the content of ejb-jar.xml ............................................................ 12 4.6 Enter the J NDI name in the ejb-j2ee-engine.xml........................................................ 13 4.7 Include external libraries in the EJ B project so the java class can be compiled........ 13 4.8 Enter the code for GetHostNameBean....................................................................... 16 4.9 Delete the package containing the Local and Remote interfaces from the build....... 17 4.10 Configure the EAR project.......................................................................................... 18 4.11 Setting target server for deployment.......................................................................... 22 4.12 Deploy the EAR file .................................................................................................... 24 5. Test Landscape.................................................................................................................. 27 6. Appendix ............................................................................................................................ 32
How To... Create Modules for the J EE Adapter Engine 1. Busi ness Sc enar i o There are occasions when the features of the default adapters cannot handle the specific needs of data formatting and handling from/to source or target systems. An example is the decryption of data before it is sent to SAP NetWeaver Process Integration for processing. When those special data handlings are required, the adapters can be enhanced using the user- module (or, user exits). This session walks through the process of developing and testing adapter user modules.
2. Bac k gr ound I nf or mat i on A message from the Integration Server is received in the Adapter Framework by the messaging service. Based on the receiver information, the corresponding module chain is selected for further processing. The Adapter Framework contains two default module chains: one for the sender/inbound direction and one for the receiver/outbound direction. You can use these default module chains for the adapter if the entire message processing is executed within the adapter. You can enhance the default module chains with customer-specific modules. The module processor controls the steps in the module chain by calling generic and, if defined, adapter-specific modules. The last module in the module chain forwards the message to the adapter. The adapter transfers the message to the connected system. Message processing in the sender/inbound direction proceeds in a similar way. The adapter calls the module processor in the form of an EJ B 2.1 local session bean and transfers the message object either as a PI message, or in its own format. If the message object is transferred in its own format, it must be converted to a PI message in an adapter-specific module.
In this exercise, we will use a user-module to retrieve the hostname where the adapter is running. The hostname will be appended as the last XML element of the message. The element name containing the hostname value, by default, is HostName. This element name can be configured by using the module parameter HostElementName. J une 2008 1 How To... Create Modules for the J EE Adapter Engine 3. Pr er equi si t es The prerequisites are as follows: Software NWDS 7.1 SP3 is minimum J 2EE engine running on jre 1.5.0_06 PCK 7.0 Hardware At least 2GB of RAM
For more information about the Adapter module development in PI 7.1, see SAP Help Portal at help.sap.com SAP NetWeaver SAP NetWeaver 7.1. In the documentation, choose SAP NetWeaver Process Integration Library IT Scenarios at a Glance Enabling Application-to- Application Processes. Scroll down to section Further Informationdevelopment, and enter the SAP NetWeaver Developer's Guide under Enabling Application-to-Application Processes. Go to Tasks Designing A2A Processes. Here you find links pointing to Configuring the A2A Processes-> Developing Adapter Modules section. This gives information about adapter module development.
J une 2008 2 How To... Create Modules for the J EE Adapter Engine 4. St ep-by-St ep Pr oc edur e 4.1 Obt ai n t he l i br ar y (or j ar ) f i l es nec essar y f or devel opment ... In order to develop the user-module locally on the NW Developer Studio on your laptop, some PI libraries will be required. These libraries must be included in the java classpath during development. The libraries, or jar files, have to be taken from an existing SAP PI/PCK 7.1 installation. Find the library files in following folders: com.sap.aii.af.lib.mod.jar: <bin>/ext/com.sap.aii.af.lib/lib sap.com~tc~logging~java~impl.jar: <bin>/system com.sap.aii.af.svc_api.jar: <bin>/services/com.sap.aii.af.svc/lib com.sap.aii.af.cpa.svc_api.jar: <bin>/services/com.sap.aii.af.cpa.svc/lib com.sap.aii.af.ms.ifc_api.jar: <bin>/interfaces/com.sap.aii.af.ms.ifc/lib
<bin>=/usr/sap/<SID>/J 01/j2ee/cluster/bin on a SAP PCK 7.1 installation. Create a temporary folder as C:/temp/AdapterJars adding all the jars above.
4.2 I nc l ude t he j ar f i l es i n t he l i br ar y c l asspat h of SAP Net w eaver Devel oper St udi o Open up NW Developer Studio and follow the following steps Navigate to Windows Preference. In the Preference window (as shown below), expand Java, and select Classpath Variables. Click New to create a new variable entry: PI_AF_LIBS. And, assign the directory containing the jar files we extracted: C:/temp/AdapterJars. Not e In J ava, / is used for directory path. Click OK, to exit the Preferences window.
J une 2008 3 How To... Create Modules for the J EE Adapter Engine
J une 2008 4 How To... Create Modules for the J EE Adapter Engine 4.3 Cr eat e EJ B and EAR pr oj ec t s f or t he User - Modul e ... In SAP NetWeaver Developer Studio, follow the steps below: 1. Create a new project by using the menu: File New Project Select EJB EJB Project. Click "Next".
CAUTI ON The user module still uses EJ B 2.x, therefore we must not select EJ B 3.0.
J une 2008 5 How To... Create Modules for the J EE Adapter Engine 2. Assign project names to the EJ B and EAR projects. EJ B Project Name: UserModule_EJB. EAR Project Name: UserModule_EAR (check the option to add EAR project). Click "Next".
J une 2008 6 How To... Create Modules for the J EE Adapter Engine 3. Choose the correct EJ B version. Configure Module Project as SAP EJB J2EE 1.4 Project. Choose the EJ B Module 2.1. Click "Next".
J une 2008 7 How To... Create Modules for the J EE Adapter Engine 4. Uncheck the flag to create the EJ B client jar interfaces. Click "Finish".
Not e Please note, 2 projects will be created, an EJ B project (UserModule_EJB) and an EAR project (UserModule_EAR).
J une 2008 8 How To... Create Modules for the J EE Adapter Engine 4.4 Cr eat e an Ent er pr i se Bean i n t he EJ B pr oj ec t ... 1. Right-click on the UserModule_EJB. 2. Select: New EnterpriseBean.
J une 2008 9 How To... Create Modules for the J EE Adapter Engine 3. Create the package and class for the EJ B project EJ B Name: GetHostName. Bean Type: Select the dropdown Stateless Session Bean. Give a default EJ BPackage: com.sap.adaptermodule. Uncheck option: generate default interfaces. Check option: add optional interfaces. Click "Next".
J une 2008 10 How To... Create Modules for the J EE Adapter Engine 4. Assign user-module interfaces. Use the following values to assign to the parameters in the screen below: Remote interface: com.sap.aii.af.lib.mp.module.ModuleRemote Home interface: com.sap.aii.af.lib.mp.module.ModuleHome Local interface: com.sap.aii.af.lib.mp.module.ModuleLocal LocalHome interface: com.sap.aii.af.lib.mp.module.ModuleLocalHome Uncheck option: Service End point Click Finish
J une 2008 11 How To... Create Modules for the J EE Adapter Engine 4.5 Ex ami ne and ver i f y t he c ont ent of ej b-j ar .x ml ... 1. On the left panel, navigate: EJB project ejbModule META-INF. 2. Double click on the "ejb-jar.xml".
3. When the ejb-jar.xml is displayed on the right panel, select the "Enterprise Beans" tab at the bottom. 4. Expand "Session Beans" and select "GetHostName".
5. All the local and remote interfaces should be displayed. The Service endpoint should be empty. J une 2008 12 How To... Create Modules for the J EE Adapter Engine 4.6 Ent er t he J NDI name i n t he ej b-j 2ee-engi ne.x ml ... 1. On the left panel, double click on the "ejb-j2ee-engine.xml".
2. "Ejb-j2ee-engine.xml" will be displayed on the right panel. 3. Expand Session beans and click on GetHostName. 4. Enter the J NDI Name: GetHostName. 5. Save the file.
4.7 I nc l ude ex t er nal l i br ar i es i n t he EJ B pr oj ec t so t he j ava c l ass c an be c ompi l ed ... 1. Right click on the EJ B project. 2. Navigate to "Build Path". J une 2008 13 How To... Create Modules for the J EE Adapter Engine 3. Select "Configure Build Path".
4. In the Properties dialogue box, click the "Add Variable".
J une 2008 14 How To... Create Modules for the J EE Adapter Engine 5. Select the variable, "PI_AF_LIBS", created earlier. 6. Click on "Extend".
7. Select all the files and click on Ok.
J une 2008 15 How To... Create Modules for the J EE Adapter Engine 8. On the Properties screen click Ok.
4.8 Ent er t he c ode f or Get Host NameBean ... 1. Double click on the "GetHostNameBean".
The J ava program will be displayed on the right hand panel.
J une 2008 16 How To... Create Modules for the J EE Adapter Engine 2. Copy-n-paste the J ava source program GetHostNameBean.java from Appendix on the source code panel. 3. Save the file.
4.9 Del et e t he pac k age c ont ai ni ng t he Loc al and Remot e i nt er f ac es f r om t he bui l d When we created the Enterprise Beans, we entered the Local and Remote interfaces. These interfaces already exist in the adapter framework, therefore, we must exclude the ones created by NWDS from the build. ... 1. Expand the build folder in the EJ B project. 2. Delete all the folders created under build classes com sap.
I mpor t ant Do not delete the folder which has the build class of the bean you created. Rest of all other folders under com sap path should be deleted.
J une 2008 17 How To... Create Modules for the J EE Adapter Engine
Not e If you do not see the com/sap/ folder, this means that the project has not been built. You can build the project by right-click on the EJ P project, e.g. "UserModule_EJB", and select Build. The Project Build Automatically on the top menu will need to be turned off in order to see the Build in "UserModule_EJB".
4.10 Conf i gur e t he EAR pr oj ec t The EAR file contains the following: J AR file created from the EJ B project. It has configuration information of the libraries, services and interfaces that will be used by the user-module in the EJ B. It contains the SAP manifest file, which has unique identifiers for each specific EAR. The manifest information is generated uniquely each time it is modified.
... J une 2008 18 How To... Create Modules for the J EE Adapter Engine 1. Expand the EAR project. 2. Double-click on the "application-j2ee-engine.xml" file.
3. In the right panel, click on the Reference and then on the + sign to "Add Elements".
4. Click "Create New" in the dialog.
J une 2008 19 How To... Create Modules for the J EE Adapter Engine 5. Enter the following information in the screen: Reference target: engine.security.facade Reference type: hard Reference target type: service Provider name: sap.com
6. Repeat the steps (click on the Reference and +) for all the following:
Reference Target Reference Type Reference Target Type Provider Name engine.j2ee14.facade hard library sap.com com.sap.aii.af.svc.facade hard service sap.com com.sap.aii.af.ifc.facade hard interface sap.com com.sap.aii.af.lib.facade hard library sap.com com.sap.base.technology.facade hard library sap.com
Upon completion, the screen should appear like this:
J une 2008 20 How To... Create Modules for the J EE Adapter Engine 7. Check the option "Failover Mode". 8. Save the file.
Not e Now we are ready to deploy the file.
J une 2008 21 How To... Create Modules for the J EE Adapter Engine 4.11 Set t i ng t ar get ser ver f or depl oyment ... 1. Navigate to Windows Preference. 2. In the Preference Window, select SAP AS Java. 3. Enter the J 2EE server information. Enter the J 2EE server instance host and instance number. Register the SAP instance.
Not e Any local or remote host can be added in this manner.
Not e This server will get registered and appear in the list of SAP System Instances. J une 2008 22 How To... Create Modules for the J EE Adapter Engine 4. Click "Ok".
J une 2008 23 How To... Create Modules for the J EE Adapter Engine 4.12 Depl oy t he EAR f i l e ... 1. Right click on the EAR file. 2. Select Run As Run on Server.
J une 2008 24 How To... Create Modules for the J EE Adapter Engine 3. Click Next.
4. In the next screen ensure that the EAR project appears in the right panel under "Configured Projects". 5. Click "Next".
J une 2008 25 How To... Create Modules for the J EE Adapter Engine 6. Choose the "Web Browser". 7. Click "Finish".
8. When prompted, enter the username and password for the J 2EE engine. This will initiate the deployment of the EAR file on the J 2EE engine.
J une 2008 26 How To... Create Modules for the J EE Adapter Engine 5. Test Landsc ape In the following a landscape is set up to test the user module. In order to use PCK for testing adapters without a PI server, a loop configuration is required. This will allow PCK to be both sender and receiver of messages. StepbyStep procedure for loopback configuration ... 1. Start the PCK Use the URL: http://host:port/pck/start/index.jsp Click on PCK. Logon using user-id and password configured for pck.
Not e This user must have all the required roles required for configuration and monitoring. In example, user used is PCKUSER.
Not e Well configure a file to file scenario and include the user module in the sender channel.
2. Create a service in PCK. a. Right click on business component and click Next.
J une 2008 27 How To... Create Modules for the J EE Adapter Engine b. Click on Business Component and enter the communication component name, here HostNameService.
... 3. Create the Sender Communication Channel, here FileSenderChannel.
Set the values at different tabs in sender channel. a. Parameters - Source tab:
J une 2008 28 How To... Create Modules for the J EE Adapter Engine b. Parameters - Processing tab:
c. Module tab Include the custom module created earlier (GetHostName):
4. Create the Receiver Communication Channel, here FileReceiverChannel.
J une 2008 29 How To... Create Modules for the J EE Adapter Engine Set the values for different tabs in receiver channel. a. Parameters - Target tab:
b. Parameters Processing tab:
J une 2008 30 How To... Create Modules for the J EE Adapter Engine 5. Create the Sender Agreement and Receiver Agreement. Not e Sender Interface name and Namespace name can be anything you want. But, the names must match between the Sender and Receiver Agreements.
J une 2008 31 How To... Create Modules for the J EE Adapter Engine 6. Appendi x Appendi x A - Code Sampl e used i n t he ex ampl e package com. sap. adapt er modul e; / / Cl asses f or EJ B i mpor t j avax. ej b. Cr eat eExcept i on; i mpor t j avax. ej b. Sessi onBean; i mpor t j avax. ej b. Sessi onCont ext ; / / Cl asses f or Modul e devel opment & Tr ace i mpor t com. sap. ai i . af . l i b. mp. modul e. *; i mpor t com. sap. engi ne. i nt er f aces. messagi ng. api . *; i mpor t com. sap. engi ne. i nt er f aces. messagi ng. api . audi t l og. *; i mpor t com. sap. t c. l oggi ng. *; / / XML par si ng and t r ansf or mat i on cl asses i mpor t j avax. xml . par ser s. *; i mpor t or g. w3c. dom. *; i mpor t j ava. i o. I nput St r eam; i mpor t j ava. i o. Byt eAr r ayOut put St r eam; i mpor t j ava. net . I net Addr ess; i mpor t j ava. net . UnknownHost Except i on; i mpor t j avax. xml . t r ansf or m. *; i mpor t j avax. xml . t r ansf or m. Sour ce; i mpor t j avax. xml . t r ansf or m. Resul t ; i mpor t j avax. xml . t r ansf or m. dom. DOMSour ce; i mpor t j avax. xml . t r ansf or m. st r eam. St r eamResul t ; publ i c cl ass Get Host nameXXBean i mpl ement s Sessi onBean, Modul e { publ i c st at i c f i nal St r i ng VERSI ON_I D = " $I d: / / t c/ ai i / 30_REL/ sr c/ _adapt er s/ _sampl e/ j ava/ user / modul e/ Get Host Name. j av a#1 $" ; st at i c f i nal l ong ser i al Ver si onUI D = 7435850550539048631L; pr i vat e Sessi onCont ext myCont ext ; publ i c voi d ej bRemove( ) {} publ i c voi d ej bAct i vat e( ) {} publ i c voi d ej bPassi vat e( ) {} publ i c voi d set Sessi onCont ext ( Sessi onCont ext cont ext ) { myCont ext = cont ext ; } J une 2008 32 How To... Create Modules for the J EE Adapter Engine publ i c voi d ej bCr eat e( ) t hr ows Cr eat eExcept i on {} publ i c Modul eDat a pr ocess( Modul eCont ext modul eCont ext , Modul eDat a i nput Modul eDat a) t hr ows Modul eExcept i on { St r i ng SI GNATURE = " pr ocess( Modul eCont ext modul eCont ext , Modul eDat a i nput Modul eDat a) " ; Locat i on l ocat i on = nul l ; Audi t Access audi t = nul l ; / / Cr eat e t he l ocat i on al ways new t o avoi d ser i al i zat i on/ t r ansi ent of l ocat i on t r y { l ocat i on = Locat i on. get Locat i on( t hi s. get Cl ass( ) . get Name( ) ) ; }cat ch ( Except i on t ) { t . pr i nt St ackTr ace( ) ; Modul eExcept i on me = new Modul eExcept i on( " Unabl e t o cr eat e t r ace l ocat i on" , t ) ; t hr ow me; } Obj ect obj = nul l ; Message msg = nul l ; St r i ng host Name = get Host Name( ) ; MessageKey key = nul l ; t r y { obj = i nput Modul eDat a. get Pr i nci pal Dat a( ) ; msg = ( Message) obj ; key = new MessageKey( msg. get MessageI d( ) , msg. get MessageDi r ect i on( ) ) ; audi t = Publ i cAPI AccessFact or y. get Publ i cAPI Access( ) . get Audi t Access( ) ; audi t . addAudi t LogEnt r y( key, Audi t LogSt at us. SUCCESS, " Get Host Name: Modul e cal l ed" ) ; } cat ch ( Except i on e) { Modul eExcept i on me = new Modul eExcept i on( e) ; t hr ow me; } / / Read t he channel I D, channel and t he modul e conf i gur at i on St r i ng host El ement Name = nul l ; t r y { / / CS_GETMODDAT START J une 2008 33 How To... Create Modules for the J EE Adapter Engine host El ement Name = ( St r i ng) modul eCont ext . get Cont ext Dat a( " Host El ement Name" ) ; / / CS_GETMODDAT END i f ( host El ement Name == nul l ) { l ocat i on. debugT( SI GNATURE, " Host El ement Name par amet er i s not set . Def aul t used: Host Name. " ) ; audi t . addAudi t LogEnt r y( key, Audi t LogSt at us. WARNI NG, " Host El ement Name par amet er i s not set . Def aul t used: Host Name. " ) ; host El ement Name = " Host Name" ; } l ocat i on. debugT( SI GNATURE, " Host El ement Name i s set t o {0}" , new Obj ect [ ] {host El ement Name}) ; audi t . addAudi t LogEnt r y( key, Audi t LogSt at us. SUCCESS, " Host El ement Name i s set t o {0}" , new Obj ect [ ] {host El ement Name}) ; } cat ch ( Except i on e) { l ocat i on. cat chi ng( SI GNATURE, e) ; l ocat i on. er r or T( SI GNATURE, " Cannot r ead t he modul e cont ext and conf i gur at i on dat a" ) ; audi t . addAudi t LogEnt r y( key, Audi t LogSt at us. ERROR, " Cannot r ead t he modul e cont ext and conf i gur at i on dat a" ) ; Modul eExcept i on me = new Modul eExcept i on( e) ; l ocat i on. t hr owi ng( SI GNATURE, me) ; t hr ow me; } t r y { XMLPayl oad xml payl oad = msg. get Document ( ) ; Document Bui l der Fact or y f act or y; f act or y = Document Bui l der Fact or y. newI nst ance( ) ; Document Bui l der bui l der = f act or y. newDocument Bui l der ( ) ; Document document = bui l der . par se( ( I nput St r eam) xml payl oad. get I nput St r eam( ) ) ; El ement r oot Node = document . get Document El ement ( ) ; i f ( r oot Node ! = nul l ) { El ement chi l dEl ement = document . cr eat eEl ement ( host El ement Name) ; chi l dEl ement . appendChi l d( document . cr eat eText Node( host Name) ) ; r oot Node. appendChi l d( chi l dEl ement ) ; } J une 2008 34 How To... Create Modules for the J EE Adapter Engine / / Tr ansf or mi ng t he DOM obj ect t o St r eamobj ect . Tr ansf or mer Fact or y t f act or y = Tr ansf or mer Fact or y. newI nst ance( ) ; Tr ansf or mer t r ansf or mer = t f act or y. newTr ansf or mer ( ) ; Sour ce sr c = new DOMSour ce( document ) ; Byt eAr r ayOut put St r eammyByt es = new Byt eAr r ayOut put St r eam( ) ; Resul t dest = new St r eamResul t ( myByt es) ; t r ansf or mer . t r ansf or m( sr c, dest ) ; byt e[ ] docCont ent = myByt es. t oByt eAr r ay( ) ; i f ( docCont ent ! = nul l ) { xml payl oad. set Cont ent ( docCont ent ) ; i nput Modul eDat a. set Pr i nci pal Dat a( msg) ; } } cat ch ( Except i on e) { Modul eExcept i on me = new Modul eExcept i on( e) ; t hr ow me; } r et ur n i nput Modul eDat a; } pr i vat e st at i c St r i ng get Host Name( ) { St r i ng host = " unknown" ; t r y { I net Addr ess i net = I net Addr ess. get Local Host ( ) ; host = i net . get Host Name( ) . t oLower Case( ) ; i nt i = host . i ndexOf ( " . " ) ; i f ( i > 0) { host = host . subst r i ng( 0, i ) ; } } cat ch ( UnknownHost Except i on e) { host = " er r or " ; } r et ur n host ; } } J une 2008 35 How To... Create Modules for the J EE Adapter Engine Appendi x B PCK c onf i gur at i on Loopback configuration In order to use PCK for testing adapters without a PI server, a loop configuration is required. This will allow PCK to be both sender and receiver of messages. Below are snapshots of NWA for PCK 7.1 setup. These will be similar to Visual Administrator. Since no Visual Administrator will be available with PI 7.1, hence the settings are required in NWA.