Coverage Report - org.mule.module.bpm.ProcessComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
ProcessComponent
0%
0/33
0%
0/8
0
 
 1  
 /*
 2  
  * $Id: ProcessComponent.java 19952 2010-10-15 18:39:57Z aperepel $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.module.bpm;
 12  
 
 13  
 import org.mule.api.MuleEvent;
 14  
 import org.mule.api.lifecycle.Disposable;
 15  
 import org.mule.api.lifecycle.Initialisable;
 16  
 import org.mule.api.lifecycle.InitialisationException;
 17  
 import org.mule.component.AbstractComponent;
 18  
 import org.mule.config.i18n.MessageFactory;
 19  
 
 20  
 /**
 21  
  * A service backed by the execution of a business process such as jBPM. 
 22  
  */
 23  0
 public class ProcessComponent extends AbstractComponent
 24  
 {
 25  
     // Created internally
 26  
     protected Process process;
 27  
     
 28  
     /** The underlying BPMS */
 29  
     protected BPMS bpms;
 30  
 
 31  
     /** The logical name of the process.  This is used to look up the running process instance from the BPMS. */
 32  
     private String name;
 33  
     
 34  
     /** The resource containing the process definition.  This will be used to deploy the process to the BPMS. */
 35  
     private String resource;
 36  
 
 37  
     /** This field will be used to correlate messages with processes. */
 38  
     private String processIdField;
 39  
 
 40  
     @Override
 41  
     protected void doInitialise() throws InitialisationException
 42  
     {
 43  0
         if (bpms == null)
 44  
         {
 45  
             try
 46  
             {
 47  0
                 bpms = muleContext.getRegistry().lookupObject(BPMS.class);
 48  
             }
 49  0
             catch (Exception e)
 50  
             {
 51  0
                 throw new InitialisationException(e, this);
 52  0
             }
 53  
         }
 54  0
         if (bpms == null)
 55  
         {
 56  0
             throw new InitialisationException(MessageFactory.createStaticMessage("The bpms property must be set for this component."), this);
 57  
         }
 58  0
         if (bpms instanceof Initialisable)
 59  
         {
 60  0
             ((Initialisable) bpms).initialise();
 61  
         }
 62  
         
 63  0
         process = new Process(bpms, name, resource, flowConstruct, muleContext);
 64  0
         process.initialise();
 65  
 
 66  
         // Inject a callback so that the BPMS may generate messages within Mule.
 67  0
         bpms.setMessageService(process);        
 68  0
     }
 69  
     
 70  
     @Override
 71  
     protected void doDispose()
 72  
     {
 73  0
         if (bpms instanceof Disposable)
 74  
         {
 75  0
             ((Disposable) bpms).dispose();
 76  
         }
 77  
 
 78  0
         process.dispose();
 79  0
         process = null;
 80  0
     }
 81  
 
 82  
     @Override
 83  
     protected Object doInvoke(MuleEvent event) throws Exception
 84  
     {
 85  0
         return process.processAction(event);
 86  
     }
 87  
 
 88  
     protected Process getProcess()
 89  
     {
 90  0
         return process;
 91  
     }
 92  
 
 93  
     public String getName()
 94  
     {
 95  0
         return name;
 96  
     }
 97  
 
 98  
     public void setName(String name)
 99  
     {
 100  0
         this.name = name;
 101  0
     }
 102  
 
 103  
     public void setResource(String resource)
 104  
     {
 105  0
         this.resource = resource;
 106  0
     }
 107  
 
 108  
     public String getResource()
 109  
     {
 110  0
         return resource;
 111  
     }
 112  
     
 113  
     public String getProcessIdField()
 114  
     {
 115  0
         return processIdField;
 116  
     }
 117  
 
 118  
     public void setProcessIdField(String processIdField)
 119  
     {
 120  0
         this.processIdField = processIdField;
 121  0
     }
 122  
 
 123  
     public BPMS getBpms()
 124  
     {
 125  0
         return bpms;
 126  
     }
 127  
 
 128  
     public void setBpms(BPMS bpms)
 129  
     {
 130  0
         this.bpms = bpms;
 131  0
     }
 132  
 }
 133  
 
 134