1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\Messaging\Utils\StateKeys |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io/messaging |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Messaging\Utils; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* This class holds the priority keys used as message state. |
25
|
|
|
* |
26
|
|
|
* @author Tim Wagner <[email protected]> |
27
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
28
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
29
|
|
|
* @link https://github.com/appserver-io/messaging |
30
|
|
|
* @link http://www.appserver.io |
31
|
|
|
*/ |
32
|
|
|
class StateKeys |
33
|
|
|
{ |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Private constructor for marking the class as utility. |
37
|
|
|
*/ |
38
|
|
|
final protected function __construct() |
39
|
|
|
{ |
40
|
|
|
/* Class is a utility class */ |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Returns the initialized state key for the passed priority key. |
45
|
|
|
* |
46
|
|
|
* @param integer $key The state key to return the instance for |
47
|
|
|
* |
48
|
|
|
* @return \AppserverIo\Psr\Pms\StateKeyInterface The instance |
49
|
|
|
* |
50
|
|
|
* @throws \Exception |
51
|
|
|
*/ |
52
|
|
|
public static function get($key) |
53
|
|
|
{ |
54
|
|
|
switch($key) { // check the passed key and return the requested state key instance |
|
|
|
|
55
|
|
|
case 1: |
56
|
|
|
return StateActive::get(); |
57
|
|
|
break; |
|
|
|
|
58
|
|
|
case 2: |
59
|
|
|
return StatePaused::get(); |
60
|
|
|
break; |
|
|
|
|
61
|
|
|
case 3: |
62
|
|
|
return StateToProcess::get(); |
63
|
|
|
break; |
|
|
|
|
64
|
|
|
case 4: |
65
|
|
|
return StateInProgress::get(); |
66
|
|
|
break; |
|
|
|
|
67
|
|
|
case 5: |
68
|
|
|
return StateProcessed::get(); |
69
|
|
|
break; |
|
|
|
|
70
|
|
|
case 6: |
71
|
|
|
return StateFailed::get(); |
72
|
|
|
break; |
|
|
|
|
73
|
|
|
case 7: |
74
|
|
|
default: |
75
|
|
|
return StateUnknown::get(); |
76
|
|
|
break; |
|
|
|
|
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|