| BasePortalLifecycle.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 *
12 *
13 */
14
15 package com.liferay.portal.kernel.util;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19
20 /**
21 * <a href="BasePortalLifecycle.java.html"><b><i>View Source</i></b></a>
22 *
23 * @author Brian Wing Shun Chan
24 */
25 public abstract class BasePortalLifecycle implements PortalLifecycle {
26
27 public void portalDestroy() {
28 if (!_calledPortalDestroy) {
29 PortalLifecycleUtil.removeDestroy(this);
30
31 try {
32 doPortalDestroy();
33 }
34 catch (Exception e) {
35 _log.error(e, e);
36 }
37
38 _calledPortalDestroy = true;
39 }
40 }
41
42 public void portalInit() {
43 try {
44 doPortalInit();
45 }
46 catch (Exception e) {
47 _log.error(e, e);
48 }
49 }
50
51 public void registerPortalLifecycle() {
52 PortalLifecycleUtil.register(this);
53 }
54
55 public void registerPortalLifecycle(int method) {
56 PortalLifecycleUtil.register(this, method);
57 }
58
59 protected abstract void doPortalDestroy() throws Exception;
60
61 protected abstract void doPortalInit() throws Exception;
62
63 private static Log _log = LogFactoryUtil.getLog(BasePortalLifecycle.class);
64
65 private boolean _calledPortalDestroy;
66
67 }