1
2
3
4
5
6
7
8
9
10
11 package org.mule.impl.model.direct;
12
13 import org.mule.impl.MuleDescriptor;
14 import org.mule.impl.MuleMessage;
15 import org.mule.impl.model.AbstractComponent;
16 import org.mule.impl.model.DefaultMuleProxy;
17 import org.mule.impl.model.MuleProxy;
18 import org.mule.umo.UMOEvent;
19 import org.mule.umo.UMOException;
20 import org.mule.umo.UMOMessage;
21 import org.mule.umo.lifecycle.InitialisationException;
22 import org.mule.umo.model.UMOModel;
23
24 import java.util.List;
25
26
27
28
29
30 public class DirectComponent extends AbstractComponent
31 {
32
33
34
35 private static final long serialVersionUID = -8590955440156945732L;
36
37 protected List interceptorList = null;
38 protected MuleProxy proxy;
39
40 public DirectComponent(MuleDescriptor descriptor, UMOModel model)
41 {
42 super(descriptor, model);
43 }
44
45 protected void doInitialise() throws InitialisationException
46 {
47
48 try
49 {
50 Object component = lookupComponent();
51 proxy = new DefaultMuleProxy(component, descriptor, model, null);
52 proxy.setStatistics(getStatistics());
53 }
54 catch (UMOException e)
55 {
56 throw new InitialisationException(e, this);
57 }
58 }
59
60 protected UMOMessage doSend(UMOEvent event) throws UMOException
61 {
62
63 Object obj = proxy.onCall(event);
64 if (obj instanceof UMOMessage)
65 {
66 return (UMOMessage) obj;
67 }
68 else
69 {
70 return new MuleMessage(obj, event.getMessage());
71 }
72 }
73
74 protected void doDispatch(UMOEvent event) throws UMOException
75 {
76 proxy.onCall(event);
77 }
78
79 protected void doStop() throws UMOException
80 {
81 proxy.stop();
82 }
83
84 protected void doStart() throws UMOException
85 {
86 proxy.start();
87 }
88
89 protected void doPause()
90 {
91 proxy.suspend();
92 }
93
94 protected void doResume()
95 {
96 proxy.resume();
97 }
98
99 protected void doDispose()
100 {
101 proxy.dispose();
102 }
103 }