|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* \AppserverIo\Psr\Servlet\Annotations\Route |
|
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-psr/servlet |
|
18
|
|
|
* @link http://www.appserver.io |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppserverIo\Psr\Servlet\Annotations; |
|
22
|
|
|
|
|
23
|
|
|
use AppserverIo\Lang\Reflection\ReflectionAnnotation; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Annotation to define a servlets routing. |
|
27
|
|
|
* |
|
28
|
|
|
* @author Tim Wagner <[email protected]> |
|
29
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
31
|
|
|
* @link https://github.com/appserver-io-psr/servlet |
|
32
|
|
|
* @link http://www.appserver.io |
|
33
|
|
|
*/ |
|
34
|
|
|
class Route extends ReflectionAnnotation |
|
35
|
|
|
{ |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The annotation to define a servlets routing. |
|
39
|
|
|
* |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
const ANNOTATION = 'Route'; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* The constructor the initializes the instance with the |
|
46
|
|
|
* data passed with the token. |
|
47
|
|
|
* |
|
48
|
|
|
* @param string $annotationName The annotation name |
|
49
|
|
|
* @param array $values The annotation values |
|
50
|
|
|
*/ |
|
51
|
1 |
|
public function __construct($annotationName, array $values = array()) |
|
52
|
|
|
{ |
|
53
|
|
|
|
|
54
|
|
|
// pass values to parent constructor |
|
55
|
1 |
|
parent::__construct($annotationName, $values); |
|
56
|
|
|
|
|
57
|
|
|
// initialize the URL pattern values |
|
58
|
1 |
|
if (!isset($this->values[AnnotationKeys::URL_PATTERN])) { |
|
59
|
|
|
$this->values[AnnotationKeys::URL_PATTERN] = array(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
// initialize the initialization parameter values |
|
63
|
1 |
|
if (!isset($this->values[AnnotationKeys::INIT_PARAMS])) { |
|
64
|
|
|
$this->values[AnnotationKeys::INIT_PARAMS] = array(); |
|
65
|
|
|
} |
|
66
|
1 |
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* This method returns the class name as |
|
70
|
|
|
* a string. |
|
71
|
|
|
* |
|
72
|
|
|
* @return string |
|
73
|
|
|
*/ |
|
74
|
|
|
public static function __getClass() |
|
75
|
|
|
{ |
|
76
|
|
|
return __CLASS__; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Returns the value of the name attribute. |
|
81
|
|
|
* |
|
82
|
|
|
* @return string The annotations name attribute |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function getName() |
|
85
|
|
|
{ |
|
86
|
1 |
|
return $this->values[AnnotationKeys::NAME]; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Returns the value of the displayName attribute. |
|
91
|
|
|
* |
|
92
|
|
|
* @return string The annotations displayName attribute |
|
93
|
|
|
*/ |
|
94
|
1 |
|
public function getDisplayName() |
|
95
|
|
|
{ |
|
96
|
1 |
|
return $this->values[AnnotationKeys::DISPLAY_NAME]; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Returns the value of the description attribute. |
|
101
|
|
|
* |
|
102
|
|
|
* @return string The annotations description attribute |
|
103
|
|
|
*/ |
|
104
|
1 |
|
public function getDescription() |
|
105
|
|
|
{ |
|
106
|
1 |
|
return $this->values[AnnotationKeys::DESCRIPTION]; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Returns the URL patterns the servlet is mapped to. |
|
111
|
|
|
* |
|
112
|
|
|
* @return array The URL patterns |
|
113
|
|
|
*/ |
|
114
|
1 |
|
public function getUrlPattern() |
|
115
|
|
|
{ |
|
116
|
1 |
|
return $this->values[AnnotationKeys::URL_PATTERN]; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Returns the URL initialization parameters the servlet is mapped to. |
|
121
|
|
|
* |
|
122
|
|
|
* @return array The initialization parameters |
|
123
|
|
|
*/ |
|
124
|
1 |
|
public function getInitParams() |
|
125
|
|
|
{ |
|
126
|
1 |
|
return $this->values[AnnotationKeys::INIT_PARAMS]; |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|