Load Ingest Data
Results 1 to 1 of 1

Thread: JCA CICS IMS Tuxedo Pathway Oracle - IBM WebSphere

  1. #1
    Costi Zaboura is offline World Wide Support Manager
    Join Date
    Aug 2006
    Posts
    300
    Rep Power
    14

    JCA CICS IMS Tuxedo Pathway Oracle - IBM WebSphere

    Access CICS,IMS,Tuxedo,Pathway,Oracle,Db2,Cobol,RBG and many more via Attunity JCA under IBM WebSphere

    DESCRIPTION

    One of the most useful features that the WebSphere Application Developer provides for JCA development, is the connector project.
    The connector project in the workspace acts essentially as a resource adapter (RAR) file, deployed in a production application server.

    Importing the Adapter Source
    To set up a connector project and import the Attunity resource adapter source:
    1. Start Application Developer v5.1: In Windows, go to: Start -> All Programs -> IBM Websphere Studio -> Application Developer 5.1.2.
    2. Specify “C:\WebSphereTest” as the workspace directory .The Startup dialog for Application Developer, lets you specify a new workspace, which will be created when the application loads.
    3. Once the Application Developer is initialized, open the Java perspective by selecting Window > Open Perspective > Java.
    4. Select File > Import. Choose “RAR file” from the list of the Import wizard. Click Next.
    5. The Import RAR wizard, lets you import existing resource adapters into the Application Developer IDE. In the “Connectior file” browse to select the correct rar file (in this case, attunityResourceAdapter.rar), and provide the name for a new connector project that will be created in the Application Developer workspace.
    6. Click New to provide a new project name. Call your connector project attunityResourceAdapter, make sure the Stand alone connector project is selected. Press Next to accept the default values.
    7. Select Finish to exit the wizard.
    Notice that a new connector project called “attunityResourceAdapter“, has been created in the workspace.
    As you browse the new connector project in the Package Explorer view, you'll see that the project contains the connectorModule folder. This folder contains a META-INF subdirectory, where you'll find the ra.xml deployment descriptor (the attunityResourceAdapter includes also an hp-ra.xml and a weblogic-ra.xml. You need to delete those files from the connector project by selecting them, right click and select Delete from the pop-up menu).
    Also notice that j2ee.jar has been automatically added to the connector project classpath. At this stage, your connector project contains the binaries (connectorModule/attunityRespurceAdapter.jar, attunityCoreResourceAdapter.jar, log4j-1.2.8.jar).
    Testing and debugging in a managed environment
    In a managed setting, the resource adapter is deployed under the Application Server.
    Calls to the adapter take place inside the Enterprise JavaBeans (EJB) container. To set up a managed test case, complete the following high-level steps:
    1. Create a new EJB project.
    2. Create a new EJB that will act as a client to your resource adapter.
    3. Create the UTE server instance that will be used for running.
    4. Deploy the managed connection factory and test application.
    5. Start the server instance hosting the EJB in run mode.
    6. Invoke Universal Test Client to make calls to the EJB.
    Creating an EJB Tester
    The first step in creating a new EJB project is to switch to the J2EE perspective:
    1. Select Window > Open Perspective > J2EE from the top-level menu. In the J2EE Hierarchy view, locate and select the folder EJB Modules.
    2. Right-click on the folder and select New > EJB Project from the pop-up menu. In the EJB Project Creation wizard, select the default for EJB level (2.0) and click Next. Enter AttunityTest for the Project name, and accept all other defaults for the project location.
    3. Click New to select the Ear project, enter “AttunityTestEAR” for the project name. Click Finish.
    4. Click Next – accept all the default values.
    5. Click Finish.
    Under the EJB Modules branch in the J2EE Hierarchy view, a new EJB module named AttunityTest will appear.
    Now that you have an EJB project, you need to create an EJB that can be used for testing your adapter code:
    1. Switch to the J2EE Project Navigator view (bottom tab), and browse the AttunityTest project to find the ejbModule folder.
    2. Select this folder and right-click. Select New > Others -> Java/Package from the pop-up menu.
    3. In the New Java Package wizard, name the new package com.attunitytest. Click Finish to create this package.
    4. Switch back to the J2EE Hierarchy view. Locate the EJB Modules then select the AttunityTest EJB module and click the right mouse button.
    5. Select New > Enterprise Bean from the pop-up menu, accept the Ejb Project name: “AttunityTest”. Click Next in the Enterprise Bean Creation dialog. In the next Enterprise Bean Creation wizard panel, choose to create your bean as a Session bean. Call your session bean “AttunityTester”.
    6. Accept the defaults for all other choices, making sure ejbModule is the source project and com.attunitytest is the target default package. Click Next.
    7. Accept the defaults again, making sure the Session type is Stateless, the Transaction type is: Container, the Bean class is set to: com.attunitytest.AttunityTesterBean, the Ejb binding name is: ejb/com/attunitytest/AttunityTesterHome, the Remote client view is set, the Remote home interface is: com.attunitytest.AttunityTesterHome, and the remote interface is: com.attunitytest.AttunityTester. Click Next.
    8. Once you select Finish, the wizard generates the bean class and the home and remote interfaces.
    9. Add the attunityResourceAdapter project to this new EJB project's classpath:
    • Select the AttunityTest, Right-Click and choose Properties.
    • Select Java Build Path, move to the “Projects” section.
    • Select the AttunityResourceAdapterConnector project. Make sure the default output folder is: AttunityTest/ejbModule, and press ok.
    To test the Attunity Resource adapter, you need to define a method on your EJB that can be invoked by an EJB client.
    To create a test method:
    1. Open the interface class AttunityTesterHome.java by double-clicking it in the J2EE perspective, at the J2EE Hierarchy view, under EJB Modules -> Attunity Test -> Session Beans -> Attunity Tester -> AttunityTesterHome.java. Add to this file the sample test method declaration: e.g:

    public void runTest() throws java.rmi.RemoteException;
    Generate the deploy code by highlighting the AttunityTest project the J2EE perspective\Project Navigator and selecting Generate > Deployment and RMIC Code, ensuring the AttunityTester EJB is checked in the Generate Deploy and RMIC Code dialog, and clicking Finish.
    1. <LI dir=ltr value=2>Add the AttunityCoreResourceAdapter.jar to the Build Path of the AttunityTest project: At the J2EE Hierarchy Right click on: EJB Modules\AttunityTest and choose “Properties”. Look for “Java Build Path”. At the Java Build Path panel look for the Libraries section. Press Add External Jars… and browse to find the “AttunityResourceAdapter.jar” (supplied by the AttunityResourceAdapter kit).
    2. Switch to the J2EE Project Navigator view, and browse the AttunityTest project to find and open the ejbModule\com.attunitytest\EJSStatelessAttunityTes terHomeBean_#.java file.

    Add to this class the following import list:
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import com.attunity.adapter.core.*;
    import com.attunity.adapter.*;
    import org.w3c.dom.*;
    import java.util.Vector;
    import javax.resource.ResourceException;
    1. Add the test method implementation to this remote class:
    public void runTest()
    {
    try
    {
    // Look-up a connection factory instance
    Context nc = new InitialContext();

    // Create and configure a managed connection
    // factory instance Properties were set when
    // managed connection factory was deployed
    AttuConnectionFactory cf = (AttuConnectionFactory)nc.lookup("eis/attunityJnd");

    try {
    javax.resource.cci.Connection con = cf.getConnection();
    javax.resource.cci.Interaction interaction = con.createInteraction();
    AttuInteractionSpec iSpeq = new AttuInteractionSpec("query");

    javax.resource.cci.RecordFactory rf = cf.getRecordFactory();
    javax.resource.cci.MappedRecord queryRecord = rf.createMappedRecord("query");
    String sSql = "select * from disam:nv_dept";
    queryRecord.put("##text", sSql);
    javax.resource.cci.Record oRec = interaction.execute(iSpeq, queryRecord);
    Element outEl = ((CoreDomRecord)oRec).getDom();

    CoreDOMWriter domW = new CoreDOMWriter(false);
    String xml = domW.toXMLString(outEl);

    System.out.println("now using the get functions of the Record interface");

    // Here we get an array of sub elements named record
    Vector recordV = (Vector)((CoreMappedRecord)oRec).get("#record[]");

    if (recordV == null || recordV.isEmpty()) {
    System.out.println("No sub elements named record");
    return;
    }

    for (int objInd = 0; objInd < recordV.size(); objInd++) {
    CoreMappedRecord record = (CoreMappedRecord)recordV.get(objInd);
    String dept_budget = (String)record.get("@dept_budget");
    String dept_id = (String)record.get("@dept_id");
    System.out.println("dept_budget is " + dept_budget);
    System.out.println("dept_id is " + dept_id);
    }

    interaction.close();
    con.close();
    System.out.println("SUCESS !");
    }
    catch (ResourceException ex) {
    System.out.print("Exception in QuerySample: " + ex.getMessage());
    ex.printStackTrace();
    throw ex;
    }

    }
    catch(Exception e) {
    System.out.println(e.getMessage());
    e.printStackTrace(System.out);
    }
    }
    To use container managed sign-on, the deployment descriptor of the calling EJB must have a resource-ref element with a Container subelement set. This tells the application server that it should provide security information to the resource rather than the application.
    To set this up:
    1. Move to J2EE Perspective. Select the Project Navigator, and look for: AttunityTest -> ejbModule -> META-INF -> ejb-jar.xml file. Double-click on it to open the EJB Deployment Descriptor editor.
    2. Select the References tab in the editor.
    3. Highlight the AttunityTester EJB. Click Add.
    4. In the Add Reference dialog, select the Resource reference and click Next.
    5. Type attunityResourceAdapter in the Name field. Select the javax.resource.cci.ConnectionFactory option from the drop-down list in the Type field. Select Container in the Authentication field. Leave Shareable as the Sharing scope value, indicating that the connections to the EIS can be shared. Finally, type JCA Resource Reference in the Description field and click Finish to create the resource reference.
    6. A new ResourceRef attunityResourceAdapter was created under Attunity Tester project and the References panel. Highlight the new ResourceRef attunityResourceAdapter resource reference and type eis/attunityJndi in the JNDI name field under the WebSphere Bindings section, accept all the other default values. Save these changes and close the EJB editor.
    Setting up the UTE Server instance
    To debug in a managed setting, you first need to create a UTE server instance and configuration that will host your resource adapter. To do this:
    1. <LI style="MARGIN-RIGHT: 0px">Switch to the server perspective by selecting Window > Perspective > Server. <LI style="MARGIN-RIGHT: 0px">Select the Servers folder in the Server Configuration view. Click the right mouse button to bring up a pop-up menu. <LI style="MARGIN-RIGHT: 0px">Select New > Server and Server Configuration. <LI style="MARGIN-RIGHT: 0px">In the Create New Server and Server Configuration Wizard, type TestAttuServer in the Server name control. <LI style="MARGIN-RIGHT: 0px">Select WebSphere Version 5.1 > Test Environment from the list. <LI style="MARGIN-RIGHT: 0px">Click Next. Accept the default values.
    2. Click Finish to end the creation process.
    Now, you need to deploy a managed connection factory to the test server. To do this:
    1. <LI style="MARGIN-RIGHT: 0px">While still in the Server configuration panel, double click the TestAttuServer. click the J2C tab. <LI style="MARGIN-RIGHT: 0px">Scroll down to the Server Settings section. <LI style="MARGIN-RIGHT: 0px">The Add button should be active to the right of the J2C Resource Adapters section. Click Add. You should see the attunityResourceAdapter adapter in the Resource Adapter Name field of the Create Resource Adapter dialog. <LI style="MARGIN-RIGHT: 0px">Select the attunityResourceAdapter adapter by clicking OK in the Create Resource Adapter dialog. <LI style="MARGIN-RIGHT: 0px">Highlight the attunityResourceAdapter adapter in the J2C Resource Adapters list. Click Add to the right of the J2C Connection Factories section. <LI style="MARGIN-RIGHT: 0px">Type “attunityResourceAdapter” in the Name field and eis/attunityJndi in the JNDI name field. Accept all other default values for the other fields and click OK. This defines the container managed authentication that will be used when your EJB establishes a connection to the adapter, since you earlier defined "container" authentication in your EJB ResourceReference. <LI style="MARGIN-RIGHT: 0px">Notice that the Resource Properties section, is populated after creating the J2C connection factory. There are some default entries for this adapter. These values are initially derived from the ra.xml file. In order to run this sample, change the eisName property to: “query”.
    2. Save and close the TestServer configuration.
    Before moving on, start up the test application server and verify that your JCA adapter is recognized and binds correctly. It is good time to do that now, so that you can isolate any potential problems while you have a very clean application server setup.
    1. <LI style="MARGIN-RIGHT: 0px">Highlight TestAttuServer under the Servers configuration of the Server perspective. <LI style="MARGIN-RIGHT: 0px">Right-click and select Start to start up the application server.
    2. Once the application server initializes, the Servers view in the Server perspective switches to the Console view and systemOut messages associated with the application startup process begin to appear in this window. You should see a message similar to the following, indicating that the application server performed the attunityResourceAdapter/jndi binding successfully:

    [7/27/04 13:14:16:219 IDT] 3cfd90d8 ResourceMgrIm I WSVR0049I: Binding attunityResourceAdapter as eis/attunityJndi.
    Using Universal Test Client for managed environment running
    Deploy the application by right-clicking on the TestAttuServer configuration in the Server Configuration, and selecting Add and Remove Projects from the pop-up menu. HighLight the AttunityTestEar and click Add. Click Finish. Start the server or restart it if it is already running.
    The only step left is to invoke the test method on your EJB. Application Developer provides Universal Test Client. To launch UTC once the server is started, select the TestAttuServer in the Servers view, right-click, and select Run Universal Test Client from the pop-up menu.
    Select the JNDI Explorer link on the UTC homepage. You will see a panel showing different objects bound in the JNDI space. Browse the links to find your test EJB home, and select that link (in this case: ejb\com\attunitytest\AttunityTesterHome, a new Reference panel will open. At the Reference panel browse to “Ejb References\Attunity Tester\AttunityTesterHome”..You will see a panel that shows methods available on your home interface (under “Method Visibility”). Select the runTest() method and press Invoke, this command will run the “runTest” method.
    The runTest output will be thrown to the server console panel.
    Last edited by Admin_attu; 09-23-2006 at 11:56 AM.
    To Find Out more About Attunity Technology:
    Attunity
    or:
    Contact Us

LinkBacks (?)

  1. 09-19-2006, 09:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •