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 | 0 | 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 | 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); |
64 | 0 | process.initialise(); |
65 | |
|
66 | |
|
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 | |
|