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 java.security.AccessController; |
22 | |
import java.security.PrivilegedActionException; |
23 | |
import java.security.PrivilegedExceptionAction; |
24 | |
import javax.faces.FacesException; |
25 | |
import javax.faces.FacesWrapper; |
26 | |
import javax.faces.context.ExternalContext; |
27 | |
import org.apache.myfaces.spi.impl.SpiUtils; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public abstract class ViewScopeProviderFactory implements FacesWrapper<ViewScopeProviderFactory> |
34 | |
{ |
35 | |
protected static final String FACTORY_DEFAULT = |
36 | |
"org.apache.myfaces.spi.impl.DefaultViewScopeProviderFactory"; |
37 | |
|
38 | 0 | private static final String FACTORY_KEY = ViewScopeProviderFactory.class.getName(); |
39 | |
|
40 | |
public static ViewScopeProviderFactory getViewScopeHandlerFactory(ExternalContext ctx) |
41 | |
{ |
42 | 0 | ViewScopeProviderFactory instance |
43 | |
= (ViewScopeProviderFactory) ctx.getApplicationMap().get(FACTORY_KEY); |
44 | 0 | if (instance != null) |
45 | |
{ |
46 | 0 | return instance; |
47 | |
} |
48 | 0 | ViewScopeProviderFactory lpf = null; |
49 | |
try |
50 | |
{ |
51 | |
|
52 | 0 | if (System.getSecurityManager() != null) |
53 | |
{ |
54 | 0 | final ExternalContext ectx = ctx; |
55 | 0 | lpf = (ViewScopeProviderFactory) |
56 | |
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() |
57 | 0 | { |
58 | |
public Object run() throws PrivilegedActionException |
59 | |
{ |
60 | 0 | return SpiUtils.build(ectx, |
61 | |
ViewScopeProviderFactory.class, |
62 | |
FACTORY_DEFAULT); |
63 | |
} |
64 | |
}); |
65 | 0 | } |
66 | |
else |
67 | |
{ |
68 | 0 | lpf = (ViewScopeProviderFactory) |
69 | |
SpiUtils.build(ctx, ViewScopeProviderFactory.class, FACTORY_DEFAULT); |
70 | |
} |
71 | |
} |
72 | 0 | catch (PrivilegedActionException pae) |
73 | |
{ |
74 | 0 | throw new FacesException(pae); |
75 | 0 | } |
76 | 0 | if (lpf != null) |
77 | |
{ |
78 | 0 | setViewScopeHandlerFactory(ctx, lpf); |
79 | |
} |
80 | 0 | return lpf; |
81 | |
} |
82 | |
|
83 | |
public static void setViewScopeHandlerFactory(ExternalContext ctx, |
84 | |
ViewScopeProviderFactory instance) |
85 | |
{ |
86 | 0 | ctx.getApplicationMap().put(FACTORY_KEY, instance); |
87 | 0 | } |
88 | |
|
89 | |
public abstract ViewScopeProvider getViewScopeHandler(ExternalContext ctx); |
90 | |
|
91 | |
public ViewScopeProviderFactory getWrapped() |
92 | |
{ |
93 | 0 | return null; |
94 | |
} |
95 | |
|
96 | |
public abstract void setViewScopeHandler(ExternalContext ctx, ViewScopeProvider viewScopeHandler); |
97 | |
} |