1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.spi; |
20 | |
|
21 | |
import org.apache.myfaces.spi.impl.DefaultFacesConfigurationMergerFactory; |
22 | |
import org.apache.myfaces.spi.impl.SpiUtils; |
23 | |
|
24 | |
import javax.faces.FacesException; |
25 | |
import javax.faces.context.ExternalContext; |
26 | |
import java.security.AccessController; |
27 | |
import java.security.PrivilegedActionException; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public abstract class FacesConfigurationMergerFactory |
37 | |
{ |
38 | |
|
39 | 0 | protected static final String FACTORY_DEFAULT = DefaultFacesConfigurationMergerFactory.class.getName(); |
40 | |
|
41 | 0 | private static final String FACTORY_KEY = FacesConfigurationMergerFactory.class.getName(); |
42 | |
|
43 | |
public static FacesConfigurationMergerFactory getFacesConfigurationMergerFactory(ExternalContext ctx) |
44 | |
{ |
45 | 0 | FacesConfigurationMergerFactory factory |
46 | |
= (FacesConfigurationMergerFactory) ctx.getApplicationMap().get(FACTORY_KEY); |
47 | |
|
48 | 0 | if (factory != null) |
49 | |
{ |
50 | |
|
51 | 0 | return factory; |
52 | |
} |
53 | |
|
54 | |
|
55 | |
try |
56 | |
{ |
57 | |
|
58 | 0 | if (System.getSecurityManager() != null) |
59 | |
{ |
60 | 0 | final ExternalContext ectx = ctx; |
61 | 0 | factory = (FacesConfigurationMergerFactory) AccessController.doPrivileged( |
62 | |
new java.security.PrivilegedExceptionAction<Object>() |
63 | 0 | { |
64 | |
public Object run() throws PrivilegedActionException |
65 | |
{ |
66 | 0 | return SpiUtils.build(ectx, |
67 | |
FacesConfigurationMergerFactory.class, |
68 | |
FACTORY_DEFAULT); |
69 | |
} |
70 | |
}); |
71 | 0 | } |
72 | |
else |
73 | |
{ |
74 | 0 | factory = (FacesConfigurationMergerFactory) SpiUtils |
75 | |
.build(ctx, FacesConfigurationMergerFactory.class, FACTORY_DEFAULT); |
76 | |
} |
77 | |
} |
78 | 0 | catch (PrivilegedActionException pae) |
79 | |
{ |
80 | 0 | throw new FacesException(pae); |
81 | 0 | } |
82 | |
|
83 | 0 | if (factory != null) |
84 | |
{ |
85 | |
|
86 | 0 | setFacesConfigurationMergerFactory(ctx, factory); |
87 | |
} |
88 | |
|
89 | 0 | return factory; |
90 | |
} |
91 | |
|
92 | |
public static void setFacesConfigurationMergerFactory(ExternalContext ctx, |
93 | |
FacesConfigurationMergerFactory factory) |
94 | |
{ |
95 | 0 | ctx.getApplicationMap().put(FACTORY_KEY, factory); |
96 | 0 | } |
97 | |
|
98 | |
public abstract FacesConfigurationMerger getFacesConfigurationMerger(ExternalContext externalContext); |
99 | |
|
100 | |
} |