<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> Generic EJB sample

Generic EJB sample





<%@ page import="commonj.sdo.*"%> <%@ page import="com.ibm.bpe.api.*"%> <%@ page import="javax.naming.*"%> <% try { if (request.getParameter("name") != null) { String in = request.getParameter("name"); //JNDI lookup Context initialContext = new InitialContext(); Object result = initialContext.lookup("java:comp/env/ejb/LocalBusinessFlowManagerHome"); //Get the home interface LocalBusinessFlowManagerHome processHome = (LocalBusinessFlowManagerHome) javax.rmi.PortableRemoteObject.narrow(result, LocalBusinessFlowManagerHome.class); //Create the EJB LocalBusinessFlowManager flowManager = processHome.create(); //Query the process template String whereClause = "PROCESS_TEMPLATE.NAME = 'HelloSnippetProcess'"; String orderByClause = "PROCESS_TEMPLATE.VALID_FROM DESC"; ProcessTemplateData[] templates = flowManager.queryProcessTemplates(whereClause, orderByClause, null, null); if (templates == null || templates.length == 0) { out.println("Process template 'HelloSnippetProcess' not found. Ensure that the process is installed correctly and the process template is started!"); } else { ProcessTemplateData processTemplate = templates[0]; //Create the input ClientObjectWrapper ClientObjectWrapper cow = flowManager.createMessage( processTemplate.getID(), processTemplate.getInputMessageTypeName() ); //Get the Input DataObject from the ClientObjectWrapper DataObject input = (DataObject) cow.getObject(); //Create the second/inner DataObject DataObject dataIn = input.createDataObject("input"); //set the Data dataIn.setString("name", in); //Call the Process and get the output ClientObjectWrapper ClientObjectWrapper cowProcessOut = flowManager.call("HelloSnippetProcess", cow); //get DataObject DataObject inner = (DataObject) cowProcessOut.getObject(); //get output Data String resp = inner.getDataObject("output").getString("hello"); //print result out.println(resp); } } else { out.println("No name was submitted."); } } catch (Exception e) { e.printStackTrace(); System.out.println(e); } %>