1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* \AppserverIo\Server\Configuration\MainXmlConfiguration |
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 Johann Zelger <[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/server |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Server\Configuration; |
22
|
|
|
|
23
|
|
|
use AppserverIo\Server\Configuration\ServerXmlConfiguration; |
24
|
|
|
use AppserverIo\Server\Configuration\LoggerXmlConfiguration; |
25
|
|
|
use AppserverIo\Server\Configuration\UpstreamXmlConfiguration; |
26
|
|
|
use AppserverIo\Server\Interfaces\MainConfigurationInterface; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Class MainXmlConfiguration |
30
|
|
|
* |
31
|
|
|
* @author Johann Zelger <[email protected]> |
32
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
33
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
34
|
|
|
* @link https://github.com/appserver-io/server |
35
|
|
|
* @link http://www.appserver.io |
36
|
|
|
*/ |
37
|
|
|
class MainXmlConfiguration implements MainConfigurationInterface |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* Hold's the simple xml element read from file |
41
|
|
|
* |
42
|
|
|
* @var \SimpleXMLElement |
43
|
|
|
*/ |
44
|
|
|
protected $xml; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Constructs main configuration |
48
|
|
|
* |
49
|
|
|
* @param string $filename The filename to load simple xml with |
50
|
|
|
*/ |
51
|
|
|
public function __construct($filename) |
52
|
|
|
{ |
53
|
|
|
$this->xml = simplexml_load_file($filename); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Return's server config nodes as array |
58
|
|
|
* |
59
|
|
|
* @return array |
60
|
|
|
*/ |
61
|
|
|
public function getServerConfigs() |
62
|
|
|
{ |
63
|
|
|
$serverConfigurations = array(); |
64
|
|
|
if (isset($this->xml->servers)) { |
65
|
|
|
foreach ($this->xml->servers->server as $serverConfig) { |
66
|
|
|
$serverConfigurations[] = new ServerXmlConfiguration($serverConfig); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
return $serverConfigurations; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Return's logger config nodes as array |
74
|
|
|
* |
75
|
|
|
* @return array |
76
|
|
|
*/ |
77
|
|
|
public function getLoggerConfigs() |
78
|
|
|
{ |
79
|
|
|
$loggerConfigurations = array(); |
80
|
|
|
if (isset($this->xml->loggers)) { |
81
|
|
|
foreach ($this->xml->loggers->logger as $loggerConfig) { |
82
|
|
|
$loggerConfigurations[] = new LoggerXmlConfiguration($loggerConfig); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
return $loggerConfigurations; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Return's upstream config nodes as array |
90
|
|
|
* |
91
|
|
|
* @return array |
92
|
|
|
*/ |
93
|
|
|
public function getUpstreamConfigs() |
94
|
|
|
{ |
95
|
|
|
$upstreamConfigurations = array(); |
96
|
|
|
if (isset($this->xml->upstreams)) { |
97
|
|
|
foreach ($this->xml->upstreams->upstream as $upstreamConfig) { |
98
|
|
|
$upstreamConfigurations[] = new UpstreamXmlConfiguration($upstreamConfig); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
return $upstreamConfigurations; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|