PHP Class AppserverIo\Appserver\Application\Application

Inheritance: extends Thread, implements AppserverIo\Psr\Application\ApplicationInterface, implements AppserverIo\Psr\Application\DirectoryAwareInterface, implements AppserverIo\Psr\Application\FilesystemAwareInterface, implements AppserverIo\Psr\Context\ContextInterface, use trait AppserverIo\Appserver\Core\Traits\ThreadedContextTrait
ファイルを表示 Open project: appserver-io/appserver Class Usage Examples

Public Methods

Method Description
__construct ( ) Initialize the internal members.
addClassLoader ( AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface $classLoader, AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration ) : void Injects an additional class loader.
addLogger ( Psr\Log\LoggerInterface $logger, AppserverIo\Appserver\Core\Api\Node\LoggerNodeInterface $configuration ) : void Injects the logger instance and the configuration.
addManager ( AppserverIo\Psr\Application\ManagerInterface $manager, AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $configuration ) : void Injects manager instance and the configuration.
addProvisioner ( AppserverIo\Psr\Application\ProvisionerInterface $provisioner, AppserverIo\Appserver\Core\Api\Node\ProvisionerNodeInterface $configuration ) : void Injects the provisioner instance and the configuration.
connect ( ) : void Has been automatically invoked by the container after the application instance has been created.
getAppBase ( ) : string Returns the absolute path to the applications base directory.
getBaseDirectory ( string $directoryToAppend = null ) : string Returns the absolute path to the servers document root directory
getCacheDir ( ) : string Returns the absolute path to the applications cache directory.
getClassLoader ( string $identifier ) : AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface Return the requested class loader instance
getClassLoaders ( ) : AppserverIo\Storage\GenericStackable Return the class loaders.
getContainer ( ) : AppserverIo\Appserver\Core\Interfaces\ContainerInterface Return's the container instance the application is bound to.
getContainerName ( ) : string Returns the name of the container the application is bound to.
getContainerRunlevel ( ) : string Returns the runlevel of the container the application is bound to.
getEnvironmentName ( ) : string Returns the applications environment name
getGroup ( ) : string Returns the groupname the application should be executed with.
getInitialContext ( ) : AppserverIo\Appserver\Application\Interfaces\ContextInterface Returns the initial context instance.
getLogger ( string $name = LoggerUtils::SYSTEM ) : Psr\Log\LoggerInterface | null Return the requested logger instance, by default the application's system logger.
getLoggers ( ) : AppserverIo\Storage\GenericStackable Returns the logger instances.
getManager ( string $identifier ) : AppserverIo\Psr\Application\ManagerInterface Return the requested manager instance.
getManagers ( ) : AppserverIo\Storage\GenericStackable Returns the manager instances.
getName ( ) : string Returns the application name (that has to be the class namespace, e.g. example)
getNamingDirectory ( ) : AppserverIo\Psr\Naming\NamingDirectoryInterface Returns the applications naming directory.
getProvisioner ( string $identifier ) : AppserverIo\Psr\Application\ProvisionerInterface Return the requested provisioner instance.
getProvisioners ( ) : AppserverIo\Storage\GenericStackable Returns the provisioner instances.
getSerial ( ) : string Return's the application's UUID.
getSessionDir ( ) : string Returns the absolute path to the applications session directory.
getTmpDir ( ) : string Returns the absolute path to the applications temporary directory.
getUmask ( ) : string Returns the umask the application should create files/directories with.
getUniqueName ( ) : string Return's the unique application name that is the container + application name separated with a slash, e. g. combined-appserver/example.
getUser ( ) : string Returns the username the application should be executed with.
getWebappPath ( ) : string Returns the absolute path to the web application base directory.
initializeManagers ( ) : void Registers all managers in the application.
injectClassLoaders ( AppserverIo\Storage\GenericStackable $classLoaders ) : void Injects the storage for the class loaders.
injectContainerName ( string $containerName ) : void Injects the name of the container the application is bound to.
injectContainerRunlevel ( string $containerRunlevel ) : void Injects the runlevel of the container the application is bound to.
injectEnvironmentName ( string $environmentName ) : void Inject the environment name
injectInitialContext ( AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext ) : void The initial context instance.
injectLoggers ( AppserverIo\Storage\GenericStackable $loggers ) : void Injects the storage for the loggers.
injectManagers ( AppserverIo\Storage\GenericStackable $managers ) : void Injects the storage for the managers.
injectName ( string $name ) : void Injects the application name.
injectNamingDirectory ( AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory ) : void Injects the naming directory.
injectProvisioners ( AppserverIo\Storage\GenericStackable $provisioners ) : void Injects the storage for the provisioners.
isConnected ( ) : boolean TRUE if the application has been connected, else FALSE.
newService ( string $className ) : object (non-PHPdoc)
prepare ( AppserverIo\Appserver\Core\Interfaces\ContainerInterface $container, ContextNode $context ) : void Prepares the application with the specific data found in the passed context node.
provision ( ) : void Provisions the initialized application.
registerClassLoaders ( ) : void Registers all class loaders injected to the applications in the opposite order as they have been injected.
run ( ) : void This is the threads main() method that initializes the application with the autoloader and instantiates all the necessary manager instances.
search ( string $name, array $args = [] ) : mixed Queries the naming directory for the requested name and returns the value or invokes the bound callback.
shutdown ( ) : void Shutdown function to log unexpected errors.
stop ( ) : void Stops the application instance.
unload ( ) : void Cleanup the naming directory from the application entries.

