11/**
2- This file is part of Waarp Project.
3-
4- Copyright 2009, Frederic Bregier, and individual contributors by the @author
5- tags. See the COPYRIGHT.txt in the distribution for a full listing of
6- individual contributors.
7-
8- All Waarp Project is free software: you can redistribute it and/or
9- modify it under the terms of the GNU General Public License as published
10- by the Free Software Foundation, either version 3 of the License, or
11- (at your option) any later version.
12-
13- Waarp is distributed in the hope that it will be useful,
14- but WITHOUT ANY WARRANTY; without even the implied warranty of
15- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16- GNU General Public License for more details.
17-
18- You should have received a copy of the GNU General Public License
19- along with Waarp . If not, see <http://www.gnu.org/licenses/>.
2+ * This file is part of Waarp Project.
3+ * <p>
4+ * Copyright 2009, Frederic Bregier, and individual contributors by the @author
5+ * tags. See the COPYRIGHT.txt in the distribution for a full listing of
6+ * individual contributors.
7+ * <p>
8+ * All Waarp Project is free software: you can redistribute it and/or
9+ * modify it under the terms of the GNU General Public License as published
10+ * by the Free Software Foundation, either version 3 of the License, or
11+ * (at your option) any later version.
12+ * <p>
13+ * Waarp is distributed in the hope that it will be useful,
14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ * GNU General Public License for more details.
17+ * <p>
18+ * You should have received a copy of the GNU General Public License
19+ * along with Waarp . If not, see <http://www.gnu.org/licenses/>.
2020 */
2121package org .waarp .common .utility ;
2222
23+ import org .waarp .common .future .WaarpFuture ;
24+ import org .waarp .common .logging .WaarpLogger ;
25+ import org .waarp .common .logging .WaarpLoggerFactory ;
26+
2327import java .io .File ;
2428import java .io .IOException ;
2529import java .lang .management .ManagementFactory ;
2832import java .util .Timer ;
2933import java .util .TimerTask ;
3034
31- import org .waarp .common .future .WaarpFuture ;
32- import org .waarp .common .logging .WaarpLogger ;
33- import org .waarp .common .logging .WaarpLoggerFactory ;
34-
3535/**
3636 * @author "Frederic Bregier"
3737 *
@@ -78,15 +78,15 @@ public abstract class WaarpShutdownHook extends Thread {
7878 public WaarpShutdownHook (ShutdownConfiguration configuration ) {
7979 if (initialized ) {
8080 shutdownHook .shutdownConfiguration = configuration ;
81- this . setName ("WaarpShutdownHook" );
82- this . setDaemon (true );
81+ setName ("WaarpShutdownHook" );
82+ setDaemon (true );
8383 shutdownHook = this ;
84- this . shutdownConfiguration = configuration ;
84+ shutdownConfiguration = configuration ;
8585 return ;
8686 }
87- this . shutdownConfiguration = configuration ;
88- this . setName ("WaarpShutdownHook" );
89- this . setDaemon (true );
87+ shutdownConfiguration = configuration ;
88+ setName ("WaarpShutdownHook" );
89+ setDaemon (true );
9090 shutdownHook = this ;
9191 initialized = true ;
9292 }
@@ -136,9 +136,10 @@ public static void terminate(boolean immediateSet) {
136136 if (shutdownHook != null ) {
137137 removeShutdownHook ();
138138 terminate ();
139+ shutdownHook = null ;
139140 } else {
140141 logger .error ("No ShutdownHook setup" );
141- DetectionUtils .SystemExit (1 );
142+ //FBGEXIT DetectionUtils.SystemExit(1);
142143 }
143144 }
144145
@@ -185,7 +186,7 @@ private static void terminate() {
185186 Thread .sleep (1000 );
186187 } catch (InterruptedException e ) {
187188 }
188- DetectionUtils .SystemExit (0 );
189+ //FBGEXIT DetectionUtils.SystemExit(0);
189190 } else {
190191 shutdownHook .launchFinalExit ();
191192 immediate = true ;
@@ -203,6 +204,10 @@ private static void terminate() {
203204 System .err .println ("Exit System" );
204205 //Runtime.getRuntime().halt(0);
205206 }
207+ shutdown = false ;
208+ shutdownStarted = false ;
209+ isShutdownOver = false ;
210+ initialized = false ;
206211 }
207212
208213 /**
@@ -218,12 +223,12 @@ private static void terminate() {
218223 */
219224 static private void printStackTrace (Thread thread ,
220225 StackTraceElement [] stacks ) {
221- System .err .print (thread . toString () + " : " );
226+ System .err .print (thread + " : " );
222227 for (int i = 0 ; i < stacks .length - 1 ; i ++) {
223- System .err .print (stacks [i ]. toString () + " " );
228+ System .err .print (stacks [i ] + " " );
224229 }
225230 if (stacks .length >= 1 ) {
226- System .err .println (stacks [stacks .length - 1 ]. toString () );
231+ System .err .println (stacks [stacks .length - 1 ]);
227232 } else {
228233 System .err .println ();
229234 }
@@ -305,6 +310,8 @@ public void launchFinalExit() {
305310 }
306311 Timer timer = new Timer ("R66FinalExit" , true );
307312 ShutdownTimerTask timerTask = new ShutdownTimerTask ();
313+ logger .warn ("Launch Timer R66 Final Exit in {}" ,
314+ shutdownConfiguration .timeout * 4 );
308315 timer .schedule (timerTask , shutdownConfiguration .timeout * 4 );
309316 }
310317
@@ -381,11 +388,11 @@ public void run() {
381388 }
382389 // Already stopped
383390 System .err .println ("Halt System now - services already stopped -" );
384- DetectionUtils .SystemExit (0 );
391+ //FBGEXIT DetectionUtils.SystemExit(0);
385392 return ;
386393 }
387394 try {
388- terminate ();
395+ terminate (false );
389396 } catch (Throwable t ) {
390397 if (shutdownHook != null && shutdownHook .serviceStopped ()) {
391398 try {
@@ -395,7 +402,7 @@ public void run() {
395402 }
396403 }
397404 System .err .println ("Halt System now" );
398- DetectionUtils .SystemExit (0 );
405+ //FBGEXIT DetectionUtils.SystemExit(0);
399406 }
400407
401408 /**
@@ -443,7 +450,7 @@ public void run() {
443450 printStackTrace (thread , map .get (thread ));
444451 }
445452 }
446- DetectionUtils .SystemExit (0 );
453+ //FBGEXIT DetectionUtils.SystemExit(0);
447454 }
448455 }
449456}
0 commit comments