1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.bpm.jbpm.actions;
12
13 import org.mule.util.ClassUtils;
14
15 import org.jbpm.JbpmException;
16 import org.jbpm.graph.exe.ExecutionContext;
17
18
19
20
21
22
23
24
25
26
27
28
29 public class ValidateMessageType extends IntegrationActionHandler
30 {
31
32 private static final long serialVersionUID = 1L;
33
34 protected String expectedType;
35 protected boolean strict = false;
36
37 public void execute(ExecutionContext executionContext) throws Exception
38 {
39 super.execute(executionContext);
40 Object message = getIncomingMessage();
41 if (message == null)
42 {
43 throw new JbpmException("Incoming message is null.");
44 }
45
46 Class expectedClass = ClassUtils.loadClass(expectedType, this.getClass());
47 boolean match;
48 if (strict)
49 {
50 match = message.getClass().equals(expectedClass);
51 }
52 else
53 {
54 match = expectedClass.isAssignableFrom(message.getClass());
55 }
56 if (!match)
57 {
58 throw new JbpmException("Incoming message type is " + message.getClass() + ", expected type is "
59 + expectedType);
60 }
61 }
62 }