1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.lifecycle; |
20 | |
|
21 | |
import javax.faces.FacesException; |
22 | |
import javax.faces.lifecycle.Lifecycle; |
23 | |
import javax.faces.lifecycle.LifecycleFactory; |
24 | |
import java.util.HashMap; |
25 | |
import java.util.Iterator; |
26 | |
import java.util.Map; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
public class LifecycleFactoryImpl |
34 | |
extends LifecycleFactory |
35 | |
{ |
36 | 0 | private final Map<String, Lifecycle> _lifecycles = new HashMap<String, Lifecycle>(); |
37 | |
|
38 | |
public LifecycleFactoryImpl() |
39 | 0 | { |
40 | 0 | addLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE, new LifecycleImpl()); |
41 | 0 | } |
42 | |
|
43 | |
public void purgeLifecycle() |
44 | |
{ |
45 | 0 | _lifecycles.clear(); |
46 | 0 | addLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE, new LifecycleImpl()); |
47 | 0 | } |
48 | |
|
49 | |
public void addLifecycle(String id, Lifecycle lifecycle) |
50 | |
{ |
51 | 0 | synchronized (_lifecycles) |
52 | |
{ |
53 | 0 | if (_lifecycles.get(id) != null) |
54 | |
{ |
55 | 0 | throw new IllegalArgumentException("Lifecycle with id '" + id + "' already exists."); |
56 | |
} |
57 | 0 | _lifecycles.put(id, lifecycle); |
58 | 0 | } |
59 | 0 | } |
60 | |
|
61 | |
public Lifecycle getLifecycle(String id) |
62 | |
throws FacesException |
63 | |
{ |
64 | 0 | synchronized (_lifecycles) |
65 | |
{ |
66 | 0 | Lifecycle lifecycle = _lifecycles.get(id); |
67 | 0 | if (lifecycle == null) |
68 | |
{ |
69 | 0 | throw new IllegalArgumentException("Unknown lifecycle '" + id + "'."); |
70 | |
} |
71 | 0 | return lifecycle; |
72 | 0 | } |
73 | |
} |
74 | |
|
75 | |
public Iterator<String> getLifecycleIds() |
76 | |
{ |
77 | 0 | return _lifecycles.keySet().iterator(); |
78 | |
} |
79 | |
} |