|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* \AppserverIo\Doppelgaenger\Entities\Pointcut\AbstractPointcut |
|
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 Bernhard Wick <[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/doppelgaenger |
|
18
|
|
|
* @link http://www.appserver.io/ |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppserverIo\Doppelgaenger\Entities\Pointcuts; |
|
22
|
|
|
|
|
23
|
|
|
use AppserverIo\Doppelgaenger\Interfaces\PointcutInterface; |
|
24
|
|
|
use AppserverIo\Doppelgaenger\Entities\Definitions\FunctionDefinition; |
|
25
|
|
|
use AppserverIo\Doppelgaenger\Entities\Definitions\AttributeDefinition; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Definition of a pointcut as a combination of a join-point and advices |
|
29
|
|
|
* |
|
30
|
|
|
* @author Bernhard Wick <[email protected]> |
|
31
|
|
|
* @copyright 2015 TechDivision GmbH - <[email protected]> |
|
32
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
33
|
|
|
* @link https://github.com/appserver-io/doppelgaenger |
|
34
|
|
|
* @link http://www.appserver.io/ |
|
35
|
|
|
* |
|
36
|
|
|
* @see https://www.eclipse.org/aspectj/doc/next/progguide/quick.html |
|
37
|
|
|
* @see https://www.eclipse.org/aspectj/doc/next/progguide/semantics-pointcuts.html |
|
38
|
|
|
* |
|
39
|
|
|
* @property string $expression Raw expression as defined within code |
|
40
|
|
|
* @property boolean $isNegated Has the result of any match to be negated? |
|
41
|
|
|
*/ |
|
42
|
|
|
abstract class AbstractPointcut implements PointcutInterface |
|
43
|
|
|
{ |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Raw expression as defined within code |
|
47
|
|
|
* |
|
48
|
|
|
* @var string $expression |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $expression; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Has the result of any match to be negated? |
|
54
|
|
|
* |
|
55
|
|
|
* @var boolean $isNegated |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $isNegated; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Default constructor |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $expression String representing the expression defining this pointcut |
|
63
|
|
|
* @param boolean $isNegated If any match made against this pointcut's expression has to be negated in its result |
|
64
|
|
|
*/ |
|
65
|
|
|
public function __construct($expression, $isNegated = false) |
|
66
|
|
|
{ |
|
67
|
|
|
$this->expression = $expression; |
|
68
|
|
|
$this->isNegated = $isNegated; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Will return a chain of callbacks which can be used to call woven code in an onion like manner |
|
73
|
|
|
* |
|
74
|
|
|
* @param \AppserverIo\Doppelgaenger\Entities\Definitions\FunctionDefinition $functionDefinition Definition of the function to inject invocation code into |
|
75
|
|
|
* |
|
76
|
|
|
* @return array |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getCallbackChain(FunctionDefinition $functionDefinition) |
|
79
|
|
|
{ |
|
80
|
|
|
return array(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Getter for the expression property |
|
85
|
|
|
* |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getExpression() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->expression; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Returns the pattern which is used to match and define this pointcut |
|
95
|
|
|
* |
|
96
|
|
|
* @return string |
|
97
|
|
|
* |
|
98
|
|
|
* @Enum({"Signature", "TypePattern", "Expression", "Type", "Pointcut"}) |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getMatchPattern() |
|
101
|
|
|
{ |
|
102
|
|
|
return static::MATCH_PATTERN; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Getter for the type property |
|
107
|
|
|
* |
|
108
|
|
|
* @return string |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getType() |
|
111
|
|
|
{ |
|
112
|
|
|
return static::TYPE; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Whether or not the pointcut is considered static, meaning is has to be weaved and evaluated during runtime |
|
117
|
|
|
* anyway |
|
118
|
|
|
* |
|
119
|
|
|
* @return boolean |
|
120
|
|
|
*/ |
|
121
|
|
|
public function isStatic() |
|
122
|
|
|
{ |
|
123
|
|
|
return static::IS_STATIC; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Whether or not the pointcut match has to be negated in its result |
|
128
|
|
|
* |
|
129
|
|
|
* @return boolean |
|
130
|
|
|
*/ |
|
131
|
|
|
public function isNegated() |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->isNegated; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Used to "straighten out" an expression as some expressions allow for shell regex which makes them hard to |
|
138
|
|
|
* generate code from. |
|
139
|
|
|
* So with this method a matching pointcut can be altered into having a directly readable expression |
|
140
|
|
|
* |
|
141
|
|
|
* @param FunctionDefinition|AttributeDefinition $definition Definition to straighten the expression against |
|
142
|
|
|
* |
|
143
|
|
|
* @return null |
|
144
|
|
|
*/ |
|
145
|
|
|
public function straightenExpression($definition) |
|
146
|
|
|
{ |
|
147
|
|
|
// nothing to do in general |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|