AppserverIo\Appserver\Core\InitialContext::__construct PHP Method

__construct() public method

Initializes the context with the connection to the storage backend.
public __construct ( AppserverIo\Appserver\Core\Interfaces\SystemConfigurationInterface $systemConfiguration )
$systemConfiguration AppserverIo\Appserver\Core\Interfaces\SystemConfigurationInterface The system configuration
    public function __construct(SystemConfigurationInterface $systemConfiguration)
    {
        // initialize the storage
        $initialContextNode = $systemConfiguration->getInitialContext();
        $storageNode = $initialContextNode->getStorage();
        $reflectionClass = $this->newReflectionClass($storageNode->getType());
        // create the storage instance
        /** @var StorageInterface $storage */
        $storage = $reflectionClass->newInstance();
        // append the storage servers registered in system configuration
        /** @var \AppserverIo\Appserver\Core\Api\Node\StorageServerNode $storageServer */
        foreach ($storageNode->getStorageServers() as $storageServer) {
            $storage->addServer($storageServer->getAddress(), $storageServer->getPort(), $storageServer->getWeight());
        }
        // add the storage to the initial context
        $this->setStorage($storage);
        // attach the system configuration to the initial context
        $this->setSystemConfiguration($systemConfiguration);
    }