1
2
3
4
5
6
7 package org.mule.transport;
8
9 import org.mule.api.MuleException;
10 import org.mule.api.endpoint.OutboundEndpoint;
11 import org.mule.api.transport.MessageDispatcher;
12 import org.mule.api.transport.MessageDispatcherFactory;
13 import org.mule.util.ClassUtils;
14
15
16
17
18
19
20
21
22 public abstract class AbstractMessageDispatcherFactory implements MessageDispatcherFactory
23 {
24
25 public AbstractMessageDispatcherFactory()
26 {
27 super();
28 }
29
30
31
32
33
34
35
36
37
38 public boolean isCreateDispatcherPerRequest()
39 {
40 return false;
41 }
42
43 public abstract MessageDispatcher create(OutboundEndpoint endpoint) throws MuleException;
44
45 public void activate(OutboundEndpoint endpoint, MessageDispatcher dispatcher) throws MuleException
46 {
47 dispatcher.activate();
48 }
49
50 public void destroy(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
51 {
52 dispatcher.dispose();
53 }
54
55 public void passivate(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
56 {
57 dispatcher.passivate();
58 }
59
60 public boolean validate(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
61 {
62
63
64
65 return (this.isCreateDispatcherPerRequest() ? false : dispatcher.validate());
66 }
67
68 @Override
69 public String toString()
70 {
71 final StringBuffer sb = new StringBuffer(60);
72 sb.append(ClassUtils.getSimpleName(this.getClass()));
73 sb.append("{this=").append(Integer.toHexString(System.identityHashCode(this)));
74 sb.append(", createDispatcherPerRequest=").append(this.isCreateDispatcherPerRequest());
75 sb.append('}');
76 return sb.toString();
77 }
78
79 }