1 package org.tanukisoftware.wrapper; 2 3 27 28 34 public class WrapperWin32Service 35 { 36 public static final int SERVICE_STATE_STOPPED = 0x00000001; 37 public static final int SERVICE_STATE_START_PENDING = 0x00000002; 38 public static final int SERVICE_STATE_STOP_PENDING = 0x00000003; 39 public static final int SERVICE_STATE_RUNNING = 0x00000004; 40 public static final int SERVICE_STATE_CONTINUE_PENDING = 0x00000005; 41 public static final int SERVICE_STATE_PAUSE_PENDING = 0x00000006; 42 public static final int SERVICE_STATE_PAUSED = 0x00000007; 43 44 45 private String m_name; 46 47 48 private String m_displayName; 49 50 51 private int m_serviceState; 52 53 54 private int m_exitCode; 55 56 59 WrapperWin32Service( byte[] name, byte[] displayName, int serviceState, int exitCode ) 60 { 61 m_name = new String ( name ); 63 m_displayName = new String ( displayName ); 64 65 m_serviceState = serviceState; 66 m_exitCode = exitCode; 67 } 68 69 72 77 public String getName() 78 { 79 return m_name; 80 } 81 82 87 public String getDisplayName() 88 { 89 return m_displayName; 90 } 91 92 97 public String getServiceStateName() 98 { 99 int serviceState = getServiceState(); 100 switch( serviceState ) 101 { 102 case SERVICE_STATE_STOPPED: 103 return "STOPPED"; 104 105 case SERVICE_STATE_START_PENDING: 106 return "START_PENDING"; 107 108 case SERVICE_STATE_STOP_PENDING: 109 return "STOP_PENDING"; 110 111 case SERVICE_STATE_RUNNING: 112 return "RUNNING"; 113 114 case SERVICE_STATE_CONTINUE_PENDING: 115 return "CONTINUE_PENDING"; 116 117 case SERVICE_STATE_PAUSE_PENDING: 118 return "PAUSE_PENDING"; 119 120 case SERVICE_STATE_PAUSED: 121 return "PAUSED"; 122 123 default: 124 return "UNKNOWN(" + serviceState + ")"; 125 } 126 } 127 128 133 public int getServiceState() 134 { 135 return m_serviceState; 136 } 137 138 143 public int getExitCode() 144 { 145 return m_exitCode; 146 } 147 148 153 public String toString() 154 { 155 StringBuffer sb = new StringBuffer (); 156 sb.append( "WrapperWin32Service[name=\"" ); 157 sb.append( getName() ); 158 sb.append( "\", displayName=\"" ); 159 sb.append( getDisplayName() ); 160 161 sb.append( "\", state=" ); 162 sb.append( getServiceStateName() ); 163 sb.append( ", exitCode=" ); 164 sb.append( getExitCode() ); 165 sb.append( "]" ); 166 return sb.toString(); 167 } 168 } 169 170 | Popular Tags |