Method Details

__construct() public method

Initialize the internal members.
public __construct ( )

addClassLoader() public method

Injects an additional class loader.
public addClassLoader ( AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface $classLoader, AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration ) : void
$classLoader AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface A class loader to put on the class loader stack
$configuration AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface The class loader's configuration
return void

addLogger() public method

Injects the logger instance and the configuration.
public addLogger ( Psr\Log\LoggerInterface $logger, AppserverIo\Appserver\Core\Api\Node\LoggerNodeInterface $configuration ) : void
$logger Psr\Log\LoggerInterface A provisioner instance
$configuration AppserverIo\Appserver\Core\Api\Node\LoggerNodeInterface The provisioner configuration
return void

addManager() public method

Injects manager instance and the configuration.
public addManager ( AppserverIo\Psr\Application\ManagerInterface $manager, AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $configuration ) : void
$manager AppserverIo\Psr\Application\ManagerInterface A manager instance
$configuration AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface The managers configuration
return void

addProvisioner() public method

Injects the provisioner instance and the configuration.
public addProvisioner ( AppserverIo\Psr\Application\ProvisionerInterface $provisioner, AppserverIo\Appserver\Core\Api\Node\ProvisionerNodeInterface $configuration ) : void
$provisioner AppserverIo\Psr\Application\ProvisionerInterface A provisioner instance
$configuration AppserverIo\Appserver\Core\Api\Node\ProvisionerNodeInterface The provisioner configuration
return void

connect() public method

Has been automatically invoked by the container after the application instance has been created.
See also: Thread::run()
public connect ( ) : void
return void

getAppBase() public method

Returns the absolute path to the applications base directory.
public getAppBase ( ) : string
return string The app base directory

getBaseDirectory() public method

Returns the absolute path to the servers document root directory
public getBaseDirectory ( string $directoryToAppend = null ) : string
$directoryToAppend string The directory to append to the base directory
return string The base directory with appended dir if given

getCacheDir() public method

Returns the absolute path to the applications cache directory.
public getCacheDir ( ) : string
return string The app cache directory

getClassLoader() public method

Return the requested class loader instance
public getClassLoader ( string $identifier ) : AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface
$identifier string The unique identifier of the requested class loader
return AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface The class loader instance

getClassLoaders() public method

Return the class loaders.
public getClassLoaders ( ) : AppserverIo\Storage\GenericStackable
return AppserverIo\Storage\GenericStackable The class loader instances

getContainer() public method

Return's the container instance the application is bound to.
public getContainer ( ) : AppserverIo\Appserver\Core\Interfaces\ContainerInterface
return AppserverIo\Appserver\Core\Interfaces\ContainerInterface The container instance

getContainerName() public method

Returns the name of the container the application is bound to.
public getContainerName ( ) : string
return string The container's name

getContainerRunlevel() public method

Returns the runlevel of the container the application is bound to.
public getContainerRunlevel ( ) : string
return string The container's runlevel

getEnvironmentName() public method

Returns the applications environment name
public getEnvironmentName ( ) : string
return string The applications environment name

getGroup() public method

Returns the groupname the application should be executed with.
public getGroup ( ) : string
return string The groupname

getInitialContext() public method

Returns the initial context instance.
public getInitialContext ( ) : AppserverIo\Appserver\Application\Interfaces\ContextInterface
return AppserverIo\Appserver\Application\Interfaces\ContextInterface The initial Context

getLogger() public method

Return the requested logger instance, by default the application's system logger.
public getLogger ( string $name = LoggerUtils::SYSTEM ) : Psr\Log\LoggerInterface | null
$name string The name of the requested logger
return Psr\Log\LoggerInterface | null The logger instance

getLoggers() public method

Returns the logger instances.
public getLoggers ( ) : AppserverIo\Storage\GenericStackable
return AppserverIo\Storage\GenericStackable The logger instances

getManager() public method

Return the requested manager instance.
public getManager ( string $identifier ) : AppserverIo\Psr\Application\ManagerInterface
$identifier string The unique identifier of the requested manager
return AppserverIo\Psr\Application\ManagerInterface The manager instance

getManagers() public method

Returns the manager instances.
public getManagers ( ) : AppserverIo\Storage\GenericStackable
return AppserverIo\Storage\GenericStackable The manager instances

getName() public method

Returns the application name (that has to be the class namespace, e.g. example)
public getName ( ) : string
return string The application name

getNamingDirectory() public method

