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