1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* \AppserverIo\RemoteMethodInvocation\FilterSessionPredicate |
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
|
|
|
* @author Bernhard Wick <[email protected]> |
16
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
17
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
18
|
|
|
* @link https://github.com/appserver-io/rmi |
19
|
|
|
* @link http://www.appserver.io |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace AppserverIo\RemoteMethodInvocation; |
23
|
|
|
|
24
|
|
|
use AppserverIo\Collections\PredicateInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Predicate to filter a session by it's ID from an ArrayList. |
28
|
|
|
* |
29
|
|
|
* @author Tim Wagner <[email protected]> |
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/rmi |
34
|
|
|
* @link http://www.appserver.io |
35
|
|
|
*/ |
36
|
|
|
class FilterSessionPredicate implements PredicateInterface |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The session-ID we want to filter for. |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $sessionId; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Initializes the predicate with the session-ID we want to filter. |
48
|
|
|
* |
49
|
|
|
* @param string $sessionId The session-ID we want to filter |
50
|
|
|
*/ |
51
|
|
|
public function __construct($sessionId) |
52
|
|
|
{ |
53
|
|
|
$this->sessionId = $sessionId; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* This method evaluates the object passed as parameter against |
58
|
|
|
* the anything specified in the evaluate method. |
59
|
|
|
* |
60
|
|
|
* @param object $object The object that should be evaluated |
61
|
|
|
* |
62
|
|
|
* @return boolean Returns a boolean depending on the implementation of the method |
63
|
|
|
*/ |
64
|
|
|
public function evaluate($object) |
65
|
|
|
{ |
66
|
|
|
return $this->compare($object); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Compares the session-ID of the passed session with the |
71
|
|
|
* internal one and returns TRUE if they match. |
72
|
|
|
* |
73
|
|
|
* @param \AppserverIo\RemoteMethodInvocation\SessionInterface $session The session to compare the ID with |
74
|
|
|
* |
75
|
|
|
* @return boolean TRUE if the IDs are equal, else FALSE |
76
|
|
|
*/ |
77
|
|
|
protected function compare(SessionInterface $session) |
78
|
|
|
{ |
79
|
|
|
return $session->getSessionId() === $this->sessionId; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|