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 @Override
026 public void portalDestroy() {
027 if (!_calledPortalDestroy) {
028 PortalLifecycleUtil.removeDestroy(this);
029
030 try {
031 doPortalDestroy();
032 }
033 catch (Exception e) {
034 _log.error(e, e);
035 }
036
037 _calledPortalDestroy = true;
038 }
039 }
040
041 @Override
042 public void portalInit() {
043 try {
044 doPortalInit();
045 }
046 catch (Exception e) {
047 _log.error(e, e);
048
049 throw new IllegalStateException("Unable to initialize portal", e);
050 }
051 }
052
053 public void registerPortalLifecycle() {
054 PortalLifecycleUtil.register(this);
055 }
056
057 public void registerPortalLifecycle(int method) {
058 PortalLifecycleUtil.register(this, method);
059 }
060
061 protected abstract void doPortalDestroy() throws Exception;
062
063 protected abstract void doPortalInit() throws Exception;
064
065 private static Log _log = LogFactoryUtil.getLog(BasePortalLifecycle.class);
066
067 private boolean _calledPortalDestroy;
068
069 }