1
22
23 package com.liferay.portal.events;
24
25 import com.liferay.portal.im.AIMConnector;
26 import com.liferay.portal.im.ICQConnector;
27 import com.liferay.portal.im.MSNConnector;
28 import com.liferay.portal.im.YMConnector;
29 import com.liferay.portal.jcr.JCRFactoryUtil;
30 import com.liferay.portal.kernel.deploy.hot.HotDeployUtil;
31 import com.liferay.portal.kernel.events.SimpleAction;
32 import com.liferay.portal.kernel.job.JobSchedulerUtil;
33 import com.liferay.portal.kernel.log.Jdk14LogFactoryImpl;
34 import com.liferay.portal.kernel.log.LogFactoryUtil;
35 import com.liferay.portal.kernel.scheduler.SchedulerEngineUtil;
36 import com.liferay.portal.kernel.util.GetterUtil;
37 import com.liferay.portal.pop.POPServerUtil;
38 import com.liferay.portal.util.PropsKeys;
39 import com.liferay.portal.util.PropsUtil;
40 import com.liferay.portal.util.PropsValues;
41 import com.liferay.portlet.documentlibrary.util.DocumentConversionUtil;
42
43 import org.apache.commons.logging.Log;
44 import org.apache.commons.logging.LogFactory;
45
46
52 public class GlobalShutdownAction extends SimpleAction {
53
54 public void run(String[] ids) {
55
56
58 HotDeployUtil.unregisterListeners();
59
60
62 try {
63 _log.debug("Shutting down AIM");
64
65 AIMConnector.disconnect();
66 }
67 catch (Exception e) {
68 }
69
70
72 try {
73 _log.debug("Shutting down ICQ");
74
75 ICQConnector.disconnect();
76 }
77 catch (Exception e) {
78 }
79
80
82 try {
83 _log.debug("Shutting down MSN");
84
85 MSNConnector.disconnect();
86 }
87 catch (Exception e) {
88 }
89
90
92 try {
93 _log.debug("Shutting down YM");
94
95 YMConnector.disconnect();
96 }
97 catch (Exception e) {
98 }
99
100
102 try {
103 _log.debug("Shutting down JCR");
104
105 JCRFactoryUtil.shutdown();
106 }
107 catch (Exception e) {
108 }
109
110
112 DocumentConversionUtil.disconnect();
113
114
116 if (PropsValues.POP_SERVER_NOTIFICATIONS_ENABLED) {
117 POPServerUtil.stop();
118 }
119
120
122 try {
123 JobSchedulerUtil.shutdown();
124 }
125 catch (Exception e) {
126 }
127
128 try {
129 SchedulerEngineUtil.shutdown();
130 }
131 catch (Exception e) {
132 }
133
134
138 try {
139 LogFactoryUtil.setLogFactory(new Jdk14LogFactoryImpl());
140 }
141 catch (Exception e) {
142 }
143
144
146 if (GetterUtil.getBoolean(PropsUtil.get(
147 PropsKeys.SHUTDOWN_PROGRAMMATICALLY_EXIT))) {
148
149 Thread thread = Thread.currentThread();
150
151 ThreadGroup threadGroup = thread.getThreadGroup();
152
153 for (int i = 0; i < 10; i++) {
154 if (threadGroup.getParent() == null) {
155 break;
156 }
157 else {
158 threadGroup = threadGroup.getParent();
159 }
160 }
161
162
164 Thread[] threads = new Thread[threadGroup.activeCount() * 2];
165
166 threadGroup.enumerate(threads);
167
168 for (int i = 0; i < threads.length; i++) {
169 Thread curThread = threads[i];
170
171 if ((curThread != null) && (curThread != thread)) {
172 try {
173 curThread.interrupt();
174 }
175 catch (Exception e) {
176 }
177 }
178 }
179
180 threadGroup.destroy();
181 }
182 }
183
184 private static Log _log = LogFactory.getLog(GlobalShutdownAction.class);
185
186 }