1
14
15 package com.liferay.portal.events;
16
17 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
18 import com.liferay.portal.kernel.cluster.ClusterExecutorUtil;
19 import com.liferay.portal.kernel.events.ActionException;
20 import com.liferay.portal.kernel.events.SimpleAction;
21 import com.liferay.portal.kernel.log.Log;
22 import com.liferay.portal.kernel.log.LogFactoryUtil;
23 import com.liferay.portal.kernel.messaging.MessageBus;
24 import com.liferay.portal.kernel.messaging.MessageBusUtil;
25 import com.liferay.portal.kernel.messaging.sender.MessageSender;
26 import com.liferay.portal.kernel.messaging.sender.SynchronousMessageSender;
27 import com.liferay.portal.kernel.scheduler.SchedulerEngineUtil;
28 import com.liferay.portal.kernel.util.ReleaseInfo;
29 import com.liferay.portal.kernel.velocity.VelocityEngineUtil;
30 import com.liferay.portal.scheduler.SchedulerEngineProxy;
31 import com.liferay.portal.security.lang.PortalSecurityManager;
32 import com.liferay.portal.service.LockLocalServiceUtil;
33 import com.liferay.portal.tools.DBUpgrader;
34 import com.liferay.portal.util.PropsValues;
35
36
43 public class StartupAction extends SimpleAction {
44
45 public void run(String[] ids) throws ActionException {
46 try {
47 doRun(ids);
48 }
49 catch (RuntimeException re) {
50 throw re;
51 }
52 catch (Exception e) {
53 throw new ActionException(e);
54 }
55 }
56
57 protected void doRun(String[] ids) throws Exception {
58
59
61 System.out.println("Starting " + ReleaseInfo.getReleaseInfo());
62
63
65 if (_log.isDebugEnabled()) {
66 _log.debug("Clear locks");
67 }
68
69 try {
70 LockLocalServiceUtil.clear();
71 }
72 catch (Exception e) {
73 if (_log.isWarnEnabled()) {
74 _log.warn(
75 "Unable to clear locks because Lock table does not exist");
76 }
77 }
78
79
81 if (_log.isDebugEnabled()) {
82 _log.debug("Add shutdown hook");
83 }
84
85 Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook()));
86
87
89 if ((System.getSecurityManager() == null) &&
90 (PropsValues.PORTAL_SECURITY_MANAGER_ENABLE)) {
91
92 System.setSecurityManager(new PortalSecurityManager());
93 }
94
95
97 if (_log.isDebugEnabled()) {
98 _log.debug("Initialize Velocity engine");
99 }
100
101 VelocityEngineUtil.init();
102
103
105 if (_log.isDebugEnabled()) {
106 _log.debug("Upgrade database");
107 }
108
109 DBUpgrader.upgrade();
110
111
113 if (_log.isDebugEnabled()) {
114 _log.debug("Initialize message bus");
115 }
116
117 MessageBus messageBus = (MessageBus)PortalBeanLocatorUtil.locate(
118 MessageBus.class.getName());
119 MessageSender messageSender =
120 (MessageSender)PortalBeanLocatorUtil.locate(
121 MessageSender.class.getName());
122 SynchronousMessageSender synchronousMessageSender =
123 (SynchronousMessageSender)PortalBeanLocatorUtil.locate(
124 SynchronousMessageSender.class.getName());
125
126 MessageBusUtil.init(
127 messageBus, messageSender, synchronousMessageSender);
128
129
131 if (_log.isDebugEnabled()) {
132 _log.debug("Initialize scheduler engine");
133 }
134
135 SchedulerEngineUtil.init(new SchedulerEngineProxy());
136
137 SchedulerEngineUtil.start();
138
139
141 if (_log.isDebugEnabled()) {
142 _log.debug("Verify database");
143 }
144
145 DBUpgrader.verify();
146
147
149 ClusterExecutorUtil.initialize();
150 }
151
152 private static Log _log = LogFactoryUtil.getLog(StartupAction.class);
153
154 }