FileDocCategorySizeDatePackage
SampleBeanScenario.javaAPI DocGlassfish v2 API3549Fri May 04 22:35:40 BST 2007sample

SampleBeanScenario

public class SampleBeanScenario extends Object
SampleBeanScenario.java

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

  
public voidmethod()

    
    try {
      Context nc = new InitialContext();

      // JNDI lookup for ConnectionFactory
      ConnectionFactory cf = (ConnectionFactory)nc.lookup(
				 "java:comp/env/eis/ConnectionFactory");
      Connection cx = cf.getConnection();

      // Create an Interaction 
      Interaction ix = cx.createInteraction();

      // Create an InteractionSpec and set properties
      InteractionSpecImpl ixSpec = new InteractionSpecImpl();
      ixSpec.setFunctionName("<NAME OF FUNCTION>");
      ixSpec.setInteractionVerb(InteractionSpec.SYNC_SEND_RECEIVE);

      // Get a RecordFactory to create input/output generic Records
      RecordFactory rf = cf.getRecordFactory();
      
      // Create an input MappedRecord
      MappedRecord input = rf.createMappedRecord("Name of Record");
      input.put("<key: element1>", new String("<VALUE1>"));
      input.put("<key: element2>", new String("<VALUE2>")); 

      // Create an output custom Record
      EmployeeRecord employee = new EmployeeRecordImpl();

      // Execute the Interaction
      ix.execute(ixSpec, input, employee);

      // Check the EmployeeRecord
      System.out.println( employee.getName() + ":" +
			  employee.getId());
    }
    catch (NamingException ne) {
      return;
    }
     catch (ResourceException e) {
      return;
    }