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