001
014
015 package com.liferay.portal.kernel.util;
016
017 import java.util.List;
018 import java.util.Vector;
019
020
023 public class PortalLifecycleUtil {
024
025 public static synchronized void flushDestroys() {
026 _inFlushDestroys = true;
027
028 for (PortalLifecycle portalLifecycle : _portalLifecyclesDestroy) {
029 portalLifecycle.portalDestroy();
030 }
031
032 _portalLifecyclesDestroy.clear();
033
034 _inFlushDestroys = false;
035 }
036
037 @SuppressWarnings("deprecation")
038 public static synchronized void flushInits() {
039 if (_portalLifecyclesInit != null) {
040 for (PortalLifecycle portalLifecycle : _portalLifecyclesInit) {
041 portalLifecycle.portalInit();
042 }
043
044 _portalLifecyclesInit = null;
045 }
046
047 PortalInitableUtil.flushInitables();
048 }
049
050 public static synchronized void register(PortalLifecycle portalLifecycle) {
051 if (_portalLifecyclesInit == null) {
052 portalLifecycle.portalInit();
053 }
054 else {
055 _portalLifecyclesInit.add(portalLifecycle);
056 }
057
058 _portalLifecyclesDestroy.add(portalLifecycle);
059 }
060
061 public static synchronized void removeDestroy(
062 PortalLifecycle portalLifecycle) {
063
064 if (!_inFlushDestroys) {
065 _portalLifecyclesDestroy.remove(portalLifecycle);
066 }
067 }
068
069 private static boolean _inFlushDestroys;
070 private static List<PortalLifecycle> _portalLifecyclesDestroy =
071 new Vector<PortalLifecycle>();
072 private static List<PortalLifecycle> _portalLifecyclesInit =
073 new Vector<PortalLifecycle>();
074
075 }