1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.config.spring; |
8 | |
|
9 | |
import org.mule.api.MuleContext; |
10 | |
import org.mule.api.lifecycle.Disposable; |
11 | |
import org.mule.api.lifecycle.Initialisable; |
12 | |
import org.mule.api.lifecycle.LifecycleException; |
13 | |
import org.mule.api.lifecycle.LifecyclePhase; |
14 | |
import org.mule.api.lifecycle.Startable; |
15 | |
import org.mule.api.lifecycle.Stoppable; |
16 | |
import org.mule.api.registry.Registry; |
17 | |
import org.mule.lifecycle.EmptyLifecycleCallback; |
18 | |
import org.mule.lifecycle.RegistryLifecycleManager; |
19 | |
import org.mule.lifecycle.phases.ContainerManagedLifecyclePhase; |
20 | |
import org.mule.lifecycle.phases.MuleContextStartPhase; |
21 | |
import org.mule.lifecycle.phases.MuleContextStopPhase; |
22 | |
import org.mule.lifecycle.phases.NotInLifecyclePhase; |
23 | |
import org.mule.registry.AbstractRegistryBroker; |
24 | |
|
25 | |
public class SpringRegistryLifecycleManager extends RegistryLifecycleManager |
26 | |
{ |
27 | |
public SpringRegistryLifecycleManager(String id, Registry object, MuleContext muleContext) |
28 | |
{ |
29 | 0 | super(id, object, muleContext); |
30 | 0 | } |
31 | |
|
32 | |
protected void registerPhases() |
33 | |
{ |
34 | 0 | registerPhase(NotInLifecyclePhase.PHASE_NAME, NOT_IN_LIFECYCLE_PHASE, |
35 | |
new EmptyLifecycleCallback<AbstractRegistryBroker>()); |
36 | 0 | registerPhase(Initialisable.PHASE_NAME, new SpringContextInitialisePhase()); |
37 | 0 | registerPhase(Startable.PHASE_NAME, new MuleContextStartPhase(), |
38 | |
new EmptyLifecycleCallback<AbstractRegistryBroker>()); |
39 | 0 | registerPhase(Stoppable.PHASE_NAME, new MuleContextStopPhase(), |
40 | |
new EmptyLifecycleCallback<AbstractRegistryBroker>()); |
41 | 0 | registerPhase(Disposable.PHASE_NAME, new SpringContextDisposePhase()); |
42 | 0 | } |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
class SpringContextInitialisePhase extends ContainerManagedLifecyclePhase |
53 | |
{ |
54 | |
public SpringContextInitialisePhase() |
55 | 0 | { |
56 | 0 | super(Initialisable.PHASE_NAME, Initialisable.class, Disposable.PHASE_NAME); |
57 | 0 | registerSupportedPhase(NotInLifecyclePhase.PHASE_NAME); |
58 | 0 | } |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
@Override |
67 | |
public void applyLifecycle(Object o) throws LifecycleException |
68 | |
{ |
69 | |
|
70 | 0 | } |
71 | |
} |
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
class SpringContextDisposePhase extends ContainerManagedLifecyclePhase |
79 | |
{ |
80 | |
public SpringContextDisposePhase() |
81 | 0 | { |
82 | 0 | super(Disposable.PHASE_NAME, Disposable.class, Initialisable.PHASE_NAME); |
83 | 0 | registerSupportedPhase(NotInLifecyclePhase.PHASE_NAME); |
84 | |
|
85 | 0 | registerSupportedPhase(LifecyclePhase.ALL_PHASES); |
86 | 0 | } |
87 | |
|
88 | |
@Override |
89 | |
public void applyLifecycle(Object o) throws LifecycleException |
90 | |
{ |
91 | 0 | ((SpringRegistry) o).doDispose(); |
92 | 0 | } |
93 | |
} |
94 | |
|
95 | |
} |