|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* \AppserverIo\Psr\Naming\EnterpriseBeanResourceIdentifier |
|
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/naming |
|
18
|
|
|
* @link http://www.appserver.io |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppserverIo\Psr\Naming; |
|
22
|
|
|
|
|
23
|
|
|
use AppserverIo\Properties\PropertiesInterface; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* This is a resource identifier implementation that supports a JNDI like |
|
27
|
|
|
* syntax to create a resource identifier for enterprise beans. |
|
28
|
|
|
* |
|
29
|
|
|
* @author Tim Wagner <[email protected]> |
|
30
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
32
|
|
|
* @link https://github.com/appserver-io-psr/naming |
|
33
|
|
|
* @link http://www.appserver.io |
|
34
|
|
|
*/ |
|
35
|
|
|
class EnterpriseBeanResourceIdentifier extends ResourceIdentifier |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* The key for the local business interface. |
|
40
|
|
|
* |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
const LOCAL_INTERFACE = 'local'; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* The key for the remote business interface. |
|
47
|
|
|
* |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
const REMOTE_INTERFACE = 'remote'; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Identifier for property name 'contextName'. |
|
54
|
|
|
* |
|
55
|
|
|
* @var string |
|
56
|
|
|
*/ |
|
57
|
|
|
const PROPERTY_CONTEXT_NAME = 'contextName'; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Identifier for property name 'className'. |
|
61
|
|
|
* |
|
62
|
|
|
* @var string |
|
63
|
|
|
*/ |
|
64
|
|
|
const PROPERTY_CLASS_NAME = 'className'; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Identifier for property name 'interface'. |
|
68
|
|
|
* |
|
69
|
|
|
* @var string |
|
70
|
|
|
*/ |
|
71
|
|
|
const PROPERTY_INTERFACE = 'interface'; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Identifier for property name 'indexFile'. |
|
75
|
|
|
* |
|
76
|
|
|
* @var string |
|
77
|
|
|
*/ |
|
78
|
|
|
const PROPERTY_INDEX_FILE = 'indexFile'; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Identifier for property name 'transport'. |
|
82
|
|
|
* |
|
83
|
|
|
* @var string |
|
84
|
|
|
*/ |
|
85
|
|
|
const PROPERTY_TRANSPORT = 'transport'; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* The array with the members we want to parse from a URL. |
|
89
|
|
|
* |
|
90
|
|
|
* @var array |
|
91
|
|
|
*/ |
|
92
|
|
|
protected $supportedMembers = array( |
|
93
|
|
|
EnterpriseBeanResourceIdentifier::PROPERTY_CONTEXT_NAME, |
|
94
|
|
|
EnterpriseBeanResourceIdentifier::PROPERTY_CLASS_NAME, |
|
95
|
|
|
EnterpriseBeanResourceIdentifier::PROPERTY_INDEX_FILE, |
|
96
|
|
|
EnterpriseBeanResourceIdentifier::PROPERTY_INTERFACE, |
|
97
|
|
|
EnterpriseBeanResourceIdentifier::PROPERTY_TRANSPORT |
|
98
|
|
|
); |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Returns the array with the supported members. |
|
102
|
|
|
* |
|
103
|
|
|
* @return array The array with the supported members |
|
104
|
|
|
*/ |
|
105
|
|
|
protected function getSupportedMembers() |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->supportedMembers; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Sets the name of the index file. |
|
112
|
|
|
* |
|
113
|
|
|
* @param string $indexFile The name of the index file |
|
114
|
|
|
* |
|
115
|
|
|
* @return void |
|
116
|
|
|
*/ |
|
117
|
|
|
public function setIndexFile($indexFile) |
|
118
|
|
|
{ |
|
119
|
|
|
$this->setValue(EnterpriseBeanResourceIdentifier::PROPERTY_INDEX_FILE, $indexFile); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Returns the name of the index file. |
|
124
|
|
|
* |
|
125
|
|
|
* @return string|null The name of the index file |
|
126
|
|
|
*/ |
|
127
|
11 |
|
public function getIndexFile() |
|
128
|
|
|
{ |
|
129
|
11 |
|
return $this->getValue(EnterpriseBeanResourceIdentifier::PROPERTY_INDEX_FILE); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Sets the context name. |
|
134
|
|
|
* |
|
135
|
|
|
* @param string $contextName The context name |
|
136
|
|
|
* |
|
137
|
|
|
* @return void |
|
138
|
|
|
*/ |
|
139
|
|
|
public function setContextName($contextName) |
|
140
|
|
|
{ |
|
141
|
|
|
$this->setValue(EnterpriseBeanResourceIdentifier::PROPERTY_CONTEXT_NAME, $contextName); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Returns the context name. |
|
146
|
|
|
* |
|
147
|
|
|
* @return string|null The context name |
|
148
|
|
|
*/ |
|
149
|
11 |
|
public function getContextName() |
|
150
|
|
|
{ |
|
151
|
11 |
|
return $this->getValue(EnterpriseBeanResourceIdentifier::PROPERTY_CONTEXT_NAME); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Sets the enterprise beans class name. |
|
156
|
|
|
* |
|
157
|
|
|
* @param string $className The enterprise bean class name |
|
158
|
|
|
* |
|
159
|
|
|
* @return void |
|
160
|
|
|
*/ |
|
161
|
|
|
public function setClassName($className) |
|
162
|
|
|
{ |
|
163
|
|
|
$this->setValue(EnterpriseBeanResourceIdentifier::PROPERTY_CLASS_NAME, $className); |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Returns the enterprise beans class name. |
|
168
|
|
|
* |
|
169
|
|
|
* @return string|null The enterprise bean class name |
|
170
|
|
|
*/ |
|
171
|
11 |
|
public function getClassName() |
|
172
|
|
|
{ |
|
173
|
11 |
|
return $this->getValue(EnterpriseBeanResourceIdentifier::PROPERTY_CLASS_NAME); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* Sets the name of the interface. |
|
178
|
|
|
* |
|
179
|
|
|
* @param string $interface The name of the interface |
|
180
|
|
|
* |
|
181
|
|
|
* @return void |
|
182
|
|
|
*/ |
|
183
|
|
|
public function setInterface($interface) |
|
184
|
|
|
{ |
|
185
|
|
|
$this->setValue(EnterpriseBeanResourceIdentifier::PROPERTY_INTERFACE, $interface); |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* Returns the name of the interface. |
|
190
|
|
|
* |
|
191
|
|
|
* @return string|null The name of the interface |
|
192
|
|
|
*/ |
|
193
|
11 |
|
public function getInterface() |
|
194
|
|
|
{ |
|
195
|
11 |
|
return $this->getValue(EnterpriseBeanResourceIdentifier::PROPERTY_INTERFACE); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* Queries whether the resource identifier requests a local interface or not. |
|
200
|
|
|
* |
|
201
|
|
|
* @return boolean TRUE if resource identifier requests a local interface |
|
202
|
|
|
*/ |
|
203
|
|
|
public function isLocal() |
|
204
|
|
|
{ |
|
205
|
|
|
return $this->getInterface() === EnterpriseBeanResourceIdentifier::LOCAL_INTERFACE; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* Queries whether the resource identifier requests a remote interface or not. |
|
210
|
|
|
* |
|
211
|
|
|
* @return boolean TRUE if resource identifier requests a remote interface |
|
212
|
|
|
*/ |
|
213
|
|
|
public function isRemote() |
|
214
|
|
|
{ |
|
215
|
|
|
return $this->getInterface() === EnterpriseBeanResourceIdentifier::REMOTE_INTERFACE; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* Sets the transport protocol for remote interface handling. |
|
220
|
|
|
* |
|
221
|
|
|
* @param string $transport The transport protocol for remote interface handling |
|
222
|
|
|
* |
|
223
|
|
|
* @return void |
|
224
|
|
|
*/ |
|
225
|
|
|
public function setTransport($transport) |
|
226
|
|
|
{ |
|
227
|
|
|
$this->setValue(EnterpriseBeanResourceIdentifier::PROPERTY_TRANSPORT, $transport); |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* Returns the transport protocol for remote interface handling. |
|
232
|
|
|
* |
|
233
|
|
|
* @return string|null The transport protocol for remote interface handling |
|
234
|
|
|
*/ |
|
235
|
1 |
|
public function getTransport() |
|
236
|
|
|
{ |
|
237
|
1 |
|
return $this->getValue(EnterpriseBeanResourceIdentifier::PROPERTY_TRANSPORT); |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* create a new resource identifier with the URL parts from the passed properties. |
|
242
|
|
|
* |
|
243
|
|
|
* @param \AppserverIo\Properties\PropertiesInterface $properties The configuration properties |
|
244
|
|
|
* |
|
245
|
|
|
* @return \AppserverIo\Psr\Naming\EnterpriseBeanResourceIdentifier The initialized instance |
|
246
|
|
|
*/ |
|
247
|
11 |
|
public static function createFromProperties(PropertiesInterface $properties) |
|
248
|
|
|
{ |
|
249
|
11 |
|
return new EnterpriseBeanResourceIdentifier($properties->toIndexedArray()); |
|
250
|
|
|
} |
|
251
|
|
|
} |
|
252
|
|
|
|