1
14
15 package com.liferay.portal.kernel.util;
16
17 import java.util.List;
18 import java.util.Vector;
19
20
25 public class PortalLifecycleUtil {
26
27 public static synchronized void flushDestroys() {
28 _inFlushDestroys = true;
29
30 for (PortalLifecycle portalLifecycle : _portalLifecyclesDestroy) {
31 portalLifecycle.portalDestroy();
32 }
33
34 _portalLifecyclesDestroy.clear();
35
36 _inFlushDestroys = false;
37 }
38
39 @SuppressWarnings("deprecation")
40 public static synchronized void flushInits() {
41 if (_portalLifecyclesInit != null) {
42 for (PortalLifecycle portalLifecycle : _portalLifecyclesInit) {
43 portalLifecycle.portalInit();
44 }
45
46 _portalLifecyclesInit = null;
47 }
48
49 PortalInitableUtil.flushInitables();
50 }
51
52 public static synchronized void register(PortalLifecycle portalLifecycle) {
53 register(portalLifecycle, PortalLifecycle.METHOD_ALL);
54 }
55
56 public static synchronized void register(
57 PortalLifecycle portalLifecycle, int method) {
58
59 if ((method == PortalLifecycle.METHOD_ALL) ||
60 (method == PortalLifecycle.METHOD_INIT)) {
61
62 if (_portalLifecyclesInit == null) {
63 portalLifecycle.portalInit();
64 }
65 else {
66 _portalLifecyclesInit.add(portalLifecycle);
67 }
68 }
69
70 if ((method == PortalLifecycle.METHOD_ALL) ||
71 (method == PortalLifecycle.METHOD_DESTROY)) {
72
73 _portalLifecyclesDestroy.add(portalLifecycle);
74 }
75 }
76
77 public static synchronized void removeDestroy(
78 PortalLifecycle portalLifecycle) {
79
80 if (!_inFlushDestroys) {
81 _portalLifecyclesDestroy.remove(portalLifecycle);
82 }
83 }
84
85 private static boolean _inFlushDestroys;
86 private static List<PortalLifecycle> _portalLifecyclesDestroy =
87 new Vector<PortalLifecycle>();
88 private static List<PortalLifecycle> _portalLifecyclesInit =
89 new Vector<PortalLifecycle>();
90
91 }