1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\Psr\EnterpriseBeans\Annotations\EnterpriseBean |
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/epb |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Psr\EnterpriseBeans\Annotations; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Annotation implementation representing a @EnterpriseBean annotation on a property. |
25
|
|
|
* |
26
|
|
|
* The name attribute refers to what the naming context name will be for the referenced enterprise bean. |
27
|
|
|
* |
28
|
|
|
* The beanInterface attribute is the interface you are interested in and usually is used by the container |
29
|
|
|
* to distinguish whether you want a remote or local reference to the enterprise bean. |
30
|
|
|
* |
31
|
|
|
* The beanName is the name of the enterprise bean referenced. It is equal to either the value you specify |
32
|
|
|
* in the @Stateless->name() or @Stateful->name() annotation. |
33
|
|
|
 *  |
34
|
|
|
* The lookup attribute, defines the naming context name that should be used to find the target enterprise |
35
|
|
|
* bean reference. When placed on the bean class, the @EnterpriseBean annotation will register a reference into |
36
|
|
|
* the naming context. |
37
|
|
|
* |
38
|
|
|
* @author Tim Wagner <[email protected]> |
39
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
40
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
41
|
|
|
* @link https://github.com/appserver-io-psr/epb |
42
|
|
|
* @link http://www.appserver.io |
43
|
|
|
*/ |
44
|
|
View Code Duplication |
class EnterpriseBean extends AbstractBeanAnnotation |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The annotation for method, a bean has to be injected. |
49
|
|
|
* |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
const ANNOTATION = 'EnterpriseBean'; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* This method returns the class name as |
56
|
|
|
* a string. |
57
|
|
|
* |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public static function __getClass() |
61
|
|
|
{ |
62
|
|
|
return __CLASS__; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Returns the value of the bean interface attribute. |
67
|
|
|
* |
68
|
|
|
* @return string|null The annotations bean interface attribute |
69
|
|
|
*/ |
70
|
|
|
public function getBeanInterface() |
71
|
|
|
{ |
72
|
|
|
if (isset($this->values[AnnotationKeys::BEAN_INTERFACE])) { |
73
|
|
|
return $this->values[AnnotationKeys::BEAN_INTERFACE]; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Returns the value of the bean name attribute. |
79
|
|
|
* |
80
|
|
|
* @return string|null The annotations bean Name attribute |
81
|
|
|
*/ |
82
|
|
|
public function getBeanName() |
83
|
|
|
{ |
84
|
|
|
if (isset($this->values[AnnotationKeys::BEAN_NAME])) { |
85
|
|
|
return $this->values[AnnotationKeys::BEAN_NAME]; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.