1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.transport; |
8 | |
|
9 | |
import org.mule.api.MuleException; |
10 | |
import org.mule.api.lifecycle.Disposable; |
11 | |
import org.mule.api.lifecycle.Initialisable; |
12 | |
import org.mule.api.lifecycle.LifecycleCallback; |
13 | |
import org.mule.api.lifecycle.Startable; |
14 | |
import org.mule.api.lifecycle.Stoppable; |
15 | |
import org.mule.api.transport.Connector; |
16 | |
import org.mule.context.notification.ConnectionNotification; |
17 | |
import org.mule.lifecycle.SimpleLifecycleManager; |
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class ConnectorLifecycleManager extends SimpleLifecycleManager<Connector> |
27 | |
{ |
28 | |
public ConnectorLifecycleManager(AbstractConnector connector) |
29 | |
{ |
30 | 0 | super(connector.getName(), connector); |
31 | 0 | } |
32 | |
|
33 | |
@Override |
34 | |
public void fireInitialisePhase(LifecycleCallback<Connector> callback) throws MuleException |
35 | |
{ |
36 | 0 | checkPhase(Initialisable.PHASE_NAME); |
37 | |
|
38 | 0 | if (logger.isInfoEnabled()) |
39 | |
{ |
40 | 0 | logger.info("Initialising connector: " + getLifecycleObject().getName()); |
41 | |
} |
42 | |
|
43 | |
|
44 | 0 | invokePhase(Initialisable.PHASE_NAME, getLifecycleObject(), callback); |
45 | |
|
46 | 0 | } |
47 | |
|
48 | |
@Override |
49 | |
public void fireStartPhase(LifecycleCallback<Connector> callback) throws MuleException |
50 | |
{ |
51 | 0 | checkPhase(Startable.PHASE_NAME); |
52 | |
|
53 | 0 | if (logger.isInfoEnabled()) |
54 | |
{ |
55 | 0 | logger.info("Starting connector: " + getLifecycleObject().getName()); |
56 | |
} |
57 | |
|
58 | |
|
59 | 0 | invokePhase(Startable.PHASE_NAME, getLifecycleObject(), callback); |
60 | |
|
61 | 0 | } |
62 | |
|
63 | |
@Override |
64 | |
public void fireStopPhase(LifecycleCallback<Connector> callback) throws MuleException |
65 | |
{ |
66 | 0 | checkPhase(Stoppable.PHASE_NAME); |
67 | 0 | if (logger.isInfoEnabled()) |
68 | |
|
69 | |
{ |
70 | 0 | logger.info("Stopping connector: " + getLifecycleObject().getName()); |
71 | |
} |
72 | |
|
73 | |
|
74 | 0 | invokePhase(Stoppable.PHASE_NAME, getLifecycleObject(), callback); |
75 | |
|
76 | 0 | } |
77 | |
|
78 | |
@Override |
79 | |
public void fireDisposePhase(LifecycleCallback<Connector> callback) throws MuleException |
80 | |
{ |
81 | 0 | checkPhase(Disposable.PHASE_NAME); |
82 | |
|
83 | 0 | if (logger.isInfoEnabled()) |
84 | |
{ |
85 | 0 | logger.info("Disposing connector: " + getLifecycleObject().getName()); |
86 | |
} |
87 | |
|
88 | |
|
89 | 0 | invokePhase(Disposable.PHASE_NAME, getLifecycleObject(), callback); |
90 | |
|
91 | 0 | } |
92 | |
|
93 | |
protected void fireNotification(int action) |
94 | |
{ |
95 | 0 | getLifecycleObject().getMuleContext().fireNotification( |
96 | |
new ConnectionNotification(getLifecycleObject(), getLifecycleObject().getName(), action)); |
97 | 0 | } |
98 | |
} |