PHP Class AppserverIo\Appserver\Core\Scanner\AbstractScanner

Inheritance: extends AppserverIo\Appserver\Core\AbstractContextThread, implements AppserverIo\Appserver\Core\Interfaces\ScannerInterface
Show file Open project: appserver-io/appserver Class Usage Examples

Protected Properties

Property Type Description
$distroMapping array The mapping of Linux distributions to their release file's name
$name string The unique scanner name.
$restartCommands array Array that contains the available startup scripts.
$service AppserverIo\Appserver\Core\Api\ContainerService The API service used to load the deployment directory.

Public Methods

Method Description
__construct ( AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext, string $name ) Constructor sets initialContext object per default and calls init function to pass other args.
getName ( ) : string Returns the unique scanner name.
getRestartCommand ( string $os, string | null $distVersion = null ) : string Returns the restart command for the passed OS if available.
getService ( ) : ContainerService Returns The API service, e. g. to load the deployment directory.
getSystemLogger ( ) : Psr\Log\LoggerInterface The system logger to use.
init ( ) : void Initalizes the scanner with the necessary service instance.
newService ( string $className ) : AppserverIo\Appserver\Core\Api\ServiceInterface (non-PHPdoc)
restart ( ) : void Restart the appserver using the appserverctl file in the sbin folder.
stop ( ) : void Stop's the scanner.

Protected Methods

Method Description
getDirectoryHash ( SplFileInfo $directory ) : string Calculates an hash value for all files with certain extensions.
getDistributionVersion ( string | null $distribution = null, array $etcList = [] ) : string | boolean This method will check for the Linux release file normally stored in /etc and will return the version of the distribution
getEtcDir ( ) : string Returns the systems configuration root directory aka "etc"
getExtensionsToWatch ( ) : array Returns an array with file extensions that are used to create the directory hash.
getLastFileTouch ( string $file ) : integer Returns the time when the contents of the file were changed. The time returned is a UNIX timestamp.
getLinuxDistribution ( array $etcList = [] ) : string | boolean This method will check for the Linux release file normally stored in /etc and will return the corresponding distribution

Method Details

__construct() public method

Constructor sets initialContext object per default and calls init function to pass other args.
public __construct ( AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext, string $name )
$initialContext AppserverIo\Appserver\Application\Interfaces\ContextInterface The initial context instance
$name string The unique scanner name from the configuration

getDirectoryHash() protected method

This is used to test if the hash value changed, so if it changed, the appserver can react accordingly.
protected getDirectoryHash ( SplFileInfo $directory ) : string
$directory SplFileInfo The directory to watch
return string The hash value build out of the found filenames

getDistributionVersion() protected method

This method will check for the Linux release file normally stored in /etc and will return the version of the distribution
protected getDistributionVersion ( string | null $distribution = null, array $etcList = [] ) : string | boolean
$distribution string | null Distribution to search a version for
$etcList array List of already collected AND flipped release files we need to filter
return string | boolean

getEtcDir() protected method

Returns the systems configuration root directory aka "etc"
protected getEtcDir ( ) : string
return string

getExtensionsToWatch() abstract protected method

Returns an array with file extensions that are used to create the directory hash.
See also: AppserverIo\Appserver\Core\Scanner\AbstractScanner::getDirectoryHash()
abstract protected getExtensionsToWatch ( ) : array
return array The array with the file extensions

getLastFileTouch() protected method

If the file doesn't exists, the method returns 0 to signal that the no successfull depolyment has been processed so far, e. g. the server has been installed and not been started yet.
protected getLastFileTouch ( string $file ) : integer
$file string The deployment directory
return integer The UNIX timestamp with the last successfully deployment date or 0 if no successful deployment has been processed

getLinuxDistribution() protected method

This method will check for the Linux release file normally stored in /etc and will return the corresponding distribution
protected getLinuxDistribution ( array $etcList = [] ) : string | boolean
$etcList array List of already collected AND flipped release files we need to filter
return string | boolean

getName() public method

Returns the unique scanner name.
See also: AppserverIo\Appserver\Core\Interfaces\ScannerInterface::getName()
public getName ( ) : string
return string The scanner name

getRestartCommand() public method

Returns the restart command for the passed OS if available.
public getRestartCommand ( string $os, string | null $distVersion = null ) : string
$os string The OS to return the restart command for
$distVersion string | null Version of the operating system to get the restart command for
return string The restart command

getService() public method

Returns The API service, e. g. to load the deployment directory.
public getService ( ) : ContainerService
return AppserverIo\Appserver\Core\Api\ContainerService The API service instance

getSystemLogger() public method

The system logger to use.
public getSystemLogger ( ) : Psr\Log\LoggerInterface
return Psr\Log\LoggerInterface The system logger instance

init() public method

Initalizes the scanner with the necessary service instance.
See also: AppserverIo\Appserver\Core\AbstractThread::init()
public init ( ) : void
return void

newService() public method

(non-PHPdoc)
See also: AppserverIo\Appserver\Core\InitialContext::newService()
public newService ( string $className ) : AppserverIo\Appserver\Core\Api\ServiceInterface
$className string The API service class name to return the instance for
return AppserverIo\Appserver\Core\Api\ServiceInterface The service instance

restart() public method

Restart the appserver using the appserverctl file in the sbin folder.
public restart ( ) : void
return void

stop() public method

Stop's the scanner.
See also: AppserverIo\Appserver\Core\Interfaces\ScannerInterface::stop()
public stop ( ) : void
return void

Property Details

$distroMapping protected property

The mapping of Linux distributions to their release file's name
protected array $distroMapping
return array

$name protected property

The unique scanner name.
protected string $name
return string

$restartCommands protected property

Array that contains the available startup scripts.
protected array $restartCommands
return array

$service protected property

The API service used to load the deployment directory.
protected ContainerService,AppserverIo\Appserver\Core\Api $service
return AppserverIo\Appserver\Core\Api\ContainerService