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
|
|
|
/** |
24
|
|
|
* Annotation to define a servlets routing. |
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-psr/servlet |
30
|
|
|
* @link http://www.appserver.io |
31
|
|
|
* |
32
|
|
|
* @Annotation |
33
|
|
|
* @Target({"CLASS"}) |
34
|
|
|
*/ |
35
|
|
|
class Route |
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The value of the name attribute. |
40
|
|
|
* |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $name; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The value of the displayName attribute. |
47
|
|
|
* |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
protected $displayName; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* The value of the description attribute. |
54
|
|
|
* |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
protected $description; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* The URL patterns the servlet is mapped to. |
61
|
|
|
* |
62
|
|
|
* @var array |
63
|
|
|
*/ |
64
|
|
|
protected $urlPattern = array(); |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* The URL initialization parameters the servlet is mapped to. |
68
|
|
|
* |
69
|
|
|
* @var array |
70
|
|
|
*/ |
71
|
|
|
protected $initParams = array(); |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* The constructor the initializes the instance with the |
75
|
|
|
* data passed with the token. |
76
|
|
|
* |
77
|
|
|
* @param array $values The annotation values |
78
|
|
|
*/ |
79
|
1 |
|
public function __construct(array $values = array()) |
80
|
|
|
{ |
81
|
|
|
|
82
|
|
|
// set the name attribute, if available |
83
|
1 |
|
if (isset($values[AnnotationKeys::NAME])) { |
84
|
1 |
|
$this->name = $values[AnnotationKeys::NAME]; |
85
|
1 |
|
} |
86
|
|
|
|
87
|
|
|
// set the display name attribute, if available |
88
|
1 |
|
if (isset($values[AnnotationKeys::DISPLAY_NAME])) { |
89
|
1 |
|
$this->displayName = $values[AnnotationKeys::DISPLAY_NAME]; |
90
|
1 |
|
} |
91
|
|
|
|
92
|
|
|
// set the display name attribute, if available |
93
|
1 |
|
if (isset($values[AnnotationKeys::DESCRIPTION])) { |
94
|
1 |
|
$this->description = $values[AnnotationKeys::DESCRIPTION]; |
95
|
1 |
|
} |
96
|
|
|
|
97
|
|
|
// set the url pattern attribute, if available |
98
|
1 |
|
if (isset($values[AnnotationKeys::URL_PATTERN])) { |
99
|
1 |
|
$this->urlPattern = $values[AnnotationKeys::URL_PATTERN]; |
100
|
1 |
|
} |
101
|
|
|
|
102
|
|
|
// set the init params attribute, if available |
103
|
1 |
|
if (isset($values[AnnotationKeys::INIT_PARAMS])) { |
104
|
1 |
|
$this->initParams = $values[AnnotationKeys::INIT_PARAMS]; |
105
|
1 |
|
} |
106
|
1 |
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Returns the value of the name attribute. |
110
|
|
|
* |
111
|
|
|
* @return string The annotations name attribute |
112
|
|
|
*/ |
113
|
1 |
|
public function getName() |
114
|
|
|
{ |
115
|
1 |
|
return $this->name; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Returns the value of the displayName attribute. |
120
|
|
|
* |
121
|
|
|
* @return string The annotations displayName attribute |
122
|
|
|
*/ |
123
|
1 |
|
public function getDisplayName() |
124
|
|
|
{ |
125
|
1 |
|
return $this->displayName; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Returns the value of the description attribute. |
130
|
|
|
* |
131
|
|
|
* @return string The annotations description attribute |
132
|
|
|
*/ |
133
|
1 |
|
public function getDescription() |
134
|
|
|
{ |
135
|
1 |
|
return $this->description; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Returns the URL patterns the servlet is mapped to. |
140
|
|
|
* |
141
|
|
|
* @return array The URL patterns |
142
|
|
|
*/ |
143
|
1 |
|
public function getUrlPattern() |
144
|
|
|
{ |
145
|
1 |
|
return $this->urlPattern; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Returns the URL initialization parameters the servlet is mapped to. |
150
|
|
|
* |
151
|
|
|
* @return array The initialization parameters |
152
|
|
|
*/ |
153
|
1 |
|
public function getInitParams() |
154
|
|
|
{ |
155
|
1 |
|
return $this->initParams; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|