1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.webapp; |
20 | |
|
21 | |
import javax.servlet.ServletContextAttributeEvent; |
22 | |
import javax.servlet.ServletRequestAttributeEvent; |
23 | |
import javax.servlet.http.HttpSessionBindingEvent; |
24 | |
|
25 | |
import org.apache.myfaces.config.annotation.LifecycleProviderFactory; |
26 | |
import org.apache.commons.logging.Log; |
27 | |
import org.apache.commons.logging.LogFactory; |
28 | |
|
29 | |
import java.lang.reflect.InvocationTargetException; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public abstract class AbstractMyFacesListener { |
36 | 0 | private static Log log = LogFactory.getLog(AbstractMyFacesListener.class); |
37 | |
|
38 | |
protected void doPreDestroy(ServletRequestAttributeEvent event, String scope) { |
39 | 0 | doPreDestroy(event.getValue(), event.getName(), scope); |
40 | 0 | } |
41 | |
|
42 | |
protected void doPreDestroy(HttpSessionBindingEvent event, String scope) { |
43 | 0 | doPreDestroy(event.getValue(), event.getName(), scope); |
44 | 0 | } |
45 | |
|
46 | |
protected void doPreDestroy(ServletContextAttributeEvent event, String scope) { |
47 | 0 | doPreDestroy(event.getValue(), event.getName(), scope); |
48 | 0 | } |
49 | |
|
50 | |
protected void doPreDestroy(Object value, String name, String scope) { |
51 | |
|
52 | 0 | if(value != null) |
53 | |
{ |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
try |
60 | |
{ |
61 | 0 | LifecycleProviderFactory.getLifecycleProviderFactory().getLifecycleProvider(null).destroyInstance(value); |
62 | 0 | } catch (IllegalAccessException e) |
63 | |
{ |
64 | 0 | log.error("", e); |
65 | 0 | } catch (InvocationTargetException e) |
66 | |
{ |
67 | 0 | log.error("", e); |
68 | 0 | } |
69 | |
} |
70 | 0 | } |
71 | |
} |