1 | <?php |
||
34 | class ServerStateKeys |
||
35 | { |
||
36 | |||
37 | /** |
||
38 | * Server has to be stopped. |
||
39 | * |
||
40 | * @var integer |
||
41 | */ |
||
42 | const HALT = 0; |
||
43 | |||
44 | /** |
||
45 | * Server is waiting for initialization. |
||
46 | * |
||
47 | * @var integer |
||
48 | */ |
||
49 | const WAITING_FOR_INITIALIZATION = 1; |
||
50 | |||
51 | /** |
||
52 | * Server has been successfully initialized. |
||
53 | * |
||
54 | * @var integer |
||
55 | */ |
||
56 | const INITIALIZATION_SUCCESSFUL = 2; |
||
57 | |||
58 | /** |
||
59 | * Servers socket has been started successful. |
||
60 | * |
||
61 | * @var integer |
||
62 | */ |
||
63 | const SERVER_SOCKET_STARTED = 3; |
||
64 | |||
65 | /** |
||
66 | * Servers modules has successfully been initialized. |
||
67 | * |
||
68 | * @var integer |
||
69 | */ |
||
70 | const MODULES_INITIALIZED = 4; |
||
71 | |||
72 | /** |
||
73 | * Servers connection handlers has successfully been initialized. |
||
74 | * |
||
75 | * @var integer |
||
76 | */ |
||
77 | const CONNECTION_HANDLERS_INITIALIZED = 5; |
||
78 | |||
79 | /** |
||
80 | * Servers workers has successfully been initialized. |
||
81 | * |
||
82 | * @var integer |
||
83 | */ |
||
84 | const WORKERS_INITIALIZED = 6; |
||
85 | |||
86 | /** |
||
87 | * Server has successfully been shutdown. |
||
88 | * |
||
89 | * @var integer |
||
90 | */ |
||
91 | const SHUTDOWN = 7; |
||
92 | |||
93 | /** |
||
94 | * The actual server state. |
||
95 | * |
||
96 | * @var integer |
||
97 | */ |
||
98 | private $serverState; |
||
99 | |||
100 | /** |
||
101 | * This is a utility class, so protect it against direct |
||
102 | * instantiation. |
||
103 | * |
||
104 | * @param integer $serverState The server state to initialize the instance with |
||
105 | */ |
||
106 | private function __construct($serverState) |
||
110 | |||
111 | /** |
||
112 | * This is a utility class, so protect it against cloning. |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | private function __clone() |
||
119 | |||
120 | /** |
||
121 | * Returns the server state representation as integer. |
||
122 | * |
||
123 | * @return integer The integer representation of the server state |
||
124 | */ |
||
125 | public function getServerState() |
||
129 | |||
130 | /** |
||
131 | * Returns the server state representation as string. |
||
132 | * |
||
133 | * @return string The string representation of the server state |
||
134 | * @see \TechDivision\ApplicationServer\Dictionaries\ServerStateKeys::getServerState() |
||
135 | */ |
||
136 | public function __toString() |
||
140 | |||
141 | /** |
||
142 | * Returns the server states. |
||
143 | * |
||
144 | * @return array The server states |
||
145 | */ |
||
146 | public static function getServerStates() |
||
159 | |||
160 | /** |
||
161 | * Returns TRUE if the server state is greater than the passed one, else FALSE. |
||
162 | * |
||
163 | * @param \AppserverIo\Server\Dictionaries\ServerStateKeys $serverState The server state to be greater than |
||
164 | * |
||
165 | * @return boolean TRUE if equal, else FALSE |
||
166 | */ |
||
167 | public function greaterOrEqualThan(ServerStateKeys $serverState) |
||
171 | |||
172 | /** |
||
173 | * Returns TRUE if the passed server state equals the actual one, else FALSE. |
||
174 | * |
||
175 | * @param \AppserverIo\Server\Dictionaries\ServerStateKeys $serverState The server state to check |
||
176 | * |
||
177 | * @return boolean TRUE if equal, else FALSE |
||
178 | */ |
||
179 | public function equals(ServerStateKeys $serverState) |
||
183 | |||
184 | /** |
||
185 | * Factory method to create a new server state instance. |
||
186 | * |
||
187 | * @param integer $serverState The server state to create an instance for |
||
188 | * |
||
189 | * @return \AppserverIo\Server\Dictionaries\ServerStateKeys The server state key instance |
||
190 | * @throws \AppserverIo\Server\Exceptions\InvalidServerStateException |
||
191 | * Is thrown if the server state is not available |
||
192 | */ |
||
193 | public static function get($serverState) |
||
210 | } |
||
211 |