001
014
015 package com.liferay.portal.kernel.util;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019
020
023 public abstract class BasePortalLifecycle implements PortalLifecycle {
024
025 public void portalDestroy() {
026 if (!_calledPortalDestroy) {
027 PortalLifecycleUtil.removeDestroy(this);
028
029 try {
030 doPortalDestroy();
031 }
032 catch (Exception e) {
033 _log.error(e, e);
034 }
035
036 _calledPortalDestroy = true;
037 }
038 }
039
040 public void portalInit() {
041 try {
042 doPortalInit();
043 }
044 catch (Exception e) {
045 _log.error(e, e);
046
047 throw new IllegalStateException("Unable to initialize portal", e);
048 }
049 }
050
051 public void registerPortalLifecycle() {
052 PortalLifecycleUtil.register(this);
053 }
054
055 public void registerPortalLifecycle(int method) {
056 PortalLifecycleUtil.register(this, method);
057 }
058
059 protected abstract void doPortalDestroy() throws Exception;
060
061 protected abstract void doPortalInit() throws Exception;
062
063 private static Log _log = LogFactoryUtil.getLog(BasePortalLifecycle.class);
064
065 private boolean _calledPortalDestroy;
066
067 }