1
2
3
4
5
6
7
8
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
22
23 public class ProcessComponent extends AbstractComponent
24 {
25
26 protected Process process;
27
28
29 protected BPMS bpms;
30
31
32 private String name;
33
34
35 private String resource;
36
37
38 private String processIdField;
39
40 @Override
41 protected void doInitialise() throws InitialisationException
42 {
43 if (bpms == null)
44 {
45 try
46 {
47 bpms = muleContext.getRegistry().lookupObject(BPMS.class);
48 }
49 catch (Exception e)
50 {
51 throw new InitialisationException(e, this);
52 }
53 }
54 if (bpms == null)
55 {
56 throw new InitialisationException(MessageFactory.createStaticMessage("The bpms property must be set for this component."), this);
57 }
58 if (bpms instanceof Initialisable)
59 {
60 ((Initialisable) bpms).initialise();
61 }
62
63 process = new Process(bpms, name, resource, flowConstruct, muleContext);
64 process.initialise();
65
66
67 bpms.setMessageService(process);
68 }
69
70 @Override
71 protected void doDispose()
72 {
73 if (bpms instanceof Disposable)
74 {
75 ((Disposable) bpms).dispose();
76 }
77
78 process.dispose();
79 process = null;
80 }
81
82 @Override
83 protected Object doInvoke(MuleEvent event) throws Exception
84 {
85 return process.processAction(event);
86 }
87
88 protected Process getProcess()
89 {
90 return process;
91 }
92
93 public String getName()
94 {
95 return name;
96 }
97
98 public void setName(String name)
99 {
100 this.name = name;
101 }
102
103 public void setResource(String resource)
104 {
105 this.resource = resource;
106 }
107
108 public String getResource()
109 {
110 return resource;
111 }
112
113 public String getProcessIdField()
114 {
115 return processIdField;
116 }
117
118 public void setProcessIdField(String processIdField)
119 {
120 this.processIdField = processIdField;
121 }
122
123 public BPMS getBpms()
124 {
125 return bpms;
126 }
127
128 public void setBpms(BPMS bpms)
129 {
130 this.bpms = bpms;
131 }
132 }
133
134