View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.boot;
8   
9   import org.mule.config.i18n.CoreMessages;
10  
11  import org.tanukisoftware.wrapper.WrapperListener;
12  import org.tanukisoftware.wrapper.WrapperManager;
13  
14  /**
15   * There is a need to exit from wrapper
16   * This is a good place for other information message
17   */
18  public class VersionWrapper implements WrapperListener
19  {
20      public Integer start(String[] args)
21      {
22          try
23          {
24              System.out.println(CoreMessages.productInformation());
25          }
26          catch (Exception e)
27          {
28              e.printStackTrace();
29              return Integer.valueOf(1);
30          }
31          return null;
32      }
33  
34      public int stop(int exitCode)
35      {
36          return exitCode;
37      }
38  
39      public void controlEvent(int event)
40      {
41          if (WrapperManager.isControlledByNativeWrapper())
42          {
43              // The Wrapper will take care of this event
44          }
45          else
46          {
47              // We are not being controlled by the Wrapper, so
48              //  handle the event ourselves.
49              if ((event == WrapperManager.WRAPPER_CTRL_C_EVENT) ||
50                  (event == WrapperManager.WRAPPER_CTRL_CLOSE_EVENT) ||
51                  (event == WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT))
52              {
53                  WrapperManager.stop(0);
54              }
55          }
56      }
57  }