The following Java code example invokes a long-lived process named MortgageLoan - Prebuilt. Notice that this process is invoked asynchronously. This quick start contains a user-defined method named GetDataSource that creates XML data that is passed to the process. The XML data is created using a org.w3c.dom.Document instance. (See Invoking Human-Centric Long-Lived Processes.)/** This Java Quick Start uses the following JAR files* 1. adobe-jobmanager-client-sdk.jar* 2. adobe-livecycle-client.jar* 3. adobe-usermanager-client.jar* 4. adobe-utilities.jar* 5. jbossall-client.jar (use a different JAR file if LiveCycle ES is not deployed on JBoss)** These JAR files are located in the following path:* <install directory>/Adobe/LiveCycle8/LiveCycle_ES_SDK/client-libs** For complete details about the location of these JAR files,* see "Including LiveCycle ES library files" in* Programming with LiveCycle ES*/import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;import com.adobe.idp.dsc.clientsdk.ServiceClient;import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;import com.adobe.idp.dsc.FaultResponse;import com.adobe.idp.dsc.InvocationRequest;import com.adobe.idp.dsc.InvocationResponse;import java.util.Properties;import java.util.Map;import java.util.HashMap;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Element;import com.adobe.idp.jobmanager.client.JobManager;import com.adobe.idp.jobmanager.common.JobId;import com.adobe.idp.jobmanager.common.JobStatus;public class InvokeLongLived {public static void main(String[] args) {try{//Set connection properties required to invoke LiveCycle ESProperties connectionProps = new Properties();connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://localhost:1099");connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");//Create a ServiceClientFactory objectServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);//Create a ServiceClient objectServiceClient myServiceClient = myFactory.getServiceClient();//Create a Map object to store the parameter valueMap params = new HashMap();//Populate the Map object with a parameter value//required to invoke the MortgageLoan long-lived process//This process requires XML dataorg.w3c.dom.Document inXML = GetDataSource();params.put("xmlFormData", inXML);//Create an InvocationRequest objectInvocationRequest request = myFactory.createInvocationRequest("MortgageLoan - Prebuilt", //Specify the long-lived process name"invoke", //Specify the operation nameparams, //Specify input valuesfalse); //Create an asynchronous request//Send the invocation request to the long-lived process and//get back an invocation response objectInvocationResponse response = myServiceClient.invoke(request);String invocationId = response.getInvocationId();//Create a Job Manager object to check the//results of an asynchronous requestJobManager jobManager = new JobManager(myFactory);JobStatus jobStatus = null;//Create a JobID object that represents the status of the//long-lived operationJobId myJobId = new JobId(invocationId);//Wait and check the results of the long-lived operationfor (int i=0;i<5;i++) {Thread.sleep(60000);jobStatus = jobManager.getStatus(myJobId);System.out.println("Job Status: " + jobStatus.getStatusCode());if (jobStatus.getStatusCode()== JobStatus.JOB_STATUS_COMPLETED || jobStatus.getStatusCode()==JobStatus.JOB_STATUS_FAILED) {break;}}//end of for loopif (jobStatus.getStatusCode()==JobStatus.JOB_STATUS_COMPLETED) {System.out.println("INVOCATION COMPLETED SUCCESSFULLY!");InvocationResponse jobResponse = jobManager.getResponse(myJobId);jobManager.disposeJob(myJobId);} else if (jobStatus.getStatusCode()==JobStatus.JOB_STATUS_FAILED) {System.out.println("INVOCATION COMPLETED FAILED!");FaultResponse _fr = jobManager.getFaultResponse(new JobId(invocationId));System.out.println(_fr.getStackTrace());jobManager.disposeJob(myJobId);} else {System.out.println("INVOCATION STATUS " + jobStatus.getStatusCode() + " NOT COMPLETE.");}}catch (Exception e) {e.printStackTrace();}}//Create XML data to pass to the long-lived processprivate static org.w3c.dom.Document GetDataSource(){org.w3c.dom.Document document = null;try{//Create DocumentBuilderFactory and DocumentBuilder objectsDocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();DocumentBuilder builder = factory.newDocumentBuilder();//Create a new Document objectdocument = builder.newDocument();//Create MortgageApp - the root element in the XMLElement root = (Element)document.createElement("MortgageApp");document.appendChild(root);//Create Mortgage fields and append it to MortgageAppElement MortgageFields = (Element)document.createElement("MortgageFields");root.appendChild(MortgageFields);//Create ApplicantFields and append it to MortgageAppElement ApplicantFields = (Element)document.createElement("ApplicantFields");root.appendChild(ApplicantFields);//Create the PropertyPrice element - a child to Mortgage fieldsElement PropertyPrice = (Element)document.createElement("PropertyPrice");PropertyPrice.appendChild(document.createTextNode("700000"));MortgageFields.appendChild(PropertyPrice);//Create the DownPayment element - a child to Mortgage fieldsElement DownPayment =(Element)document.createElement("DownPayment");DownPayment.appendChild(document.createTextNode("100000"));MortgageFields.appendChild(DownPayment);//Create the DownPayment element - a child to Mortgage fieldsElement Mortgage =(Element)document.createElement("Mortgage");Mortgage.appendChild(document.createTextNode("600000"));MortgageFields.appendChild(Mortgage);//Create the Term element - a child to Mortgage fieldsElement Term = (Element)document.createElement("Term");Term.appendChild(document.createTextNode("20"));MortgageFields.appendChild(Term);//Create the InterestRate element - a child to Mortgage fieldsElement InterestRate = (Element)document.createElement("InterestRate");InterestRate.appendChild(document.createTextNode("6.0"));MortgageFields.appendChild(InterestRate);//Create the LastName element - a child to ApplicantFields fieldsElement LastName = (Element)document.createElement("LastName");LastName.appendChild(document.createTextNode("White"));ApplicantFields.appendChild(LastName);//Create the FirstName element - a child to ApplicantFields fieldsElement FirstName = (Element)document.createElement("FirstName");FirstName.appendChild(document.createTextNode("Sam"));ApplicantFields.appendChild(FirstName);//Create the PhoneNumber element - a child to ApplicantFields fieldsElement PhoneNumber = (Element)document.createElement("PhoneNumber");PhoneNumber.appendChild(document.createTextNode("555-5555"));ApplicantFields.appendChild(PhoneNumber);//Create the SNN element - a child to ApplicantFields fieldsElement SSN = (Element)document.createElement("SSN");SSN.appendChild(document.createTextNode("123-456-678"));ApplicantFields.appendChild(SSN);}catch (Exception e) {System.out.println("The following exception occurred: "+e.getMessage());}return document;}}
| Programming with LiveCycle ES (LiveDocs) |
| Adobe LiveCycle ES Update 1 |
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/000005.html