Returns the applications naming directory.
public getNamingDirectory ( ) : AppserverIo\Psr\Naming\NamingDirectoryInterface
return AppserverIo\Psr\Naming\NamingDirectoryInterface The applications naming directory interface

getProvisioner() public method

Return the requested provisioner instance.
public getProvisioner ( string $identifier ) : AppserverIo\Psr\Application\ProvisionerInterface
$identifier string The unique identifier of the requested provisioner
return AppserverIo\Psr\Application\ProvisionerInterface The provisioner instance

getProvisioners() public method

Returns the provisioner instances.
public getProvisioners ( ) : AppserverIo\Storage\GenericStackable
return AppserverIo\Storage\GenericStackable The provisioner instances

getSerial() public method

Return's the application's UUID.
public getSerial ( ) : string
return string The application's UUID

getSessionDir() public method

Returns the absolute path to the applications session directory.
public getSessionDir ( ) : string
return string The app session directory

getTmpDir() public method

Returns the absolute path to the applications temporary directory.
public getTmpDir ( ) : string
return string The app temporary directory

getUmask() public method

Returns the umask the application should create files/directories with.
public getUmask ( ) : string
return string The umask

getUniqueName() public method

Return's the unique application name that is the container + application name separated with a slash, e. g. combined-appserver/example.
public getUniqueName ( ) : string
return string

getUser() public method

Returns the username the application should be executed with.
public getUser ( ) : string
return string The username

getWebappPath() public method

Returns the absolute path to the web application base directory.
public getWebappPath ( ) : string
return string The path to the webapps folder

initializeManagers() public method

Registers all managers in the application.
public initializeManagers ( ) : void
return void

injectClassLoaders() public method

Injects the storage for the class loaders.
public injectClassLoaders ( AppserverIo\Storage\GenericStackable $classLoaders ) : void
$classLoaders AppserverIo\Storage\GenericStackable The storage for the class loaders
return void

injectContainerName() public method

Injects the name of the container the application is bound to.
public injectContainerName ( string $containerName ) : void
$containerName string The container's name
return void

injectContainerRunlevel() public method

Injects the runlevel of the container the application is bound to.
public injectContainerRunlevel ( string $containerRunlevel ) : void
$containerRunlevel string The container's runlevel
return void

injectEnvironmentName() public method

Inject the environment name
public injectEnvironmentName ( string $environmentName ) : void
$environmentName string The environment name to inject
return void

injectInitialContext() public method

The initial context instance.
public injectInitialContext ( AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext ) : void
$initialContext AppserverIo\Appserver\Application\Interfaces\ContextInterface The initial context instance
return void

injectLoggers() public method

Injects the storage for the loggers.
public injectLoggers ( AppserverIo\Storage\GenericStackable $loggers ) : void
$loggers AppserverIo\Storage\GenericStackable The storage for the loggers
return void

injectManagers() public method

Injects the storage for the managers.
public injectManagers ( AppserverIo\Storage\GenericStackable $managers ) : void
$managers AppserverIo\Storage\GenericStackable The storage for the managers
return void

injectName() public method

Injects the application name.
public injectName ( string $name ) : void
$name string The application name
return void

injectNamingDirectory() public method

Injects the naming directory.
public injectNamingDirectory ( AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory ) : void
$namingDirectory AppserverIo\Psr\Naming\NamingDirectoryInterface The naming directory instance
return void

injectProvisioners() public method

Injects the storage for the provisioners.
public injectProvisioners ( AppserverIo\Storage\GenericStackable $provisioners ) : void
$provisioners AppserverIo\Storage\GenericStackable The storage for the provisioners
return void

isConnected() public method

TRUE if the application has been connected, else FALSE.
public isConnected ( ) : boolean
return boolean Returns TRUE if the application has been connected, else FALSE

newService() public method

(non-PHPdoc)
See also: AppserverIo\Appserver\Application\Interfaces\ContextInterface::newService()
public newService ( string $className ) : object
$className string The API service class name to return the instance for
return object The service instance

prepare() public method

Prepares the application with the specific data found in the passed context node.
public prepare ( AppserverIo\Appserver\Core\Interfaces\ContainerInterface $container, ContextNode $context ) : void
$container AppserverIo\Appserver\Core\Interfaces\ContainerInterface The container instance bind the application to
$context AppserverIo\Appserver\Core\Api\Node\ContextNode The application configuration
return void

provision() public method

Provisions the initialized application.
public provision ( ) : void
return void

registerClassLoaders() public method

Registers all class loaders injected to the applications in the opposite order as they have been injected.
public registerClassLoaders ( ) : void
return void

run() public method

This is the threads main() method that initializes the application with the autoloader and instantiates all the necessary manager instances.
public run ( ) : void
return void

shutdown() public method

Shutdown function to log unexpected errors.
See also: http://php.net/register_shutdown_function
public shutdown ( ) : void
return void

stop() public method

Stops the application instance.
public stop ( ) : void
return void

unload() public method

Cleanup the naming directory from the application entries.
public unload ( ) : void
return void