repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/AnalyticsNodeTrait.php
AnalyticsNodeTrait.getAnalytic
public function getAnalytic($uri) { // iterate over all analytics /** @var \AppserverIo\Appserver\Core\Api\Node\AnalyticNode $analyticNode */ foreach ($this->getAnalytics() as $analyticNode) { // if we found one with a matching URI we will return it if ($analyticNode->getUri() === $uri) { return $analyticNode; } } // we did not find anything return false; }
php
public function getAnalytic($uri) { // iterate over all analytics /** @var \AppserverIo\Appserver\Core\Api\Node\AnalyticNode $analyticNode */ foreach ($this->getAnalytics() as $analyticNode) { // if we found one with a matching URI we will return it if ($analyticNode->getUri() === $uri) { return $analyticNode; } } // we did not find anything return false; }
[ "public", "function", "getAnalytic", "(", "$", "uri", ")", "{", "// iterate over all analytics", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\AnalyticNode $analyticNode */", "foreach", "(", "$", "this", "->", "getAnalytics", "(", ")", "as", "$", "analyticNode", ")",...
Will return the analytic node with the specified definition and if nothing could be found we will return false @param string $uri The URI of the analytic in question @return \AppserverIo\Appserver\Core\Api\Node\AnalyticNode|boolean The requested analytics node
[ "Will", "return", "the", "analytic", "node", "with", "the", "specified", "definition", "and", "if", "nothing", "could", "be", "found", "we", "will", "return", "false" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/AnalyticsNodeTrait.php#L63-L77
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/AnalyticsNodeTrait.php
AnalyticsNodeTrait.getAnalyticsAsArray
public function getAnalyticsAsArray() { // initialize the array for the analytics $analytics = array(); // iterate over the analytics nodes and sort them into an array /** @var \AppserverIo\Appserver\Core\Api\Node\AnalyticNode $analyticNode */ foreach ($this->getAnalytics() as $analyticNode) { // restructure to an array $analytics[] = array( 'uri' => $analyticNode->getUri(), 'connectors' => $analyticNode->getConnectorsAsArray() ); } // return the array return $analytics; }
php
public function getAnalyticsAsArray() { // initialize the array for the analytics $analytics = array(); // iterate over the analytics nodes and sort them into an array /** @var \AppserverIo\Appserver\Core\Api\Node\AnalyticNode $analyticNode */ foreach ($this->getAnalytics() as $analyticNode) { // restructure to an array $analytics[] = array( 'uri' => $analyticNode->getUri(), 'connectors' => $analyticNode->getConnectorsAsArray() ); } // return the array return $analytics; }
[ "public", "function", "getAnalyticsAsArray", "(", ")", "{", "// initialize the array for the analytics", "$", "analytics", "=", "array", "(", ")", ";", "// iterate over the analytics nodes and sort them into an array", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\AnalyticNode $...
Returns the analytics as an associative array @return array The array with the sorted analytics
[ "Returns", "the", "analytics", "as", "an", "associative", "array" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/AnalyticsNodeTrait.php#L84-L102
appserver-io/appserver
src/AppserverIo/Appserver/Application/ApplicationStateKeys.php
ApplicationStateKeys.getApplicationStates
public static function getApplicationStates() { return array( ApplicationStateKeys::HALT, ApplicationStateKeys::WAITING_FOR_INITIALIZATION, ApplicationStateKeys::INITIALIZATION_SUCCESSFUL, ApplicationStateKeys::DEPLOYMENT_SUCCESSFUL, ApplicationStateKeys::SERVERS_STARTED_SUCCESSFUL, ApplicationStateKeys::SHUTDOWN ); }
php
public static function getApplicationStates() { return array( ApplicationStateKeys::HALT, ApplicationStateKeys::WAITING_FOR_INITIALIZATION, ApplicationStateKeys::INITIALIZATION_SUCCESSFUL, ApplicationStateKeys::DEPLOYMENT_SUCCESSFUL, ApplicationStateKeys::SERVERS_STARTED_SUCCESSFUL, ApplicationStateKeys::SHUTDOWN ); }
[ "public", "static", "function", "getApplicationStates", "(", ")", "{", "return", "array", "(", "ApplicationStateKeys", "::", "HALT", ",", "ApplicationStateKeys", "::", "WAITING_FOR_INITIALIZATION", ",", "ApplicationStateKeys", "::", "INITIALIZATION_SUCCESSFUL", ",", "Appl...
Returns the container states. @return array The container states
[ "Returns", "the", "container", "states", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/ApplicationStateKeys.php#L130-L140
appserver-io/appserver
src/AppserverIo/Appserver/Application/ApplicationStateKeys.php
ApplicationStateKeys.get
public static function get($applicationState) { // check if the requested container state is available and create a new instance if (in_array($applicationState, ApplicationStateKeys::getApplicationStates())) { return new ApplicationStateKeys($applicationState); } // throw a exception if the requested runlevel is not available throw new InvalidApplicationStateException( sprintf( 'Requested application state %s is not available (choose on of: %s)', $applicationState, implode(',', ApplicationStateKeys::getApplicationStates()) ) ); }
php
public static function get($applicationState) { // check if the requested container state is available and create a new instance if (in_array($applicationState, ApplicationStateKeys::getApplicationStates())) { return new ApplicationStateKeys($applicationState); } // throw a exception if the requested runlevel is not available throw new InvalidApplicationStateException( sprintf( 'Requested application state %s is not available (choose on of: %s)', $applicationState, implode(',', ApplicationStateKeys::getApplicationStates()) ) ); }
[ "public", "static", "function", "get", "(", "$", "applicationState", ")", "{", "// check if the requested container state is available and create a new instance", "if", "(", "in_array", "(", "$", "applicationState", ",", "ApplicationStateKeys", "::", "getApplicationStates", "...
Factory method to create a new application state instance. @param integer $applicationState The application state to create an instance for @return \AppserverIo\Appserver\Application\ApplicationStateKeys The application state key instance @throws \AppserverIo\Appserver\Application\InvalidApplicationStateException Is thrown if the application state is not available
[ "Factory", "method", "to", "create", "a", "new", "application", "state", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/ApplicationStateKeys.php#L187-L203
appserver-io/appserver
src/AppserverIo/Appserver/DependencyInjectionContainer/DirectoryParser.php
DirectoryParser.parse
public function parse() { // parse the directories from the servlet managers configuration foreach ($this->getDirectories() as $directory) { // parse the directories for annotated servlets $this->parseDirectory(DirectoryKeys::realpath($directory)); } }
php
public function parse() { // parse the directories from the servlet managers configuration foreach ($this->getDirectories() as $directory) { // parse the directories for annotated servlets $this->parseDirectory(DirectoryKeys::realpath($directory)); } }
[ "public", "function", "parse", "(", ")", "{", "// parse the directories from the servlet managers configuration", "foreach", "(", "$", "this", "->", "getDirectories", "(", ")", "as", "$", "directory", ")", "{", "// parse the directories for annotated servlets", "$", "this...
Parses the bean context's web application base directory for beans that has to be registered in the object manager. @return void
[ "Parses", "the", "bean", "context", "s", "web", "application", "base", "directory", "for", "beans", "that", "has", "to", "be", "registered", "in", "the", "object", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/DependencyInjectionContainer/DirectoryParser.php#L44-L52
appserver-io/appserver
src/AppserverIo/Appserver/DependencyInjectionContainer/DirectoryParser.php
DirectoryParser.parseDirectory
protected function parseDirectory($directory) { // check if we've found a valid directory if (is_dir($directory) === false) { return; } // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // check directory for classes we want to register /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */ $service = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); $phpFiles = $service->globDir($directory . DIRECTORY_SEPARATOR . '*.php'); // iterate all php files foreach ($phpFiles as $phpFile) { // iterate over all configured descriptors and try to load object description foreach ($this->getDescriptors() as $descriptor) { try { // cut off the META-INF directory and replace OS specific directory separators $relativePathToPhpFile = str_replace(DIRECTORY_SEPARATOR, '\\', str_replace($directory, '', $phpFile)); // now cut off the .php extension $className = substr($relativePathToPhpFile, 0, -4); // we need a reflection class to read the annotations /** \AppserverIo\Lang\Reflection\ClassInterface $reflectionClass */ $reflectionClass = $objectManager->getReflectionClass($className); // load the descriptor class $descriptorClass = $descriptor->getNodeValue()->getValue(); // load the object descriptor and add it to the object manager /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ if (class_exists($descriptorClass)) { if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromReflectionClass($reflectionClass)) { $objectManager->addObjectDescriptor($objectDescriptor); } } // if class can not be reflected continue with next class } catch (\Exception $e) { // log an error message $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString()); // proceed with the next bean continue; } } } }
php
protected function parseDirectory($directory) { // check if we've found a valid directory if (is_dir($directory) === false) { return; } // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // check directory for classes we want to register /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */ $service = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); $phpFiles = $service->globDir($directory . DIRECTORY_SEPARATOR . '*.php'); // iterate all php files foreach ($phpFiles as $phpFile) { // iterate over all configured descriptors and try to load object description foreach ($this->getDescriptors() as $descriptor) { try { // cut off the META-INF directory and replace OS specific directory separators $relativePathToPhpFile = str_replace(DIRECTORY_SEPARATOR, '\\', str_replace($directory, '', $phpFile)); // now cut off the .php extension $className = substr($relativePathToPhpFile, 0, -4); // we need a reflection class to read the annotations /** \AppserverIo\Lang\Reflection\ClassInterface $reflectionClass */ $reflectionClass = $objectManager->getReflectionClass($className); // load the descriptor class $descriptorClass = $descriptor->getNodeValue()->getValue(); // load the object descriptor and add it to the object manager /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ if (class_exists($descriptorClass)) { if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromReflectionClass($reflectionClass)) { $objectManager->addObjectDescriptor($objectDescriptor); } } // if class can not be reflected continue with next class } catch (\Exception $e) { // log an error message $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString()); // proceed with the next bean continue; } } } }
[ "protected", "function", "parseDirectory", "(", "$", "directory", ")", "{", "// check if we've found a valid directory", "if", "(", "is_dir", "(", "$", "directory", ")", "===", "false", ")", "{", "return", ";", "}", "// load the object manager instance", "/** @var \\A...
Parses the passed directory for classes and instances that has to be registered in the object manager. @param string $directory The directory to parse @return void
[ "Parses", "the", "passed", "directory", "for", "classes", "and", "instances", "that", "has", "to", "be", "registered", "in", "the", "object", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/DependencyInjectionContainer/DirectoryParser.php#L62-L115
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/ContainerService.php
ContainerService.createSslCertificate
public function createSslCertificate(\SplFileInfo $certificate) { // first we've to check if OpenSSL is available if (!$this->isOpenSslAvailable()) { return; } // do nothing if the file is already available if ($certificate->isFile()) { return; } // prepare the certificate data from our configuration $dn = array( "countryName" => "DE", "stateOrProvinceName" => "Bavaria", "localityName" => "Kolbermoor", "organizationName" => "appserver.io", "organizationalUnitName" => "Development", "commonName" => gethostname(), "emailAddress" => "info@appserver.io" ); // check the operating system switch ($this->getOsIdentifier()) { case 'DAR': // on Mac OS X use the system default configuration $configargs = array('config' => $this->getBaseDirectory('/ssl/openssl.cnf')); break; case 'WIN': // on Windows use the system configuration we deliver $configargs = array('config' => $this->getBaseDirectory('/php/extras/ssl/openssl.cnf')); break; default: // on all other use a standard configuration $configargs = array( 'digest_alg' => 'sha256', 'x509_extensions' => 'v3_ca', 'req_extensions' => 'v3_req', 'private_key_bits' => 2048, 'private_key_type' => OPENSSL_KEYTYPE_RSA, 'encrypt_key' => false ); } // generate a new private (and public) key pair $privkey = openssl_pkey_new($configargs); // Generate a certificate signing request $csr = openssl_csr_new($dn, $privkey, $configargs); // create a self-signed cert that is valid for 365 days $sscert = openssl_csr_sign($csr, null, $privkey, 365, $configargs); // export the cert + pk files $certout = ''; $pkeyout = ''; openssl_x509_export($sscert, $certout); openssl_pkey_export($privkey, $pkeyout, null, $configargs); // write the SSL certificate data to the target $file = $certificate->openFile('w'); if (($written = $file->fwrite($certout . $pkeyout)) === false) { throw new \Exception(sprintf('Can\'t create SSL certificate %s', $certificate->getPathname())); } // log a message that the file has been written successfully $this->getInitialContext()->getSystemLogger()->info( sprintf('Successfully created %s with %d bytes', $certificate->getPathname(), $written) ); // log any errors that occurred here while (($e = openssl_error_string()) !== false) { $this->getInitialContext()->getSystemLogger()->debug($e); } }
php
public function createSslCertificate(\SplFileInfo $certificate) { // first we've to check if OpenSSL is available if (!$this->isOpenSslAvailable()) { return; } // do nothing if the file is already available if ($certificate->isFile()) { return; } // prepare the certificate data from our configuration $dn = array( "countryName" => "DE", "stateOrProvinceName" => "Bavaria", "localityName" => "Kolbermoor", "organizationName" => "appserver.io", "organizationalUnitName" => "Development", "commonName" => gethostname(), "emailAddress" => "info@appserver.io" ); // check the operating system switch ($this->getOsIdentifier()) { case 'DAR': // on Mac OS X use the system default configuration $configargs = array('config' => $this->getBaseDirectory('/ssl/openssl.cnf')); break; case 'WIN': // on Windows use the system configuration we deliver $configargs = array('config' => $this->getBaseDirectory('/php/extras/ssl/openssl.cnf')); break; default: // on all other use a standard configuration $configargs = array( 'digest_alg' => 'sha256', 'x509_extensions' => 'v3_ca', 'req_extensions' => 'v3_req', 'private_key_bits' => 2048, 'private_key_type' => OPENSSL_KEYTYPE_RSA, 'encrypt_key' => false ); } // generate a new private (and public) key pair $privkey = openssl_pkey_new($configargs); // Generate a certificate signing request $csr = openssl_csr_new($dn, $privkey, $configargs); // create a self-signed cert that is valid for 365 days $sscert = openssl_csr_sign($csr, null, $privkey, 365, $configargs); // export the cert + pk files $certout = ''; $pkeyout = ''; openssl_x509_export($sscert, $certout); openssl_pkey_export($privkey, $pkeyout, null, $configargs); // write the SSL certificate data to the target $file = $certificate->openFile('w'); if (($written = $file->fwrite($certout . $pkeyout)) === false) { throw new \Exception(sprintf('Can\'t create SSL certificate %s', $certificate->getPathname())); } // log a message that the file has been written successfully $this->getInitialContext()->getSystemLogger()->info( sprintf('Successfully created %s with %d bytes', $certificate->getPathname(), $written) ); // log any errors that occurred here while (($e = openssl_error_string()) !== false) { $this->getInitialContext()->getSystemLogger()->debug($e); } }
[ "public", "function", "createSslCertificate", "(", "\\", "SplFileInfo", "$", "certificate", ")", "{", "// first we've to check if OpenSSL is available", "if", "(", "!", "$", "this", "->", "isOpenSslAvailable", "(", ")", ")", "{", "return", ";", "}", "// do nothing i...
Creates the SSL file passed as parameter or nothing if the file already exists. @param \SplFileInfo $certificate The file info about the SSL file to generate @return void @throws \Exception
[ "Creates", "the", "SSL", "file", "passed", "as", "parameter", "or", "nothing", "if", "the", "file", "already", "exists", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/ContainerService.php#L66-L145
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/ContainerService.php
ContainerService.load
public function load($uuid) { $containers = $this->findAll(); if (array_key_exists($uuid, $containers)) { return $containers[$uuid]; } }
php
public function load($uuid) { $containers = $this->findAll(); if (array_key_exists($uuid, $containers)) { return $containers[$uuid]; } }
[ "public", "function", "load", "(", "$", "uuid", ")", "{", "$", "containers", "=", "$", "this", "->", "findAll", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "uuid", ",", "$", "containers", ")", ")", "{", "return", "$", "containers", "[", ...
Returns the container for the passed UUID. @param string $uuid Unique UUID of the container to return @return \AppserverIo\Appserver\Core\Api\Node\ContainerNode The container with the UUID passed as parameter @see \AppserverIo\Psr\ApplicationServer\ServiceInterface::load($uuid)
[ "Returns", "the", "container", "for", "the", "passed", "UUID", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/ContainerService.php#L191-L197
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/ContainerService.php
ContainerService.prepareFileSystem
public function prepareFileSystem() { // load the directories $directories = $this->getDirectories(); // load user and group from system configuration $user = $this->getSystemConfiguration()->getUser(); $group = $this->getSystemConfiguration()->getGroup(); // check if the necessary directories already exists, if not, create them foreach (DirectoryKeys::getServerDirectoryKeysToBeCreated() as $directoryKey) { // prepare the path to the directory to be created $toBeCreated = $this->realpath($directories[$directoryKey]); // prepare the directory name and check if the directory already exists if (is_dir($toBeCreated) === false) { // if not, try to create it if (mkdir($toBeCreated, 0755, true) === false) { throw new \Exception( sprintf('Can\'t create necessary directory %s while starting application server', $toBeCreated) ); } // set user/group specified from the system configuration if ($this->setUserRights(new \SplFileInfo($toBeCreated), $user, $group) === false) { throw new \Exception( sprintf('Can\'t switch user/group to %s/% for directory %s while starting application server', $user, $group, $toBeCreated) ); } } } // create the container specific directories /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) { // iterate over the container host's directories foreach ($containerNode->getHost()->getDirectories() as $directory) { // prepare the path to the directory to be created $toBeCreated = $this->realpath($directory); // prepare the directory name and check if the directory already exists if (is_dir($toBeCreated) === false) { // if not, try to create it if (mkdir($toBeCreated, 0755, true) === false) { throw new \Exception( sprintf('Can\'t create necessary directory %s while starting application server', $toBeCreated) ); } // set user/group specified from the system configuration if ($this->setUserRights(new \SplFileInfo($toBeCreated), $user, $group) === false) { throw new \Exception( sprintf('Can\'t switch user/group to %s/% for directory %s while starting application server', $user, $group, $toBeCreated) ); } } } } // check if specific directories has to be cleaned up on startup foreach (DirectoryKeys::getServerDirectoryKeysToBeCleanedUp() as $directoryKey) { // prepare the path to the directory to be cleaned up $toBeCleanedUp = $this->realpath($directories[$directoryKey]); // if the directory exists, clean it up if (is_dir($toBeCleanedUp)) { $this->cleanUpDir(new \SplFileInfo($toBeCleanedUp)); } } // check if needed files do exist and have the correct user rights $files = $this->getFiles(); foreach (FileKeys::getServerFileKeysToBeCreated() as $fileKeys) { // prepare the path to the file to be created $toBeCreated = $this->realpath($files[$fileKeys]); // touch the file (will lead to its creation if it does not exist by now) if (touch($toBeCreated) === false) { throw new \Exception( sprintf('Can\'t create necessary file %s while starting application server', $toBeCreated) ); } else { chmod($toBeCreated, 0755); } // set user/group specified from the system configuration if ($this->setUserRight(new \SplFileInfo($toBeCreated), $user, $group) === false) { throw new \Exception( sprintf('Can\'t switch user/group to %s/% for file %s while starting application server', $user, $group, $toBeCreated) ); } } }
php
public function prepareFileSystem() { // load the directories $directories = $this->getDirectories(); // load user and group from system configuration $user = $this->getSystemConfiguration()->getUser(); $group = $this->getSystemConfiguration()->getGroup(); // check if the necessary directories already exists, if not, create them foreach (DirectoryKeys::getServerDirectoryKeysToBeCreated() as $directoryKey) { // prepare the path to the directory to be created $toBeCreated = $this->realpath($directories[$directoryKey]); // prepare the directory name and check if the directory already exists if (is_dir($toBeCreated) === false) { // if not, try to create it if (mkdir($toBeCreated, 0755, true) === false) { throw new \Exception( sprintf('Can\'t create necessary directory %s while starting application server', $toBeCreated) ); } // set user/group specified from the system configuration if ($this->setUserRights(new \SplFileInfo($toBeCreated), $user, $group) === false) { throw new \Exception( sprintf('Can\'t switch user/group to %s/% for directory %s while starting application server', $user, $group, $toBeCreated) ); } } } // create the container specific directories /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) { // iterate over the container host's directories foreach ($containerNode->getHost()->getDirectories() as $directory) { // prepare the path to the directory to be created $toBeCreated = $this->realpath($directory); // prepare the directory name and check if the directory already exists if (is_dir($toBeCreated) === false) { // if not, try to create it if (mkdir($toBeCreated, 0755, true) === false) { throw new \Exception( sprintf('Can\'t create necessary directory %s while starting application server', $toBeCreated) ); } // set user/group specified from the system configuration if ($this->setUserRights(new \SplFileInfo($toBeCreated), $user, $group) === false) { throw new \Exception( sprintf('Can\'t switch user/group to %s/% for directory %s while starting application server', $user, $group, $toBeCreated) ); } } } } // check if specific directories has to be cleaned up on startup foreach (DirectoryKeys::getServerDirectoryKeysToBeCleanedUp() as $directoryKey) { // prepare the path to the directory to be cleaned up $toBeCleanedUp = $this->realpath($directories[$directoryKey]); // if the directory exists, clean it up if (is_dir($toBeCleanedUp)) { $this->cleanUpDir(new \SplFileInfo($toBeCleanedUp)); } } // check if needed files do exist and have the correct user rights $files = $this->getFiles(); foreach (FileKeys::getServerFileKeysToBeCreated() as $fileKeys) { // prepare the path to the file to be created $toBeCreated = $this->realpath($files[$fileKeys]); // touch the file (will lead to its creation if it does not exist by now) if (touch($toBeCreated) === false) { throw new \Exception( sprintf('Can\'t create necessary file %s while starting application server', $toBeCreated) ); } else { chmod($toBeCreated, 0755); } // set user/group specified from the system configuration if ($this->setUserRight(new \SplFileInfo($toBeCreated), $user, $group) === false) { throw new \Exception( sprintf('Can\'t switch user/group to %s/% for file %s while starting application server', $user, $group, $toBeCreated) ); } } }
[ "public", "function", "prepareFileSystem", "(", ")", "{", "// load the directories", "$", "directories", "=", "$", "this", "->", "getDirectories", "(", ")", ";", "// load user and group from system configuration", "$", "user", "=", "$", "this", "->", "getSystemConfigu...
Prepares filesystem to be sure that everything is on place as expected @return void @throws \Exception Is thrown if a server directory can't be created
[ "Prepares", "filesystem", "to", "be", "sure", "that", "everything", "is", "on", "place", "as", "expected" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/ContainerService.php#L205-L298
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/ContainerService.php
ContainerService.switchSetupMode
public function switchSetupMode($newMode, $configurationFilename, $user) { // log a message that we switch setup mode now $this->getInitialContext()->getSystemLogger()->info(sprintf('Now switch mode to %s!!!', $newMode)); // init setup context Setup::prepareContext($this->getBaseDirectory()); // init variable for the group $group = null; // pattern to replace the user in the etc/appserver/appserver.xml/appserver-single-app.xml file $configurationUserReplacePattern = '/(<appserver[^>]+>[^<]+<params>.*<param name="user[^>]+>)([^<]+)/s'; // check setup modes switch ($newMode) { // prepares everything for developer mode case ContainerService::SETUP_MODE_DEV: // get defined group from configuration $group = Setup::getValue(SetupKeys::GROUP); // replace user in configuration file file_put_contents( $configurationFilename, preg_replace( $configurationUserReplacePattern, '${1}' . $user, file_get_contents($configurationFilename) ) ); // replace the user in the PHP-FPM configuration file file_put_contents( $this->getEtcDir('php-fpm.conf'), preg_replace( '/user = (.*)/', 'user = ' . $user, file_get_contents($this->getEtcDir('php-fpm.conf')) ) ); // add everyone write access to configuration files for dev mode FileSystem::recursiveChmod($this->getEtcDir(), 0777, 0777); break; // prepares everything for production mode case ContainerService::SETUP_MODE_PROD: // get defined user and group from configuration $user = Setup::getValue(SetupKeys::USER); $group = Setup::getValue(SetupKeys::GROUP); // replace user to be same as user in configuration file file_put_contents( $configurationFilename, preg_replace( $configurationUserReplacePattern, '${1}' . $user, file_get_contents($configurationFilename) ) ); // replace the user in the PHP-FPM configuration file file_put_contents( $this->getEtcDir('php-fpm.conf'), preg_replace( '/user = (.*)/', 'user = ' . $user, file_get_contents($this->getEtcDir('php-fpm.conf')) ) ); // set correct file permissions for configurations FileSystem::recursiveChmod($this->getEtcDir()); break; // prepares everything for first installation which is default mode case ContainerService::SETUP_MODE_INSTALL: // load the flag marked the server as installed $isInstalledFlag = $this->getIsInstalledFlag(); // first check if it is a fresh installation if ($isInstalledFlag->isReadable() === false) { // first iterate over all containers deploy directories and look for application archives /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) { // iterate over all found application archives and create the .dodeploy flag file foreach (glob($this->getDeployDir($containerNode, '/*.phar')) as $archive) { touch(sprintf('%s.dodeploy', $archive)); } } } // create is installed flag for prevent further setup install mode calls touch($isInstalledFlag); // get defined user and group from configuration $user = Setup::getValue(SetupKeys::USER); $group = Setup::getValue(SetupKeys::GROUP); // set correct file permissions for configurations FileSystem::recursiveChmod($this->getEtcDir()); break; default: throw new \Exception(sprintf('Invalid setup mode %s given', $newMode)); } // check if user and group is set if (!is_null($user) && !is_null($group)) { // get needed files as accessable for all root files remove "." and ".." from the list $rootFiles = scandir($this->getBaseDirectory()); // iterate all files foreach ($rootFiles as $rootFile) { // we want just files on root dir if (is_file($rootFile) && !in_array($rootFile, array('.', '..'))) { FileSystem::chmod($rootFile, 0644); FileSystem::chown($rootFile, $user, $group); } } // ... and change own and mod of following directories FileSystem::chown($this->getBaseDirectory(), $user, $group); FileSystem::recursiveChown($this->getBaseDirectory('resources'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('resources')); FileSystem::recursiveChown($this->getBaseDirectory('src'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('src')); FileSystem::recursiveChown($this->getBaseDirectory('var'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('var')); FileSystem::recursiveChown($this->getBaseDirectory('tests'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('tests')); FileSystem::recursiveChown($this->getBaseDirectory('vendor'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('vendor')); // ... and the change own and mod for the system's temporary directory FileSystem::recursiveChown($this->getSystemTmpDir(), $user, $group); FileSystem::recursiveChmod($this->getSystemTmpDir()); // ... and change own and mod for the container specific directories /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) { FileSystem::recursiveChown($this->getWebappsDir($containerNode), $user, $group); FileSystem::recursiveChmod($this->getWebappsDir($containerNode)); FileSystem::recursiveChown($this->getTmpDir($containerNode), $user, $group); FileSystem::recursiveChmod($this->getTmpDir($containerNode)); FileSystem::recursiveChown($this->getDeployDir($containerNode), $user, $group); FileSystem::recursiveChmod($this->getDeployDir($containerNode)); } // make server.php executable FileSystem::chmod($this->getBaseDirectory('server.php'), 0755); // log a message that we successfully switched to the new setup mode $this->getInitialContext()->getSystemLogger()->info(sprintf("Setup for mode '%s' done successfully!", $newMode)); } else { throw new \Exception('No user or group given'); } }
php
public function switchSetupMode($newMode, $configurationFilename, $user) { // log a message that we switch setup mode now $this->getInitialContext()->getSystemLogger()->info(sprintf('Now switch mode to %s!!!', $newMode)); // init setup context Setup::prepareContext($this->getBaseDirectory()); // init variable for the group $group = null; // pattern to replace the user in the etc/appserver/appserver.xml/appserver-single-app.xml file $configurationUserReplacePattern = '/(<appserver[^>]+>[^<]+<params>.*<param name="user[^>]+>)([^<]+)/s'; // check setup modes switch ($newMode) { // prepares everything for developer mode case ContainerService::SETUP_MODE_DEV: // get defined group from configuration $group = Setup::getValue(SetupKeys::GROUP); // replace user in configuration file file_put_contents( $configurationFilename, preg_replace( $configurationUserReplacePattern, '${1}' . $user, file_get_contents($configurationFilename) ) ); // replace the user in the PHP-FPM configuration file file_put_contents( $this->getEtcDir('php-fpm.conf'), preg_replace( '/user = (.*)/', 'user = ' . $user, file_get_contents($this->getEtcDir('php-fpm.conf')) ) ); // add everyone write access to configuration files for dev mode FileSystem::recursiveChmod($this->getEtcDir(), 0777, 0777); break; // prepares everything for production mode case ContainerService::SETUP_MODE_PROD: // get defined user and group from configuration $user = Setup::getValue(SetupKeys::USER); $group = Setup::getValue(SetupKeys::GROUP); // replace user to be same as user in configuration file file_put_contents( $configurationFilename, preg_replace( $configurationUserReplacePattern, '${1}' . $user, file_get_contents($configurationFilename) ) ); // replace the user in the PHP-FPM configuration file file_put_contents( $this->getEtcDir('php-fpm.conf'), preg_replace( '/user = (.*)/', 'user = ' . $user, file_get_contents($this->getEtcDir('php-fpm.conf')) ) ); // set correct file permissions for configurations FileSystem::recursiveChmod($this->getEtcDir()); break; // prepares everything for first installation which is default mode case ContainerService::SETUP_MODE_INSTALL: // load the flag marked the server as installed $isInstalledFlag = $this->getIsInstalledFlag(); // first check if it is a fresh installation if ($isInstalledFlag->isReadable() === false) { // first iterate over all containers deploy directories and look for application archives /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) { // iterate over all found application archives and create the .dodeploy flag file foreach (glob($this->getDeployDir($containerNode, '/*.phar')) as $archive) { touch(sprintf('%s.dodeploy', $archive)); } } } // create is installed flag for prevent further setup install mode calls touch($isInstalledFlag); // get defined user and group from configuration $user = Setup::getValue(SetupKeys::USER); $group = Setup::getValue(SetupKeys::GROUP); // set correct file permissions for configurations FileSystem::recursiveChmod($this->getEtcDir()); break; default: throw new \Exception(sprintf('Invalid setup mode %s given', $newMode)); } // check if user and group is set if (!is_null($user) && !is_null($group)) { // get needed files as accessable for all root files remove "." and ".." from the list $rootFiles = scandir($this->getBaseDirectory()); // iterate all files foreach ($rootFiles as $rootFile) { // we want just files on root dir if (is_file($rootFile) && !in_array($rootFile, array('.', '..'))) { FileSystem::chmod($rootFile, 0644); FileSystem::chown($rootFile, $user, $group); } } // ... and change own and mod of following directories FileSystem::chown($this->getBaseDirectory(), $user, $group); FileSystem::recursiveChown($this->getBaseDirectory('resources'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('resources')); FileSystem::recursiveChown($this->getBaseDirectory('src'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('src')); FileSystem::recursiveChown($this->getBaseDirectory('var'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('var')); FileSystem::recursiveChown($this->getBaseDirectory('tests'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('tests')); FileSystem::recursiveChown($this->getBaseDirectory('vendor'), $user, $group); FileSystem::recursiveChmod($this->getBaseDirectory('vendor')); // ... and the change own and mod for the system's temporary directory FileSystem::recursiveChown($this->getSystemTmpDir(), $user, $group); FileSystem::recursiveChmod($this->getSystemTmpDir()); // ... and change own and mod for the container specific directories /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) { FileSystem::recursiveChown($this->getWebappsDir($containerNode), $user, $group); FileSystem::recursiveChmod($this->getWebappsDir($containerNode)); FileSystem::recursiveChown($this->getTmpDir($containerNode), $user, $group); FileSystem::recursiveChmod($this->getTmpDir($containerNode)); FileSystem::recursiveChown($this->getDeployDir($containerNode), $user, $group); FileSystem::recursiveChmod($this->getDeployDir($containerNode)); } // make server.php executable FileSystem::chmod($this->getBaseDirectory('server.php'), 0755); // log a message that we successfully switched to the new setup mode $this->getInitialContext()->getSystemLogger()->info(sprintf("Setup for mode '%s' done successfully!", $newMode)); } else { throw new \Exception('No user or group given'); } }
[ "public", "function", "switchSetupMode", "(", "$", "newMode", ",", "$", "configurationFilename", ",", "$", "user", ")", "{", "// log a message that we switch setup mode now", "$", "this", "->", "getInitialContext", "(", ")", "->", "getSystemLogger", "(", ")", "->", ...
Switches the setup mode to the passed value. @param string $newMode The mode to switch to @param string $configurationFilename The path of the configuration filename @param string $user The name of the user who started the application server @return void @throws \Exception Is thrown for an invalid setup mode passed
[ "Switches", "the", "setup", "mode", "to", "the", "passed", "value", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/ContainerService.php#L320-L477
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoaderFactory.php
DgClassLoaderFactory.visit
public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration) { // initialize the class path and the enforcement directories $classPath = array(); $enforcementDirs = array(); // add the possible class path if folder is available foreach ($configuration->getDirectories() as $directory) { if (is_dir($directory->getNodeValue())) { array_push($classPath, $directory->getNodeValue()); if ($directory->isEnforced()) { array_push($enforcementDirs, $directory->getNodeValue()); } } } // initialize the arrays of different omit possibilities $omittedEnforcement = array(); $omittedAutoLoading = array(); // iterate over all namespaces and check if they are omitted in one or the other way foreach ($configuration->getNamespaces() as $namespace) { // is the enforcement omitted for this namespace? if ($namespace->omitEnforcement()) { $omittedEnforcement[] = $namespace->getNodeValue()->__toString(); } // is the autoloading omitted for this namespace? if ($namespace->omitAutoLoading()) { $omittedAutoLoading[] = $namespace->getNodeValue()->__toString(); } } // initialize the class loader configuration $config = new Config(); // set the environment mode we want to use $config->setValue('environment', $configuration->getEnvironment()); // set the cache directory $config->setValue('cache/dir', $application->getCacheDir()); // set the default autoloader values $config->setValue('autoloader/dirs', $classPath); // collect the omitted namespaces (if any) $config->setValue('autoloader/omit', $omittedAutoLoading); $config->setValue('enforcement/omit', $omittedEnforcement); // set the default enforcement configuration values $config->setValue('enforcement/dirs', $enforcementDirs); $config->setValue('enforcement/enforce-default-type-safety', $configuration->getTypeSafety()); $config->setValue('enforcement/processing', $configuration->getProcessing()); $config->setValue('enforcement/level', $configuration->getEnforcementLevel()); try { // try to load the application system logger $config->setValue('enforcement/logger', $application->search(LoggerUtils::SYSTEM_LOGGER)); } catch (NamingException $ne) { // load the general system logger, if the application has no logger registered $config->setValue('enforcement/logger', $application->search(LoggerUtils::SYSTEM)); } // create a autoloader instance and initialize it $classLoader = new DgClassLoader($config); $classLoader->init( new StackableStructureMap( $config->getValue('autoloader/dirs'), $config->getValue('enforcement/dirs'), $config ), new AspectRegister() ); // add the autoloader to the manager $application->addClassLoader($classLoader, $configuration); }
php
public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration) { // initialize the class path and the enforcement directories $classPath = array(); $enforcementDirs = array(); // add the possible class path if folder is available foreach ($configuration->getDirectories() as $directory) { if (is_dir($directory->getNodeValue())) { array_push($classPath, $directory->getNodeValue()); if ($directory->isEnforced()) { array_push($enforcementDirs, $directory->getNodeValue()); } } } // initialize the arrays of different omit possibilities $omittedEnforcement = array(); $omittedAutoLoading = array(); // iterate over all namespaces and check if they are omitted in one or the other way foreach ($configuration->getNamespaces() as $namespace) { // is the enforcement omitted for this namespace? if ($namespace->omitEnforcement()) { $omittedEnforcement[] = $namespace->getNodeValue()->__toString(); } // is the autoloading omitted for this namespace? if ($namespace->omitAutoLoading()) { $omittedAutoLoading[] = $namespace->getNodeValue()->__toString(); } } // initialize the class loader configuration $config = new Config(); // set the environment mode we want to use $config->setValue('environment', $configuration->getEnvironment()); // set the cache directory $config->setValue('cache/dir', $application->getCacheDir()); // set the default autoloader values $config->setValue('autoloader/dirs', $classPath); // collect the omitted namespaces (if any) $config->setValue('autoloader/omit', $omittedAutoLoading); $config->setValue('enforcement/omit', $omittedEnforcement); // set the default enforcement configuration values $config->setValue('enforcement/dirs', $enforcementDirs); $config->setValue('enforcement/enforce-default-type-safety', $configuration->getTypeSafety()); $config->setValue('enforcement/processing', $configuration->getProcessing()); $config->setValue('enforcement/level', $configuration->getEnforcementLevel()); try { // try to load the application system logger $config->setValue('enforcement/logger', $application->search(LoggerUtils::SYSTEM_LOGGER)); } catch (NamingException $ne) { // load the general system logger, if the application has no logger registered $config->setValue('enforcement/logger', $application->search(LoggerUtils::SYSTEM)); } // create a autoloader instance and initialize it $classLoader = new DgClassLoader($config); $classLoader->init( new StackableStructureMap( $config->getValue('autoloader/dirs'), $config->getValue('enforcement/dirs'), $config ), new AspectRegister() ); // add the autoloader to the manager $application->addClassLoader($classLoader, $configuration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ClassLoaderNodeInterface", "$", "configuration", ")", "{", "// initialize the class path and the enforcement directories", "$", "classPath", "=", "array", "(", ")", ";", "$", ...
Visitor method that registers the class loaders in the application. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with @param \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration The class loader configuration @return void
[ "Visitor", "method", "that", "registers", "the", "class", "loaders", "in", "the", "application", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoaderFactory.php#L51-L128
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardGarbageCollector.php
StandardGarbageCollector.bootstrap
public function bootstrap() { // setup autoloader require SERVER_AUTOLOADER; // register the application's class loaders $application = $this->getApplication(); $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // try to load the system logger $this->systemLogger = $this->getLogger(LoggerUtils::SYSTEM); // try to load the profile logger if ($this->profileLogger = $this->getLogger(LoggerUtils::PROFILE)) { $this->profileLogger->appendThreadContext('servlet-engine-garbage-collector'); } }
php
public function bootstrap() { // setup autoloader require SERVER_AUTOLOADER; // register the application's class loaders $application = $this->getApplication(); $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // try to load the system logger $this->systemLogger = $this->getLogger(LoggerUtils::SYSTEM); // try to load the profile logger if ($this->profileLogger = $this->getLogger(LoggerUtils::PROFILE)) { $this->profileLogger->appendThreadContext('servlet-engine-garbage-collector'); } }
[ "public", "function", "bootstrap", "(", ")", "{", "// setup autoloader", "require", "SERVER_AUTOLOADER", ";", "// register the application's class loaders", "$", "application", "=", "$", "this", "->", "getApplication", "(", ")", ";", "$", "application", "->", "registe...
This method will be invoked before the while() loop starts and can be used to implement some bootstrap functionality. @return void
[ "This", "method", "will", "be", "invoked", "before", "the", "while", "()", "loop", "starts", "and", "can", "be", "used", "to", "implement", "some", "bootstrap", "functionality", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardGarbageCollector.php#L105-L125
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardGarbageCollector.php
StandardGarbageCollector.iterate
public function iterate($timeout) { // call parent method and sleep for the default timeout parent::iterate($timeout); // collect the session garbage $this->collectGarbage(); // profile the size of the sessions if ($profileLogger = $this->getProfileLogger()) { $profileLogger->info('Successfull collect garbage for the servlet engine\'s session manager'); } }
php
public function iterate($timeout) { // call parent method and sleep for the default timeout parent::iterate($timeout); // collect the session garbage $this->collectGarbage(); // profile the size of the sessions if ($profileLogger = $this->getProfileLogger()) { $profileLogger->info('Successfull collect garbage for the servlet engine\'s session manager'); } }
[ "public", "function", "iterate", "(", "$", "timeout", ")", "{", "// call parent method and sleep for the default timeout", "parent", "::", "iterate", "(", "$", "timeout", ")", ";", "// collect the session garbage", "$", "this", "->", "collectGarbage", "(", ")", ";", ...
This is invoked on every iteration of the daemons while() loop. @param integer $timeout The timeout before the daemon wakes up @return void
[ "This", "is", "invoked", "on", "every", "iteration", "of", "the", "daemons", "while", "()", "loop", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardGarbageCollector.php#L144-L157
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardGarbageCollector.php
StandardGarbageCollector.collectGarbage
public function collectGarbage() { // the probability that we want to collect the garbage (float <= 1.0) $garbageCollectionProbability = $this->getSessionSettings()->getGarbageCollectionProbability(); // calculate if the want to collect the garbage now $decimals = strlen(strrchr($garbageCollectionProbability, '.')) - 1; $factor = ($decimals > - 1) ? $decimals * 10 : 1; // if we can to collect the garbage, start collecting now if (rand(0, 100 * $factor) <= ($garbageCollectionProbability * $factor)) { // load the session manager instance /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $sessionManager */ $sessionManager = $this->getApplication()->search(SessionManagerInterface::IDENTIFIER); // load the system logger instance $systemLogger = $this->getSystemLogger(); // iterate over all session managers and remove the expired sessions foreach ($sessionManager->getSessionHandlers() as $sessionHandlerName => $sessionHandler) { try { if ($systemLogger && ($sessionRemovalCount = $sessionHandler->collectGarbage()) > 0) { $systemLogger->debug( sprintf( 'Successfully removed %d session(s) by session handler \'%s\'', $sessionRemovalCount, $sessionHandlerName ) ); } } catch (\Exception $e) { if ($systemLogger) { $systemLogger->error($e->__toString()); } } } } }
php
public function collectGarbage() { // the probability that we want to collect the garbage (float <= 1.0) $garbageCollectionProbability = $this->getSessionSettings()->getGarbageCollectionProbability(); // calculate if the want to collect the garbage now $decimals = strlen(strrchr($garbageCollectionProbability, '.')) - 1; $factor = ($decimals > - 1) ? $decimals * 10 : 1; // if we can to collect the garbage, start collecting now if (rand(0, 100 * $factor) <= ($garbageCollectionProbability * $factor)) { // load the session manager instance /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $sessionManager */ $sessionManager = $this->getApplication()->search(SessionManagerInterface::IDENTIFIER); // load the system logger instance $systemLogger = $this->getSystemLogger(); // iterate over all session managers and remove the expired sessions foreach ($sessionManager->getSessionHandlers() as $sessionHandlerName => $sessionHandler) { try { if ($systemLogger && ($sessionRemovalCount = $sessionHandler->collectGarbage()) > 0) { $systemLogger->debug( sprintf( 'Successfully removed %d session(s) by session handler \'%s\'', $sessionRemovalCount, $sessionHandlerName ) ); } } catch (\Exception $e) { if ($systemLogger) { $systemLogger->error($e->__toString()); } } } } }
[ "public", "function", "collectGarbage", "(", ")", "{", "// the probability that we want to collect the garbage (float <= 1.0)", "$", "garbageCollectionProbability", "=", "$", "this", "->", "getSessionSettings", "(", ")", "->", "getGarbageCollectionProbability", "(", ")", ";",...
Collects the session garbage. @return integer The number of expired and removed sessions
[ "Collects", "the", "session", "garbage", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardGarbageCollector.php#L164-L201
appserver-io/appserver
src/AppserverIo/Appserver/DependencyInjectionContainer/ObjectManagerFactory.php
ObjectManagerFactory.visit
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // create the storage for the data and the bean descriptors $data = new StackableStorage(); $objectDescriptors = new StackableStorage(); // create and initialize the object manager instance $objectManager = new ObjectManager(); $objectManager->injectData($data); $objectManager->injectApplication($application); $objectManager->injectObjectDescriptors($objectDescriptors); $objectManager->injectManagerConfiguration($managerConfiguration); // attach the instance $application->addManager($objectManager, $managerConfiguration); }
php
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // create the storage for the data and the bean descriptors $data = new StackableStorage(); $objectDescriptors = new StackableStorage(); // create and initialize the object manager instance $objectManager = new ObjectManager(); $objectManager->injectData($data); $objectManager->injectApplication($application); $objectManager->injectObjectDescriptors($objectDescriptors); $objectManager->injectManagerConfiguration($managerConfiguration); // attach the instance $application->addManager($objectManager, $managerConfiguration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ManagerNodeInterface", "$", "managerConfiguration", ")", "{", "// create the storage for the data and the bean descriptors", "$", "data", "=", "new", "StackableStorage", "(", ")"...
The main method that creates new instances in a separate context. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration The manager configuration @return void
[ "The", "main", "method", "that", "creates", "new", "instances", "in", "a", "separate", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/DependencyInjectionContainer/ObjectManagerFactory.php#L48-L64
appserver-io/appserver
src/AppserverIo/Appserver/Application/ApplicationFactory.php
ApplicationFactory.visit
public static function visit(ContainerInterface $container, ContextNode $context) { // load the applications base directory $webappPath = $context->getWebappPath(); // declare META-INF and WEB-INF directory $webInfDir = $webappPath . DIRECTORY_SEPARATOR . 'WEB-INF'; $metaInfDir = $webappPath . DIRECTORY_SEPARATOR . 'META-INF'; // check if we've a directory containing a valid application, // at least a WEB-INF or META-INF folder has to be available if (!is_dir($webInfDir) && !is_dir($metaInfDir)) { return; } // load the naming directory + initial context $initialContext = $container->getInitialContext(); $namingDirectory = $container->getNamingDirectory(); // load the application service $appService = $container->newService('AppserverIo\Appserver\Core\Api\AppService'); // load the application type $contextType = $context->getType(); $containerName = $container->getName(); $environmentName = $context->getEnvironmentName(); $applicationName = $context->getName(); $containerRunlevel = $container->getRunlevel(); // create a new application instance /** @var \AppserverIo\Appserver\Application\Application $application */ $application = new $contextType(); // initialize the storage for managers, virtual hosts an class loaders $loggers = new GenericStackable(); $managers = new GenericStackable(); $provisioners = new GenericStackable(); $classLoaders = new GenericStackable(); // initialize the generic instances and information $application->injectLoggers($loggers); $application->injectManagers($managers); $application->injectName($applicationName); $application->injectEnvironmentName($environmentName); $application->injectProvisioners($provisioners); $application->injectClassLoaders($classLoaders); $application->injectContainerName($containerName); $application->injectInitialContext($initialContext); $application->injectNamingDirectory($namingDirectory); $application->injectContainerRunlevel($containerRunlevel); // prepare the application instance $application->prepare($container, $context); // create the applications temporary folders and cleans the folders up /** @var \AppserverIo\Appserver\Core\Api\AppService $appService */ PermissionHelper::sudo(array($appService, 'createTmpFolders'), array($application)); $appService->cleanUpFolders($application); // add the configured loggers /** @var \AppserverIo\Appserver\Core\Api\Node\LoggerNode $loggerNode */ foreach ($context->getLoggers() as $loggerNode) { $application->addLogger(LoggerFactory::factory($loggerNode), $loggerNode); } // add the configured class loaders /** @var \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNode $classLoader */ foreach ($context->getClassLoaders() as $classLoader) { /** @var \AppserverIo\Appserver\Core\Interfaces\ClassLoaderFactoryInterface $classLoaderFactory */ if ($classLoaderFactory = $classLoader->getFactory()) { // use the factory if available $classLoaderFactory::visit($application, $classLoader); } else { // if not, try to instanciate the class loader directly $classLoaderType = $classLoader->getType(); $application->addClassLoader(new $classLoaderType($classLoader), $classLoader); } } // add the configured managers /** @var \AppserverIo\Appserver\Core\Api\Node\ManagerNode $manager */ foreach ($context->getManagers() as $manager) { /** @var \AppserverIo\Appserver\Core\Interfaces\ManagerFactoryInterface $managerFactory */ if ($managerFactory = $manager->getFactory()) { // use the factory if available $managerFactory::visit($application, $manager); } else { // if not, try to instanciate the manager directly $managerType = $manager->getType(); $application->addManager(new $managerType($manager), $manager); } } // add the configured provisioners /** @var \AppserverIo\Appserver\Core\Api\Node\ProvisionerNode $provisioner */ foreach ($context->getProvisioners() as $provisioner) { /** @var \AppserverIo\Appserver\Provisioning\StandardProvisionerFactory $provisionerFactory */ if ($provisionerFactory = $provisioner->getFactory()) { // use the factory if available $provisionerFactory::visit($application, $provisioner); } else { // if not, try to instanciate the provisioner directly $provisionerType = $provisioner->getType(); $application->addProvisioner(new $provisionerType($provisioner), $provisioner); } } // add the application to the container $container->addApplication($application); }
php
public static function visit(ContainerInterface $container, ContextNode $context) { // load the applications base directory $webappPath = $context->getWebappPath(); // declare META-INF and WEB-INF directory $webInfDir = $webappPath . DIRECTORY_SEPARATOR . 'WEB-INF'; $metaInfDir = $webappPath . DIRECTORY_SEPARATOR . 'META-INF'; // check if we've a directory containing a valid application, // at least a WEB-INF or META-INF folder has to be available if (!is_dir($webInfDir) && !is_dir($metaInfDir)) { return; } // load the naming directory + initial context $initialContext = $container->getInitialContext(); $namingDirectory = $container->getNamingDirectory(); // load the application service $appService = $container->newService('AppserverIo\Appserver\Core\Api\AppService'); // load the application type $contextType = $context->getType(); $containerName = $container->getName(); $environmentName = $context->getEnvironmentName(); $applicationName = $context->getName(); $containerRunlevel = $container->getRunlevel(); // create a new application instance /** @var \AppserverIo\Appserver\Application\Application $application */ $application = new $contextType(); // initialize the storage for managers, virtual hosts an class loaders $loggers = new GenericStackable(); $managers = new GenericStackable(); $provisioners = new GenericStackable(); $classLoaders = new GenericStackable(); // initialize the generic instances and information $application->injectLoggers($loggers); $application->injectManagers($managers); $application->injectName($applicationName); $application->injectEnvironmentName($environmentName); $application->injectProvisioners($provisioners); $application->injectClassLoaders($classLoaders); $application->injectContainerName($containerName); $application->injectInitialContext($initialContext); $application->injectNamingDirectory($namingDirectory); $application->injectContainerRunlevel($containerRunlevel); // prepare the application instance $application->prepare($container, $context); // create the applications temporary folders and cleans the folders up /** @var \AppserverIo\Appserver\Core\Api\AppService $appService */ PermissionHelper::sudo(array($appService, 'createTmpFolders'), array($application)); $appService->cleanUpFolders($application); // add the configured loggers /** @var \AppserverIo\Appserver\Core\Api\Node\LoggerNode $loggerNode */ foreach ($context->getLoggers() as $loggerNode) { $application->addLogger(LoggerFactory::factory($loggerNode), $loggerNode); } // add the configured class loaders /** @var \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNode $classLoader */ foreach ($context->getClassLoaders() as $classLoader) { /** @var \AppserverIo\Appserver\Core\Interfaces\ClassLoaderFactoryInterface $classLoaderFactory */ if ($classLoaderFactory = $classLoader->getFactory()) { // use the factory if available $classLoaderFactory::visit($application, $classLoader); } else { // if not, try to instanciate the class loader directly $classLoaderType = $classLoader->getType(); $application->addClassLoader(new $classLoaderType($classLoader), $classLoader); } } // add the configured managers /** @var \AppserverIo\Appserver\Core\Api\Node\ManagerNode $manager */ foreach ($context->getManagers() as $manager) { /** @var \AppserverIo\Appserver\Core\Interfaces\ManagerFactoryInterface $managerFactory */ if ($managerFactory = $manager->getFactory()) { // use the factory if available $managerFactory::visit($application, $manager); } else { // if not, try to instanciate the manager directly $managerType = $manager->getType(); $application->addManager(new $managerType($manager), $manager); } } // add the configured provisioners /** @var \AppserverIo\Appserver\Core\Api\Node\ProvisionerNode $provisioner */ foreach ($context->getProvisioners() as $provisioner) { /** @var \AppserverIo\Appserver\Provisioning\StandardProvisionerFactory $provisionerFactory */ if ($provisionerFactory = $provisioner->getFactory()) { // use the factory if available $provisionerFactory::visit($application, $provisioner); } else { // if not, try to instanciate the provisioner directly $provisionerType = $provisioner->getType(); $application->addProvisioner(new $provisionerType($provisioner), $provisioner); } } // add the application to the container $container->addApplication($application); }
[ "public", "static", "function", "visit", "(", "ContainerInterface", "$", "container", ",", "ContextNode", "$", "context", ")", "{", "// load the applications base directory", "$", "webappPath", "=", "$", "context", "->", "getWebappPath", "(", ")", ";", "// declare M...
Visitor method that registers the application in the container. @param \AppserverIo\Psr\ApplicationServer\ContainerInterface $container The container instance bind the application to @param \AppserverIo\Appserver\Core\Api\Node\ContextNode $context The application configuration @return void
[ "Visitor", "method", "that", "registers", "the", "application", "in", "the", "container", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/ApplicationFactory.php#L49-L159
appserver-io/appserver
src/AppserverIo/Appserver/Core/SplClassLoaderFactory.php
SplClassLoaderFactory.visit
public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration) { // initialize the storage for the class map and the include path $classMap = new GenericStackable(); $includePath = array(); // load the application directory $webappPath = $application->getWebappPath(); // load the composer class loader for the configured directories foreach ($configuration->getDirectories() as $directory) { // we prepare the directories to include scripts AFTER registering (in application context) $includePath[] = $webappPath . $directory->getNodeValue(); } // initialize and return the SPL class loader instance $application->addClassLoader(new SplClassLoader($classMap, $includePath), $configuration); }
php
public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration) { // initialize the storage for the class map and the include path $classMap = new GenericStackable(); $includePath = array(); // load the application directory $webappPath = $application->getWebappPath(); // load the composer class loader for the configured directories foreach ($configuration->getDirectories() as $directory) { // we prepare the directories to include scripts AFTER registering (in application context) $includePath[] = $webappPath . $directory->getNodeValue(); } // initialize and return the SPL class loader instance $application->addClassLoader(new SplClassLoader($classMap, $includePath), $configuration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ClassLoaderNodeInterface", "$", "configuration", ")", "{", "// initialize the storage for the class map and the include path", "$", "classMap", "=", "new", "GenericStackable", "(",...
Visitor method that registers the class loaders in the application. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with @param \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration The class loader configuration @return void
[ "Visitor", "method", "that", "registers", "the", "class", "loaders", "in", "the", "application", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/SplClassLoaderFactory.php#L48-L66
appserver-io/appserver
src/AppserverIo/Appserver/Core/FileClassLoader.php
FileClassLoader.register
public function register($throw = true, $prepend = false) { // require all the files found in the directory foreach ($this->directories as $directory) { foreach (glob($directory) as $file) { require_once $file; } } }
php
public function register($throw = true, $prepend = false) { // require all the files found in the directory foreach ($this->directories as $directory) { foreach (glob($directory) as $file) { require_once $file; } } }
[ "public", "function", "register", "(", "$", "throw", "=", "true", ",", "$", "prepend", "=", "false", ")", "{", "// require all the files found in the directory", "foreach", "(", "$", "this", "->", "directories", "as", "$", "directory", ")", "{", "foreach", "("...
Installs this class loader on the SPL autoload stack. @param bool $throw If register should throw an exception or not @param bool $prepend If register should prepend @return void
[ "Installs", "this", "class", "loader", "on", "the", "SPL", "autoload", "stack", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/FileClassLoader.php#L69-L78
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php
ErrorUtil.fromArray
public function fromArray(array $error) { // extract the array with the error information list ($type, $message, $file, $line) = array_values($error); // initialize and return the error instance return new Error($type, $message, $file, $line); }
php
public function fromArray(array $error) { // extract the array with the error information list ($type, $message, $file, $line) = array_values($error); // initialize and return the error instance return new Error($type, $message, $file, $line); }
[ "public", "function", "fromArray", "(", "array", "$", "error", ")", "{", "// extract the array with the error information", "list", "(", "$", "type", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "=", "array_values", "(", "$", "error", ")", ...
Create's a new error instance with the values from the passed array. @param array $error The array containing the error information @return \AppserverIo\Appserver\Core\Utilities\ErrorInterface The error instance
[ "Create", "s", "a", "new", "error", "instance", "with", "the", "values", "from", "the", "passed", "array", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php#L71-L79
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php
ErrorUtil.fromException
public function fromException(\Exception $e) { return new Error(E_EXCEPTION, $e->__toString(), $e->getFile(), $e->getLine(), $e->getCode()); }
php
public function fromException(\Exception $e) { return new Error(E_EXCEPTION, $e->__toString(), $e->getFile(), $e->getLine(), $e->getCode()); }
[ "public", "function", "fromException", "(", "\\", "Exception", "$", "e", ")", "{", "return", "new", "Error", "(", "E_EXCEPTION", ",", "$", "e", "->", "__toString", "(", ")", ",", "$", "e", "->", "getFile", "(", ")", ",", "$", "e", "->", "getLine", ...
Create's a new error instance from the passed exception. @param \Exception $e The exception to create the error instance from @return \AppserverIo\Appserver\Core\Utilities\ErrorInterface The error instance
[ "Create", "s", "a", "new", "error", "instance", "from", "the", "passed", "exception", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php#L88-L91
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php
ErrorUtil.prepareMessage
public function prepareMessage(ErrorInterface $error) { return sprintf('PHP %s: %s in %s on line %d', $this->mapErrorCode($error), $error->getMessage(), $error->getFile(), $error->getLine()); }
php
public function prepareMessage(ErrorInterface $error) { return sprintf('PHP %s: %s in %s on line %d', $this->mapErrorCode($error), $error->getMessage(), $error->getFile(), $error->getLine()); }
[ "public", "function", "prepareMessage", "(", "ErrorInterface", "$", "error", ")", "{", "return", "sprintf", "(", "'PHP %s: %s in %s on line %d'", ",", "$", "this", "->", "mapErrorCode", "(", "$", "error", ")", ",", "$", "error", "->", "getMessage", "(", ")", ...
Prepare's the error message for logging/rendering purposes. @param \AppserverIo\Appserver\Core\Utilities\ErrorInterface $error The error instance to create the message from @return string The error message
[ "Prepare", "s", "the", "error", "message", "for", "logging", "/", "rendering", "purposes", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php#L100-L103
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php
ErrorUtil.mapLogLevel
public function mapLogLevel(ErrorInterface $error) { // initialize the log level, default is 'error' $logLevel = LogLevel::ERROR; // query the error type switch ($error->getType()) { case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_RECOVERABLE_ERROR: $logLevel = LogLevel::WARNING; break; case E_NOTICE: case E_USER_NOTICE: case E_STRICT: case E_DEPRECATED: case E_USER_DEPRECATED: $logLevel = LogLevel::NOTICE; break; default: break; } // return the log level return $logLevel; }
php
public function mapLogLevel(ErrorInterface $error) { // initialize the log level, default is 'error' $logLevel = LogLevel::ERROR; // query the error type switch ($error->getType()) { case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_RECOVERABLE_ERROR: $logLevel = LogLevel::WARNING; break; case E_NOTICE: case E_USER_NOTICE: case E_STRICT: case E_DEPRECATED: case E_USER_DEPRECATED: $logLevel = LogLevel::NOTICE; break; default: break; } // return the log level return $logLevel; }
[ "public", "function", "mapLogLevel", "(", "ErrorInterface", "$", "error", ")", "{", "// initialize the log level, default is 'error'", "$", "logLevel", "=", "LogLevel", "::", "ERROR", ";", "// query the error type", "switch", "(", "$", "error", "->", "getType", "(", ...
Return's the log level for the passed error instance. @param \AppserverIo\Appserver\Core\Utilities\ErrorInterface $error The error instance to map the log level for @return string
[ "Return", "s", "the", "log", "level", "for", "the", "passed", "error", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php#L112-L141
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php
ErrorUtil.mapErrorCode
public function mapErrorCode(ErrorInterface $error) { // initialize the error representation $wrapped = 'Unknown'; // query the error type switch ($error->getType()) { case E_EXCEPTION: $wrapped = 'Exception'; break; case E_PARSE: case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: $wrapped = 'Fatal Error'; break; case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_RECOVERABLE_ERROR: $wrapped = 'Warning'; break; case E_NOTICE: case E_USER_NOTICE: $wrapped = 'Notice'; break; case E_STRICT: $wrapped = 'Strict'; break; case E_DEPRECATED: case E_USER_DEPRECATED: $wrapped = 'Deprecated'; break; default: break; } // return the human readable error representation return $wrapped; }
php
public function mapErrorCode(ErrorInterface $error) { // initialize the error representation $wrapped = 'Unknown'; // query the error type switch ($error->getType()) { case E_EXCEPTION: $wrapped = 'Exception'; break; case E_PARSE: case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: $wrapped = 'Fatal Error'; break; case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_RECOVERABLE_ERROR: $wrapped = 'Warning'; break; case E_NOTICE: case E_USER_NOTICE: $wrapped = 'Notice'; break; case E_STRICT: $wrapped = 'Strict'; break; case E_DEPRECATED: case E_USER_DEPRECATED: $wrapped = 'Deprecated'; break; default: break; } // return the human readable error representation return $wrapped; }
[ "public", "function", "mapErrorCode", "(", "ErrorInterface", "$", "error", ")", "{", "// initialize the error representation", "$", "wrapped", "=", "'Unknown'", ";", "// query the error type", "switch", "(", "$", "error", "->", "getType", "(", ")", ")", "{", "case...
Return's the a human readable error representation for the passed error instance. @param \AppserverIo\Appserver\Core\Utilities\ErrorInterface $error The error instance @return string The human readable error representation
[ "Return", "s", "the", "a", "human", "readable", "error", "representation", "for", "the", "passed", "error", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php#L150-L197
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php
ErrorUtil.isFatal
public function isFatal($type) { return in_array($type, array(E_EXCEPTION, E_PARSE, E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR)); }
php
public function isFatal($type) { return in_array($type, array(E_EXCEPTION, E_PARSE, E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR)); }
[ "public", "function", "isFatal", "(", "$", "type", ")", "{", "return", "in_array", "(", "$", "type", ",", "array", "(", "E_EXCEPTION", ",", "E_PARSE", ",", "E_ERROR", ",", "E_CORE_ERROR", ",", "E_COMPILE_ERROR", ",", "E_USER_ERROR", ")", ")", ";", "}" ]
Query whether or not the passed error type is fatal or not. @param integer $type The type to query for @return boolean TRUE if the passed type is a fatal error, else FALSE
[ "Query", "whether", "or", "not", "the", "passed", "error", "type", "is", "fatal", "or", "not", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/ErrorUtil.php#L206-L209
appserver-io/appserver
src/AppserverIo/Appserver/Core/Extractors/PharExtractorFactory.php
PharExtractorFactory.factory
public static function factory(ApplicationServerInterface $applicationServer, ExtractorNodeInterface $configuration) { // create a new reflection class instance $reflectionClass = new \ReflectionClass($configuration->getType()); // initialize the container configuration with the base directory and pass it to the thread $params = array($applicationServer->getInitialContext(), $configuration); // create and append the thread instance to the internal array return $reflectionClass->newInstanceArgs($params); }
php
public static function factory(ApplicationServerInterface $applicationServer, ExtractorNodeInterface $configuration) { // create a new reflection class instance $reflectionClass = new \ReflectionClass($configuration->getType()); // initialize the container configuration with the base directory and pass it to the thread $params = array($applicationServer->getInitialContext(), $configuration); // create and append the thread instance to the internal array return $reflectionClass->newInstanceArgs($params); }
[ "public", "static", "function", "factory", "(", "ApplicationServerInterface", "$", "applicationServer", ",", "ExtractorNodeInterface", "$", "configuration", ")", "{", "// create a new reflection class instance", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "...
Factory method to create a new PHAR extractor instance. @param \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer The application server instance @param \AppserverIo\Appserver\Core\Api\Node\ExtractorNodeInterface $configuration The extractor configuration @return void
[ "Factory", "method", "to", "create", "a", "new", "PHAR", "extractor", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Extractors/PharExtractorFactory.php#L45-L56
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Doctrine/V2/AnnotationRegistries/Psr4AnnotationRegistry.php
Psr4AnnotationRegistry.register
public function register(AnnotationRegistryConfigurationInterface $annotationRegistry) { // initialize the composer class loader $classLoader = new ClassLoader(); $classLoader->addPsr4( $annotationRegistry->getNamespace(), $annotationRegistry->getDirectoriesAsArray() ); // register the class loader to load annotations AnnotationRegistry::registerLoader(array($classLoader, 'loadClass')); }
php
public function register(AnnotationRegistryConfigurationInterface $annotationRegistry) { // initialize the composer class loader $classLoader = new ClassLoader(); $classLoader->addPsr4( $annotationRegistry->getNamespace(), $annotationRegistry->getDirectoriesAsArray() ); // register the class loader to load annotations AnnotationRegistry::registerLoader(array($classLoader, 'loadClass')); }
[ "public", "function", "register", "(", "AnnotationRegistryConfigurationInterface", "$", "annotationRegistry", ")", "{", "// initialize the composer class loader", "$", "classLoader", "=", "new", "ClassLoader", "(", ")", ";", "$", "classLoader", "->", "addPsr4", "(", "$"...
Register's the annotation driver for the passed configuration. @param \AppserverIo\Description\Configuration\AnnotationRegistryConfigurationInterface $annotationRegistry The configuration node @return void
[ "Register", "s", "the", "annotation", "driver", "for", "the", "passed", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Doctrine/V2/AnnotationRegistries/Psr4AnnotationRegistry.php#L47-L59
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/DependencyInjection/DeploymentDescriptorParser.php
DeploymentDescriptorParser.parse
public function parse() { // load the deployment descriptors that has to be parsed $deploymentDescriptors = $this->loadDeploymentDescriptors(); // parse the deployment descriptors from the conf.d and the application's META-INF directory foreach ($deploymentDescriptors as $deploymentDescriptor) { // query whether we found epb.xml deployment descriptor file if (file_exists($deploymentDescriptor) === false) { continue; } // validate the passed configuration file /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); $configurationService->validateFile($deploymentDescriptor, null, true); // prepare and initialize the configuration node $epbNode = new EpbNode(); $epbNode->initFromFile($deploymentDescriptor); // query whether or not the deployment descriptor contains any beans /** @var \AppserverIo\Appserver\Core\Api\Node\EnterpriseBeansNode $enterpriseBeans */ if ($enterpriseBeans = $epbNode->getEnterpriseBeans()) { // parse the session beans of the deployment descriptor /** @var \AppserverIo\Appserver\Core\Api\Node\SessionNode $sessionNode */ foreach ($enterpriseBeans->getSessions() as $sessionNode) { $this->processConfigurationNode($sessionNode); } // parse the message driven beans from the deployment descriptor /** @var \AppserverIo\Appserver\Core\Api\Node\MessageDrivenNode $messageDrivenNode */ foreach ($enterpriseBeans->getMessageDrivens() as $messageDrivenNode) { $this->processConfigurationNode($messageDrivenNode); } } } }
php
public function parse() { // load the deployment descriptors that has to be parsed $deploymentDescriptors = $this->loadDeploymentDescriptors(); // parse the deployment descriptors from the conf.d and the application's META-INF directory foreach ($deploymentDescriptors as $deploymentDescriptor) { // query whether we found epb.xml deployment descriptor file if (file_exists($deploymentDescriptor) === false) { continue; } // validate the passed configuration file /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); $configurationService->validateFile($deploymentDescriptor, null, true); // prepare and initialize the configuration node $epbNode = new EpbNode(); $epbNode->initFromFile($deploymentDescriptor); // query whether or not the deployment descriptor contains any beans /** @var \AppserverIo\Appserver\Core\Api\Node\EnterpriseBeansNode $enterpriseBeans */ if ($enterpriseBeans = $epbNode->getEnterpriseBeans()) { // parse the session beans of the deployment descriptor /** @var \AppserverIo\Appserver\Core\Api\Node\SessionNode $sessionNode */ foreach ($enterpriseBeans->getSessions() as $sessionNode) { $this->processConfigurationNode($sessionNode); } // parse the message driven beans from the deployment descriptor /** @var \AppserverIo\Appserver\Core\Api\Node\MessageDrivenNode $messageDrivenNode */ foreach ($enterpriseBeans->getMessageDrivens() as $messageDrivenNode) { $this->processConfigurationNode($messageDrivenNode); } } } }
[ "public", "function", "parse", "(", ")", "{", "// load the deployment descriptors that has to be parsed", "$", "deploymentDescriptors", "=", "$", "this", "->", "loadDeploymentDescriptors", "(", ")", ";", "// parse the deployment descriptors from the conf.d and the application's MET...
Parses the bean context's deployment descriptor file for beans that has to be registered in the object manager. @return void
[ "Parses", "the", "bean", "context", "s", "deployment", "descriptor", "file", "for", "beans", "that", "has", "to", "be", "registered", "in", "the", "object", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/DependencyInjection/DeploymentDescriptorParser.php#L46-L83
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/DependencyInjection/DeploymentDescriptorParser.php
DeploymentDescriptorParser.processConfigurationNode
protected function processConfigurationNode(NodeInterface $node) { // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // iterate over all configured descriptors and try to load object description /** \AppserverIo\Appserver\Core\Api\Node\DescriptorNode $descriptor */ foreach ($this->getDescriptors() as $descriptor) { try { // load the descriptor class $descriptorClass = $descriptor->getNodeValue()->getValue(); // load the object descriptor, initialize the servlet mappings and add it to the object manager /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromConfiguration($node)) { $objectManager->addObjectDescriptor($objectDescriptor, true); } // proceed with the next descriptor continue; // if class can not be reflected continue with next class } catch (\Exception $e) { // log an error message $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString()); // proceed with the next descriptor continue; } } }
php
protected function processConfigurationNode(NodeInterface $node) { // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // iterate over all configured descriptors and try to load object description /** \AppserverIo\Appserver\Core\Api\Node\DescriptorNode $descriptor */ foreach ($this->getDescriptors() as $descriptor) { try { // load the descriptor class $descriptorClass = $descriptor->getNodeValue()->getValue(); // load the object descriptor, initialize the servlet mappings and add it to the object manager /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromConfiguration($node)) { $objectManager->addObjectDescriptor($objectDescriptor, true); } // proceed with the next descriptor continue; // if class can not be reflected continue with next class } catch (\Exception $e) { // log an error message $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString()); // proceed with the next descriptor continue; } } }
[ "protected", "function", "processConfigurationNode", "(", "NodeInterface", "$", "node", ")", "{", "// load the object manager instance", "/** @var \\AppserverIo\\Psr\\Di\\ObjectManagerInterface $objectManager */", "$", "objectManager", "=", "$", "this", "->", "getApplication", "(...
Creates a new descriptor instance from the data of the passed configuration node and add's it to the object manager. @param \AppserverIo\Configuration\Interfaces\NodeInterface $node The node to process @return void
[ "Creates", "a", "new", "descriptor", "instance", "from", "the", "data", "of", "the", "passed", "configuration", "node", "and", "add", "s", "it", "to", "the", "object", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/DependencyInjection/DeploymentDescriptorParser.php#L93-L125
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerFactory.php
TimerFactory.createTimer
public function createTimer(TimerServiceInterface $timerService, \DateTime $initialExpiration, $intervalDuration = 0, \Serializable $info = null, $persistent = true) { // lock the method \Mutex::lock($this->mutex); // we're not dispatched $this->dispatched = false; // initialize the data $this->info = $info; $this->persistent = $persistent; $this->timerService = $timerService; $this->intervalDuration = $intervalDuration; $this->initialExpiration = $initialExpiration->format(ScheduleExpression::DATE_FORMAT); // notify the thread $this->notify(); // wait till we've dispatched the request while ($this->dispatched === false) { usleep(100); } // unlock the method \Mutex::unlock($this->mutex); // return the created timer return $this->timer; }
php
public function createTimer(TimerServiceInterface $timerService, \DateTime $initialExpiration, $intervalDuration = 0, \Serializable $info = null, $persistent = true) { // lock the method \Mutex::lock($this->mutex); // we're not dispatched $this->dispatched = false; // initialize the data $this->info = $info; $this->persistent = $persistent; $this->timerService = $timerService; $this->intervalDuration = $intervalDuration; $this->initialExpiration = $initialExpiration->format(ScheduleExpression::DATE_FORMAT); // notify the thread $this->notify(); // wait till we've dispatched the request while ($this->dispatched === false) { usleep(100); } // unlock the method \Mutex::unlock($this->mutex); // return the created timer return $this->timer; }
[ "public", "function", "createTimer", "(", "TimerServiceInterface", "$", "timerService", ",", "\\", "DateTime", "$", "initialExpiration", ",", "$", "intervalDuration", "=", "0", ",", "\\", "Serializable", "$", "info", "=", "null", ",", "$", "persistent", "=", "...
Create a new timer instance with the passed data. @param \AppserverIo\Psr\EnterpriseBeans\TimerServiceInterface $timerService The timer service to create the service for @param \DateTime $initialExpiration The date at which the first timeout should occur. If the date is in the past, then the timeout is triggered immediately when the timer moves to TimerState::ACTIVE @param integer $intervalDuration The interval (in milli seconds) between consecutive timeouts for the newly created timer. Cannot be a negative value. A value of 0 indicates a single timeout action @param \Serializable $info Serializable info that will be made available through the newly created timers Timer::getInfo() method @param boolean $persistent TRUE if the newly created timer has to be persistent @return \AppserverIo\Psr\EnterpriseBeans\TimerInterface Returns the newly created timer @throws \Exception
[ "Create", "a", "new", "timer", "instance", "with", "the", "passed", "data", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerFactory.php#L97-L126
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerFactory.php
TimerFactory.bootstrap
public function bootstrap() { // setup autoloader require SERVER_AUTOLOADER; // make the application available and register the class loaders $application = $this->getApplication(); $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // try to load the profile logger if (isset($this->loggers[LoggerUtils::PROFILE])) { $this->profileLogger = $this->loggers[LoggerUtils::PROFILE]; $this->profileLogger->appendThreadContext('timer-factory'); } }
php
public function bootstrap() { // setup autoloader require SERVER_AUTOLOADER; // make the application available and register the class loaders $application = $this->getApplication(); $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // try to load the profile logger if (isset($this->loggers[LoggerUtils::PROFILE])) { $this->profileLogger = $this->loggers[LoggerUtils::PROFILE]; $this->profileLogger->appendThreadContext('timer-factory'); } }
[ "public", "function", "bootstrap", "(", ")", "{", "// setup autoloader", "require", "SERVER_AUTOLOADER", ";", "// make the application available and register the class loaders", "$", "application", "=", "$", "this", "->", "getApplication", "(", ")", ";", "$", "application...
This method will be invoked before the while() loop starts and can be used to implement some bootstrap functionality. @return void
[ "This", "method", "will", "be", "invoked", "before", "the", "while", "()", "loop", "starts", "and", "can", "be", "used", "to", "implement", "some", "bootstrap", "functionality", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerFactory.php#L134-L152
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerFactory.php
TimerFactory.iterate
public function iterate($timeout) { // call parent method and sleep for the default timeout parent::iterate($timeout); // create the requested timer instance $this->synchronized(function ($self) { // create the timer, only if we're NOT dispatched if ($self->dispatched === false) { $self->timer = Timer::builder() ->setNewTimer(true) ->setId(Uuid::uuid4()->__toString()) ->setInitialDate($self->initialExpiration) ->setRepeatInterval($self->intervalDuration) ->setInfo($self->info) ->setPersistent($self->persistent) ->setTimerState(TimerState::CREATED) ->setTimedObjectId($self->timerService->getTimedObjectInvoker()->getTimedObjectId()) ->build($self->timerService); // we're dispatched now $self->dispatched = true; } }, $this); // profile the size of the sessions if ($this->profileLogger) { $this->profileLogger->debug( sprintf('Size of session pool is: %d', sizeof($this->sessionPool)) ); } }
php
public function iterate($timeout) { // call parent method and sleep for the default timeout parent::iterate($timeout); // create the requested timer instance $this->synchronized(function ($self) { // create the timer, only if we're NOT dispatched if ($self->dispatched === false) { $self->timer = Timer::builder() ->setNewTimer(true) ->setId(Uuid::uuid4()->__toString()) ->setInitialDate($self->initialExpiration) ->setRepeatInterval($self->intervalDuration) ->setInfo($self->info) ->setPersistent($self->persistent) ->setTimerState(TimerState::CREATED) ->setTimedObjectId($self->timerService->getTimedObjectInvoker()->getTimedObjectId()) ->build($self->timerService); // we're dispatched now $self->dispatched = true; } }, $this); // profile the size of the sessions if ($this->profileLogger) { $this->profileLogger->debug( sprintf('Size of session pool is: %d', sizeof($this->sessionPool)) ); } }
[ "public", "function", "iterate", "(", "$", "timeout", ")", "{", "// call parent method and sleep for the default timeout", "parent", "::", "iterate", "(", "$", "timeout", ")", ";", "// create the requested timer instance", "$", "this", "->", "synchronized", "(", "functi...
This is invoked on every iteration of the daemons while() loop. @param integer $timeout The timeout before the daemon wakes up @return void
[ "This", "is", "invoked", "on", "every", "iteration", "of", "the", "daemons", "while", "()", "loop", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerFactory.php#L161-L195
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/CronNode.php
CronNode.merge
public function merge(CronNode $cronNode) { $this->setJobs(array_merge($this->getJobs(), $cronNode->getJobs())); }
php
public function merge(CronNode $cronNode) { $this->setJobs(array_merge($this->getJobs(), $cronNode->getJobs())); }
[ "public", "function", "merge", "(", "CronNode", "$", "cronNode", ")", "{", "$", "this", "->", "setJobs", "(", "array_merge", "(", "$", "this", "->", "getJobs", "(", ")", ",", "$", "cronNode", "->", "getJobs", "(", ")", ")", ")", ";", "}" ]
This method merges the passed CRON node with this one @param \AppserverIo\Appserver\Core\Api\Node\CronNodeInterface $cronNode The node to merge @return void
[ "This", "method", "merges", "the", "passed", "CRON", "node", "with", "this", "one" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/CronNode.php#L53-L56
appserver-io/appserver
src/AppserverIo/Appserver/DependencyInjectionContainer/ObjectManager.php
ObjectManager.addPreference
public function addPreference(DescriptorInterface $objectDescriptor, $merge = false) { // query whether or not an existing preference has to be overwritten if ($this->hasAttribute($interface = $objectDescriptor->getInterface()) && !$merge) { return; } // add the new preference $this->setAttribute($interface, $objectDescriptor->getClassName()); }
php
public function addPreference(DescriptorInterface $objectDescriptor, $merge = false) { // query whether or not an existing preference has to be overwritten if ($this->hasAttribute($interface = $objectDescriptor->getInterface()) && !$merge) { return; } // add the new preference $this->setAttribute($interface, $objectDescriptor->getClassName()); }
[ "public", "function", "addPreference", "(", "DescriptorInterface", "$", "objectDescriptor", ",", "$", "merge", "=", "false", ")", "{", "// query whether or not an existing preference has to be overwritten", "if", "(", "$", "this", "->", "hasAttribute", "(", "$", "interf...
Adds the passed object descriptor to the object manager. If the merge flag is TRUE, then we check if already an object descriptor for the class exists before they will be merged. When we merge object descriptors this means, that the values of the passed descriptor will override the existing ones. @param \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor The object descriptor to add @param boolean $merge TRUE if we want to merge with an existing object descriptor @return void
[ "Adds", "the", "passed", "object", "descriptor", "to", "the", "object", "manager", ".", "If", "the", "merge", "flag", "is", "TRUE", "then", "we", "check", "if", "already", "an", "object", "descriptor", "for", "the", "class", "exists", "before", "they", "wi...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/DependencyInjectionContainer/ObjectManager.php#L97-L107
appserver-io/appserver
src/AppserverIo/Appserver/DependencyInjectionContainer/ObjectManager.php
ObjectManager.addObjectDescriptor
public function addObjectDescriptor(DescriptorInterface $objectDescriptor, $merge = false) { // query whether we've to merge the configuration found in annotations if ($this->hasObjectDescriptor($objectDescriptor->getName()) && $merge) { // load the existing descriptor $existingDescriptor = $this->getObjectDescriptor($objectDescriptor->getName()); $existingDescriptorType = get_class($existingDescriptor); // log on info level to make overwriting more obvious $this->getApplication()->getInitialContext()->getSystemLogger()->debug( sprintf( 'Overriding descriptor "%s" of webapp "%s" from XML configuration.', $existingDescriptor->getName(), $this->getApplication()->getName() ) ); // Merge the descriptors. XML configuration overrides values from annotation but we have to make sure // that the descriptors are of the same type. If not we have to take the XML descriptor as our new base descriptor // and merge the annotations (but XML still has to be dominant) $mergedDescriptor = null; if (!$objectDescriptor instanceof $existingDescriptorType) { // create a temporary clone of the object (XML) descriptor to merge the existing descriptor into an instance with the same type $mergedDescriptor = clone $objectDescriptor; $mergedDescriptor->merge($existingDescriptor); $mergedDescriptor->merge($objectDescriptor); } else { // merge the object descriptor into the existing one $mergedDescriptor = $existingDescriptor; $mergedDescriptor->merge($objectDescriptor); } // re-register the merged descriptor $this->setObjectDescriptor($mergedDescriptor); } else { // register the object descriptor $this->setObjectDescriptor($objectDescriptor); } }
php
public function addObjectDescriptor(DescriptorInterface $objectDescriptor, $merge = false) { // query whether we've to merge the configuration found in annotations if ($this->hasObjectDescriptor($objectDescriptor->getName()) && $merge) { // load the existing descriptor $existingDescriptor = $this->getObjectDescriptor($objectDescriptor->getName()); $existingDescriptorType = get_class($existingDescriptor); // log on info level to make overwriting more obvious $this->getApplication()->getInitialContext()->getSystemLogger()->debug( sprintf( 'Overriding descriptor "%s" of webapp "%s" from XML configuration.', $existingDescriptor->getName(), $this->getApplication()->getName() ) ); // Merge the descriptors. XML configuration overrides values from annotation but we have to make sure // that the descriptors are of the same type. If not we have to take the XML descriptor as our new base descriptor // and merge the annotations (but XML still has to be dominant) $mergedDescriptor = null; if (!$objectDescriptor instanceof $existingDescriptorType) { // create a temporary clone of the object (XML) descriptor to merge the existing descriptor into an instance with the same type $mergedDescriptor = clone $objectDescriptor; $mergedDescriptor->merge($existingDescriptor); $mergedDescriptor->merge($objectDescriptor); } else { // merge the object descriptor into the existing one $mergedDescriptor = $existingDescriptor; $mergedDescriptor->merge($objectDescriptor); } // re-register the merged descriptor $this->setObjectDescriptor($mergedDescriptor); } else { // register the object descriptor $this->setObjectDescriptor($objectDescriptor); } }
[ "public", "function", "addObjectDescriptor", "(", "DescriptorInterface", "$", "objectDescriptor", ",", "$", "merge", "=", "false", ")", "{", "// query whether we've to merge the configuration found in annotations", "if", "(", "$", "this", "->", "hasObjectDescriptor", "(", ...
Adds the passed object descriptor to the object manager. If the merge flag is TRUE, then we check if already an object descriptor for the class exists before they will be merged. When we merge object descriptors this means, that the values of the passed descriptor will override the existing ones. @param \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor The object descriptor to add @param boolean $merge TRUE if we want to merge with an existing object descriptor @return void
[ "Adds", "the", "passed", "object", "descriptor", "to", "the", "object", "manager", ".", "If", "the", "merge", "flag", "is", "TRUE", "then", "we", "check", "if", "already", "an", "object", "descriptor", "for", "the", "class", "exists", "before", "they", "wi...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/DependencyInjectionContainer/ObjectManager.php#L140-L180
appserver-io/appserver
src/AppserverIo/Appserver/DependencyInjectionContainer/ObjectManager.php
ObjectManager.getObjectDescriptor
public function getObjectDescriptor($name) { // query if we've an object descriptor registered if ($this->hasObjectDescriptor($name)) { // return the object descriptor return $this->objectDescriptors->get($name); } // throw an exception is object descriptor has not been registered throw new UnknownObjectDescriptorException(sprintf('Object Descriptor with name "%s" has not been registered', $name)); }
php
public function getObjectDescriptor($name) { // query if we've an object descriptor registered if ($this->hasObjectDescriptor($name)) { // return the object descriptor return $this->objectDescriptors->get($name); } // throw an exception is object descriptor has not been registered throw new UnknownObjectDescriptorException(sprintf('Object Descriptor with name "%s" has not been registered', $name)); }
[ "public", "function", "getObjectDescriptor", "(", "$", "name", ")", "{", "// query if we've an object descriptor registered", "if", "(", "$", "this", "->", "hasObjectDescriptor", "(", "$", "name", ")", ")", "{", "// return the object descriptor", "return", "$", "this"...
Returns the object descriptor if we've registered it. @param string $name The name we want to return the object descriptor for @return \AppserverIo\Psr\Deployment\DescriptorInterface|null The requested object descriptor instance @throws \AppserverIo\Psr\Di\UnknownObjectDescriptorException Is thrown if someone tries to access an unknown object desciptor
[ "Returns", "the", "object", "descriptor", "if", "we", "ve", "registered", "it", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/DependencyInjectionContainer/ObjectManager.php#L214-L225
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/WebAppNode.php
WebAppNode.postInit
protected function postInit() { // initialize the node values for the default error page $errorCodePattern = new ValueNode(new NodeValue(ErrorPageNodeInterface::DEFAULT_ERROR_CODE_PATTERN)); $errorLocation = new ValueNode(new NodeValue(ErrorPageNodeInterface::DEFAULT_ERROR_LOCATION)); // add the default error page $this->errorPages[] = new ErrorPageNode($errorCodePattern, $errorLocation); }
php
protected function postInit() { // initialize the node values for the default error page $errorCodePattern = new ValueNode(new NodeValue(ErrorPageNodeInterface::DEFAULT_ERROR_CODE_PATTERN)); $errorLocation = new ValueNode(new NodeValue(ErrorPageNodeInterface::DEFAULT_ERROR_LOCATION)); // add the default error page $this->errorPages[] = new ErrorPageNode($errorCodePattern, $errorLocation); }
[ "protected", "function", "postInit", "(", ")", "{", "// initialize the node values for the default error page", "$", "errorCodePattern", "=", "new", "ValueNode", "(", "new", "NodeValue", "(", "ErrorPageNodeInterface", "::", "DEFAULT_ERROR_CODE_PATTERN", ")", ")", ";", "$"...
Will be invoked after the node will be initialized from the configuration values. Initialize the web app with the default error page. @return void
[ "Will", "be", "invoked", "after", "the", "node", "will", "be", "initialized", "from", "the", "configuration", "values", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/WebAppNode.php#L169-L178
appserver-io/appserver
src/AppserverIo/Appserver/Naming/NamingContextFactory.php
NamingContextFactory.visit
public static function visit(ManagerSettingsAwareInterface $manager) { // load the path to the web application $application = $manager->getApplication(); $webappPath = $application->getWebappPath(); // initialize the variable for the properties $properties = null; // load the configuration base directory if ($baseDirectory = $manager->getManagerSettings()->getBaseDirectory()) { // look for naming context properties in the manager's base directory $propertiesFile = DirectoryKeys::realpath( sprintf('%s/%s/%s', $webappPath, $baseDirectory, NamingContextFactory::CONFIGURATION_FILE) ); // load the properties from the configuration file if (file_exists($propertiesFile)) { $properties = Properties::create()->load($propertiesFile); } } // create the initial context instance $initialContext = new InitialContext($properties); $initialContext->injectApplication($application); // set the initial context in the manager $manager->injectInitialContext($initialContext); }
php
public static function visit(ManagerSettingsAwareInterface $manager) { // load the path to the web application $application = $manager->getApplication(); $webappPath = $application->getWebappPath(); // initialize the variable for the properties $properties = null; // load the configuration base directory if ($baseDirectory = $manager->getManagerSettings()->getBaseDirectory()) { // look for naming context properties in the manager's base directory $propertiesFile = DirectoryKeys::realpath( sprintf('%s/%s/%s', $webappPath, $baseDirectory, NamingContextFactory::CONFIGURATION_FILE) ); // load the properties from the configuration file if (file_exists($propertiesFile)) { $properties = Properties::create()->load($propertiesFile); } } // create the initial context instance $initialContext = new InitialContext($properties); $initialContext->injectApplication($application); // set the initial context in the manager $manager->injectInitialContext($initialContext); }
[ "public", "static", "function", "visit", "(", "ManagerSettingsAwareInterface", "$", "manager", ")", "{", "// load the path to the web application", "$", "application", "=", "$", "manager", "->", "getApplication", "(", ")", ";", "$", "webappPath", "=", "$", "applicat...
Creates a new naming context and add's it to the passed manager. @param \AppserverIo\Psr\Application\ManagerInterface $manager The manager to add the naming context to @return void
[ "Creates", "a", "new", "naming", "context", "and", "add", "s", "it", "to", "the", "passed", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Naming/NamingContextFactory.php#L61-L90
appserver-io/appserver
src/AppserverIo/Appserver/Console/ConsoleManagerFactory.php
ConsoleManagerFactory.visit
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the console manager $consoleManager = new ConsoleManager(); $consoleManager->injectApplication($application); // attach the instance $application->addManager($consoleManager, $managerConfiguration); }
php
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the console manager $consoleManager = new ConsoleManager(); $consoleManager->injectApplication($application); // attach the instance $application->addManager($consoleManager, $managerConfiguration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ManagerNodeInterface", "$", "managerConfiguration", ")", "{", "// initialize the console manager", "$", "consoleManager", "=", "new", "ConsoleManager", "(", ")", ";", "$", ...
The main method that creates new instances in a separate context. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration The manager configuration @return void
[ "The", "main", "method", "that", "creates", "new", "instances", "in", "a", "separate", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Console/ConsoleManagerFactory.php#L47-L56
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Normalizer.php
Normalizer.normalize
public function normalize(ConfigurationInterface $configuration) { // initialize the \stdClass instance $node = $this->newInstance('\stdClass'); $node->{$configuration->getNodeName()} = new \stdClass(); // set the node value if available if ($value = $configuration->getValue()) { $node->{$configuration->getNodeName()}->value = $value; } // set members by converting camel case to underscore (necessary for ember.js) foreach ($configuration->getAllData() as $member => $value) { $node->{$configuration->getNodeName()}->{strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $member))} = $value; } // return the normalized node instance return $node; }
php
public function normalize(ConfigurationInterface $configuration) { // initialize the \stdClass instance $node = $this->newInstance('\stdClass'); $node->{$configuration->getNodeName()} = new \stdClass(); // set the node value if available if ($value = $configuration->getValue()) { $node->{$configuration->getNodeName()}->value = $value; } // set members by converting camel case to underscore (necessary for ember.js) foreach ($configuration->getAllData() as $member => $value) { $node->{$configuration->getNodeName()}->{strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $member))} = $value; } // return the normalized node instance return $node; }
[ "public", "function", "normalize", "(", "ConfigurationInterface", "$", "configuration", ")", "{", "// initialize the \\stdClass instance", "$", "node", "=", "$", "this", "->", "newInstance", "(", "'\\stdClass'", ")", ";", "$", "node", "->", "{", "$", "configuratio...
Normalizes the passed configuration node and returns a \stdClass representation of it. @param \AppserverIo\Configuration\Interfaces\ConfigurationInterface $configuration The configuration node to normalize @return \stdClass The normalized configuration node
[ "Normalizes", "the", "passed", "configuration", "node", "and", "returns", "a", "\\", "stdClass", "representation", "of", "it", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Normalizer.php#L45-L63
appserver-io/appserver
src/AppserverIo/Appserver/Core/Listeners/LoadInitialContextListener.php
LoadInitialContextListener.handle
public function handle(EventInterface $event) { try { // load the application server and system configuration instance /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */ $applicationServer = $this->getApplicationServer(); /** @var \AppserverIo\Psr\ApplicationServer\Configuration\SystemConfigurationInterface $systemConfiguration */ $systemConfiguration = $applicationServer->getSystemConfiguration(); // load the initial context configuration /** @var \AppserverIo\Psr\ApplicationServer\Configuration\InitialContextConfigurationInterface $initialContextNode */ $initialContextNode = $systemConfiguration->getInitialContext(); $reflectionClass = new \ReflectionClass($initialContextNode->getType()); /** @var \AppserverIo\Psr\ApplicationServer\ContextInterface $initialContext */ $initialContext = $reflectionClass->newInstanceArgs(array($systemConfiguration)); // attach the registered loggers to the initial context $initialContext->setLoggers($applicationServer->getLoggers()); $initialContext->setSystemLogger($applicationServer->getSystemLogger()); // set the initial context and flush it initially $applicationServer->setInitialContext($initialContext); } catch (\Exception $e) { $applicationServer->getSystemLogger()->error($e->__toString()); } }
php
public function handle(EventInterface $event) { try { // load the application server and system configuration instance /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */ $applicationServer = $this->getApplicationServer(); /** @var \AppserverIo\Psr\ApplicationServer\Configuration\SystemConfigurationInterface $systemConfiguration */ $systemConfiguration = $applicationServer->getSystemConfiguration(); // load the initial context configuration /** @var \AppserverIo\Psr\ApplicationServer\Configuration\InitialContextConfigurationInterface $initialContextNode */ $initialContextNode = $systemConfiguration->getInitialContext(); $reflectionClass = new \ReflectionClass($initialContextNode->getType()); /** @var \AppserverIo\Psr\ApplicationServer\ContextInterface $initialContext */ $initialContext = $reflectionClass->newInstanceArgs(array($systemConfiguration)); // attach the registered loggers to the initial context $initialContext->setLoggers($applicationServer->getLoggers()); $initialContext->setSystemLogger($applicationServer->getSystemLogger()); // set the initial context and flush it initially $applicationServer->setInitialContext($initialContext); } catch (\Exception $e) { $applicationServer->getSystemLogger()->error($e->__toString()); } }
[ "public", "function", "handle", "(", "EventInterface", "$", "event", ")", "{", "try", "{", "// load the application server and system configuration instance", "/** @var \\AppserverIo\\Psr\\ApplicationServer\\ApplicationServerInterface $applicationServer */", "$", "applicationServer", "...
Handle an event. @param \League\Event\EventInterface $event The triggering event @return void @see \League\Event\ListenerInterface::handle()
[ "Handle", "an", "event", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Listeners/LoadInitialContextListener.php#L45-L72
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Callback/SecurityAssociationHandler.php
SecurityAssociationHandler.handle
public function handle(CollectionInterface $callbacks) { // handle the registered callbacks foreach ($callbacks as $callback) { if ($callback instanceof NameCallback) { $callback->setName($this->principal->getName()); } elseif ($callback instanceof PasswordCallback) { $callback->setPassword($this->credential); } else { throw new UnsupportedCallbackException('Unrecognized Callback'); } } }
php
public function handle(CollectionInterface $callbacks) { // handle the registered callbacks foreach ($callbacks as $callback) { if ($callback instanceof NameCallback) { $callback->setName($this->principal->getName()); } elseif ($callback instanceof PasswordCallback) { $callback->setPassword($this->credential); } else { throw new UnsupportedCallbackException('Unrecognized Callback'); } } }
[ "public", "function", "handle", "(", "CollectionInterface", "$", "callbacks", ")", "{", "// handle the registered callbacks", "foreach", "(", "$", "callbacks", "as", "$", "callback", ")", "{", "if", "(", "$", "callback", "instanceof", "NameCallback", ")", "{", "...
Handles UsernameCallback and PasswordCallback types. A UsernameCallback name property is set to the Prinicpal->getName() value. A PasswordCallback password property is set to the credential value. @param \AppserverIo\Collections\CollectionInterface $callbacks The collection with the callbacks @return void @throws \AppserverIo\Psr\Security\Auth\Callback\UnsupportedCallbackException Is thrown if any callback of type other than NameCallback or PasswordCallback has been passed
[ "Handles", "UsernameCallback", "and", "PasswordCallback", "types", ".", "A", "UsernameCallback", "name", "property", "is", "set", "to", "the", "Prinicpal", "-", ">", "getName", "()", "value", ".", "A", "PasswordCallback", "password", "property", "is", "set", "to...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Callback/SecurityAssociationHandler.php#L77-L89
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php
UsernamePasswordLoginModule.initialize
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // call the parent method parent::initialize($subject, $callbackHandler, $sharedState, $params); // check to see if password hashing has been enabled, if an algorithm is set, check for a format and charset $this->hashAlgorithm = new String($params->get(ParamKeys::HASH_ALGORITHM)); // query whether or not a hash algorithm has been specified if ($this->hashAlgorithm != null) { // initialize the hash encoding to use if ($params->exists(ParamKeys::HASH_ENCODING)) { $this->hashEncoding = new String($params->get(ParamKeys::HASH_ENCODING)); } else { $this->hashEncoding = new String(Util::BASE64_ENCODING); } // initialize the hash charset if specified if ($params->exists(ParamKeys::HASH_CHARSET)) { $this->hashCharset = new String($params->get(ParamKeys::HASH_CHARSET)); } } // query whether or not we should ignor case when comparing passwords if ($params->exists(ParamKeys::IGNORE_PASSWORD_CASE)) { $flag = new String($params->get(ParamKeys::IGNORE_PASSWORD_CASE)); $this->ignorePasswordCase = Boolean::valueOf($flag)->booleanValue(); } else { $this->ignorePasswordCase = false; } }
php
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // call the parent method parent::initialize($subject, $callbackHandler, $sharedState, $params); // check to see if password hashing has been enabled, if an algorithm is set, check for a format and charset $this->hashAlgorithm = new String($params->get(ParamKeys::HASH_ALGORITHM)); // query whether or not a hash algorithm has been specified if ($this->hashAlgorithm != null) { // initialize the hash encoding to use if ($params->exists(ParamKeys::HASH_ENCODING)) { $this->hashEncoding = new String($params->get(ParamKeys::HASH_ENCODING)); } else { $this->hashEncoding = new String(Util::BASE64_ENCODING); } // initialize the hash charset if specified if ($params->exists(ParamKeys::HASH_CHARSET)) { $this->hashCharset = new String($params->get(ParamKeys::HASH_CHARSET)); } } // query whether or not we should ignor case when comparing passwords if ($params->exists(ParamKeys::IGNORE_PASSWORD_CASE)) { $flag = new String($params->get(ParamKeys::IGNORE_PASSWORD_CASE)); $this->ignorePasswordCase = Boolean::valueOf($flag)->booleanValue(); } else { $this->ignorePasswordCase = false; } }
[ "public", "function", "initialize", "(", "Subject", "$", "subject", ",", "CallbackHandlerInterface", "$", "callbackHandler", ",", "MapInterface", "$", "sharedState", ",", "MapInterface", "$", "params", ")", "{", "// call the parent method", "parent", "::", "initialize...
Initialize the login module. This stores the subject, callbackHandler and sharedState and options for the login session. Subclasses should override if they need to process their own options. A call to parent::initialize() must be made in the case of an override. The following parameters can by default be passed from the configuration. lookupName: The datasource name used to lookup in the naming directory rolesQuery: The database query used to load the user's roles principalsQuery: The database query used to load the user @param \AppserverIo\Psr\Security\Auth\Subject $subject The Subject to update after a successful login @param \AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface $callbackHandler The callback handler that will be used to obtain the user identity and credentials @param \AppserverIo\Collections\MapInterface $sharedState A map shared between all configured login module instances @param \AppserverIo\Collections\MapInterface $params The parameters passed to the login module @return void
[ "Initialize", "the", "login", "module", ".", "This", "stores", "the", "subject", "callbackHandler", "and", "sharedState", "and", "options", "for", "the", "login", "session", ".", "Subclasses", "should", "override", "if", "they", "need", "to", "process", "their",...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php#L116-L146
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php
UsernamePasswordLoginModule.login
public function login() { // invoke the parent method if (parent::login()) { // if login has been successfully, setup our view of the user $name = new String($this->sharedState->get(SharedStateKeys::LOGIN_NAME)); // query whether or not we alredy hava a principal if ($name instanceof PrincipalInterface) { $this->identity = name; } else { $name = $name->__toString(); try { $this->identity = $this->createIdentity($name); } catch (\Exception $e) { throw new LoginException(sprintf('Failed to create principal: %s', $e->getMessage())); } } // return immediately return true; } // else, reset the login flag $this->loginOk = false; // array containing the username and password from the user's input list ($name, $password) = $this->getUsernameAndPassword(); if ($name == null && $password == null) { $this->identity = $this->unauthenticatedIdentity; } if ($this->identity == null) { try { $this->identity = $this->createIdentity($name); } catch (\Exception $e) { throw new LoginException(sprintf('Failed to create principal: %s', $e->getMessage())); } // hash the user entered password if password hashing is in use if ($this->hashAlgorithm != null) { $password = $this->createPasswordHash($name, $password); // validate the password supplied by the subclass $expectedPassword = $this->getUsersPassword(); } // validate the password if ($this->validatePassword($password, $expectedPassword) === false) { throw new FailedLoginException('Password Incorrect/Password Required'); } } // query whether or not password stacking has been activated if ($this->getUseFirstPass()) { // add the username and password to the shared state map $this->sharedState->add(SharedStateKeys::LOGIN_NAME, $name); $this->sharedState->add(SharedStateKeys::LOGIN_PASSWORD, $this->credential); } $this->loginOk = true; return true; }
php
public function login() { // invoke the parent method if (parent::login()) { // if login has been successfully, setup our view of the user $name = new String($this->sharedState->get(SharedStateKeys::LOGIN_NAME)); // query whether or not we alredy hava a principal if ($name instanceof PrincipalInterface) { $this->identity = name; } else { $name = $name->__toString(); try { $this->identity = $this->createIdentity($name); } catch (\Exception $e) { throw new LoginException(sprintf('Failed to create principal: %s', $e->getMessage())); } } // return immediately return true; } // else, reset the login flag $this->loginOk = false; // array containing the username and password from the user's input list ($name, $password) = $this->getUsernameAndPassword(); if ($name == null && $password == null) { $this->identity = $this->unauthenticatedIdentity; } if ($this->identity == null) { try { $this->identity = $this->createIdentity($name); } catch (\Exception $e) { throw new LoginException(sprintf('Failed to create principal: %s', $e->getMessage())); } // hash the user entered password if password hashing is in use if ($this->hashAlgorithm != null) { $password = $this->createPasswordHash($name, $password); // validate the password supplied by the subclass $expectedPassword = $this->getUsersPassword(); } // validate the password if ($this->validatePassword($password, $expectedPassword) === false) { throw new FailedLoginException('Password Incorrect/Password Required'); } } // query whether or not password stacking has been activated if ($this->getUseFirstPass()) { // add the username and password to the shared state map $this->sharedState->add(SharedStateKeys::LOGIN_NAME, $name); $this->sharedState->add(SharedStateKeys::LOGIN_PASSWORD, $this->credential); } $this->loginOk = true; return true; }
[ "public", "function", "login", "(", ")", "{", "// invoke the parent method", "if", "(", "parent", "::", "login", "(", ")", ")", "{", "// if login has been successfully, setup our view of the user", "$", "name", "=", "new", "String", "(", "$", "this", "->", "shared...
Perform the authentication of username and password. @return boolean TRUE when login has been successfull, else FALSE @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if an error during login occured
[ "Perform", "the", "authentication", "of", "username", "and", "password", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php#L162-L224
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php
UsernamePasswordLoginModule.createPasswordHash
protected function createPasswordHash(String $name, String $password) { // initialize the callback $callback = null; // query whether or not we've a callback configured if ($this->params->exists(ParamKeys::DIGEST_CALLBACK)) { try { // load the callback class name and create a new callback instance $callbackClassName = $this->params->get(ParamKeys::DIGEST_CALLBACK); $callback = new $callbackClassName(); // initialize the callback $tmp = new HashMap($this->params->toIndexedArray()); $tmp->add(SharedStateKeys::LOGIN_NAME, $name); $tmp->add(SharedStateKeys::LOGIN_PASSWORD, $password); $callback->init($tmp); } catch (\Exception $e) { throw new SecurityException("Failed to load DigestCallback"); } } // hash and return the password return Util::createPasswordHash($this->hashAlgorithm, $this->hashEncoding, $this->hashCharset, $name, $password, $callback); }
php
protected function createPasswordHash(String $name, String $password) { // initialize the callback $callback = null; // query whether or not we've a callback configured if ($this->params->exists(ParamKeys::DIGEST_CALLBACK)) { try { // load the callback class name and create a new callback instance $callbackClassName = $this->params->get(ParamKeys::DIGEST_CALLBACK); $callback = new $callbackClassName(); // initialize the callback $tmp = new HashMap($this->params->toIndexedArray()); $tmp->add(SharedStateKeys::LOGIN_NAME, $name); $tmp->add(SharedStateKeys::LOGIN_PASSWORD, $password); $callback->init($tmp); } catch (\Exception $e) { throw new SecurityException("Failed to load DigestCallback"); } } // hash and return the password return Util::createPasswordHash($this->hashAlgorithm, $this->hashEncoding, $this->hashCharset, $name, $password, $callback); }
[ "protected", "function", "createPasswordHash", "(", "String", "$", "name", ",", "String", "$", "password", ")", "{", "// initialize the callback", "$", "callback", "=", "null", ";", "// query whether or not we've a callback configured", "if", "(", "$", "this", "->", ...
If hashing is enabled, this method is called from login() prior to password validation. Subclasses may override it to provide customized password hashing, for example by adding user-specific information or salting. The default version calculates the hash based on the following options: hashAlgorithm: The digest algorithm to use. hashEncoding: The format used to store the hashes (base64 or hex) hashCharset: The encoding used to convert the password to bytes for hashing. digestCallback: The class name of the digest callback implementation that includes pre/post digest content like salts. It will return null if the hash fails for any reason, which will in turn cause validatePassword() to fail. @param \AppserverIo\Lang\String $name Ignored in default version @param \AppserverIo\Lang\String $password The password string to be hashed @return \AppserverIo\Lang\String The hashed password @throws \AppserverIo\Psr\Security\SecurityException Is thrown if there is a failure to load the digestCallback
[ "If", "hashing", "is", "enabled", "this", "method", "is", "called", "from", "login", "()", "prior", "to", "password", "validation", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php#L252-L278
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php
UsernamePasswordLoginModule.validatePassword
protected function validatePassword(String $inputPassword, String $expectedPassword) { // if username or password is NULL, return immediately if ($inputPassword == null || $expectedPassword == null) { return false; } // initialize the valid login flag $valid = false; // query whether or not we've to ignore the case if ($this->ignorePasswordCase === true) { $valid = $inputPassword->equalsIgnoreCase($expectedPassword); } else { $valid = $inputPassword->equals($expectedPassword); } // return the flag return $valid; }
php
protected function validatePassword(String $inputPassword, String $expectedPassword) { // if username or password is NULL, return immediately if ($inputPassword == null || $expectedPassword == null) { return false; } // initialize the valid login flag $valid = false; // query whether or not we've to ignore the case if ($this->ignorePasswordCase === true) { $valid = $inputPassword->equalsIgnoreCase($expectedPassword); } else { $valid = $inputPassword->equals($expectedPassword); } // return the flag return $valid; }
[ "protected", "function", "validatePassword", "(", "String", "$", "inputPassword", ",", "String", "$", "expectedPassword", ")", "{", "// if username or password is NULL, return immediately", "if", "(", "$", "inputPassword", "==", "null", "||", "$", "expectedPassword", "=...
A hook that allows subclasses to change the validation of the input password against the expected password. This version checks that neither inputPassword or expectedPassword are null that that inputPassword.equals(expectedPassword) is true; @param \AppserverIo\Lang\String $inputPassword The specified password @param \AppserverIo\Lang\String $expectedPassword The expected password @return boolean TRUE if the inputPassword is valid, FALSE otherwise
[ "A", "hook", "that", "allows", "subclasses", "to", "change", "the", "validation", "of", "the", "input", "password", "against", "the", "expected", "password", ".", "This", "version", "checks", "that", "neither", "inputPassword", "or", "expectedPassword", "are", "...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php#L291-L311
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php
UsernamePasswordLoginModule.getUsername
protected function getUsername() { // initialize the name $name = null; // query whether or not we've an principal if ($identity = $this->getIdentity()) { $name = $identity->getName(); } // return the name return $name; }
php
protected function getUsername() { // initialize the name $name = null; // query whether or not we've an principal if ($identity = $this->getIdentity()) { $name = $identity->getName(); } // return the name return $name; }
[ "protected", "function", "getUsername", "(", ")", "{", "// initialize the name", "$", "name", "=", "null", ";", "// query whether or not we've an principal", "if", "(", "$", "identity", "=", "$", "this", "->", "getIdentity", "(", ")", ")", "{", "$", "name", "=...
Return's the principal's username. @return \AppserverIo\Lang\String The username
[ "Return", "s", "the", "principal", "s", "username", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/UsernamePasswordLoginModule.php#L328-L341
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Timer.php
Timer.getPreviousRun
public function getPreviousRun() { if ($this->previousRun != null) { return \DateTime::createFromFormat(ScheduleExpression::DATE_FORMAT, $this->previousRun); } }
php
public function getPreviousRun() { if ($this->previousRun != null) { return \DateTime::createFromFormat(ScheduleExpression::DATE_FORMAT, $this->previousRun); } }
[ "public", "function", "getPreviousRun", "(", ")", "{", "if", "(", "$", "this", "->", "previousRun", "!=", "null", ")", "{", "return", "\\", "DateTime", "::", "createFromFormat", "(", "ScheduleExpression", "::", "DATE_FORMAT", ",", "$", "this", "->", "previou...
Returns the previous run date. @return \DateTime|null The previous run date
[ "Returns", "the", "previous", "run", "date", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Timer.php#L155-L160
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Timer.php
Timer.getNextExpiration
public function getNextExpiration() { if ($this->nextExpiration != null) { return \DateTime::createFromFormat(ScheduleExpression::DATE_FORMAT, $this->nextExpiration); } }
php
public function getNextExpiration() { if ($this->nextExpiration != null) { return \DateTime::createFromFormat(ScheduleExpression::DATE_FORMAT, $this->nextExpiration); } }
[ "public", "function", "getNextExpiration", "(", ")", "{", "if", "(", "$", "this", "->", "nextExpiration", "!=", "null", ")", "{", "return", "\\", "DateTime", "::", "createFromFormat", "(", "ScheduleExpression", "::", "DATE_FORMAT", ",", "$", "this", "->", "n...
This method is similar to Timer::getNextTimeout(), except that this method does not check the timer state and hence does not throw either IllegalStateException or NoSuchObjectLocalException or EnterpriseBeansException. @return \DateTime The date of the next timeout expiration
[ "This", "method", "is", "similar", "to", "Timer", "::", "getNextTimeout", "()", "except", "that", "this", "method", "does", "not", "check", "the", "timer", "state", "and", "hence", "does", "not", "throw", "either", "IllegalStateException", "or", "NoSuchObjectLoc...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Timer.php#L192-L197
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Timer.php
Timer.setNextTimeout
public function setNextTimeout($next = null) { if ($next != null) { $this->nextExpiration = $next; } else { $this->nextExpiration = null; } }
php
public function setNextTimeout($next = null) { if ($next != null) { $this->nextExpiration = $next; } else { $this->nextExpiration = null; } }
[ "public", "function", "setNextTimeout", "(", "$", "next", "=", "null", ")", "{", "if", "(", "$", "next", "!=", "null", ")", "{", "$", "this", "->", "nextExpiration", "=", "$", "next", ";", "}", "else", "{", "$", "this", "->", "nextExpiration", "=", ...
Sets the next timeout of this timer. @param string $next The next scheduled timeout of this timer @return void
[ "Sets", "the", "next", "timeout", "of", "this", "timer", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Timer.php#L206-L213
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Timer.php
Timer.getNextTimeout
public function getNextTimeout() { // throw an exception if timer has been canceled if ($this->isCanceled()) { throw new NoSuchObjectLocalException('Timer has been cancelled'); } // return the timeout of the next expiration $nextExpiration = $this->getNextExpiration(); // check if we've a next expiration timeout if ($nextExpiration == null) { throw new NoMoreTimeoutsException(sprintf('Timer %s has no more future timeouts', $this->getId())); } // return the next expiration date return $nextExpiration; }
php
public function getNextTimeout() { // throw an exception if timer has been canceled if ($this->isCanceled()) { throw new NoSuchObjectLocalException('Timer has been cancelled'); } // return the timeout of the next expiration $nextExpiration = $this->getNextExpiration(); // check if we've a next expiration timeout if ($nextExpiration == null) { throw new NoMoreTimeoutsException(sprintf('Timer %s has no more future timeouts', $this->getId())); } // return the next expiration date return $nextExpiration; }
[ "public", "function", "getNextTimeout", "(", ")", "{", "// throw an exception if timer has been canceled", "if", "(", "$", "this", "->", "isCanceled", "(", ")", ")", "{", "throw", "new", "NoSuchObjectLocalException", "(", "'Timer has been cancelled'", ")", ";", "}", ...
Get the point in time at which the next timer expiration is scheduled to occur. @return \DateTime Get the point in time at which the next timer expiration is scheduled to occur @throws \AppserverIo\Psr\EnterpriseBeans\NoSuchObjectLocalException If invoked on a timer that has expired or has been cancelled @throws \AppserverIo\Psr\EnterpriseBeans\NoMoreTimeoutsException Indicates that the timer has no future timeouts @throws \AppserverIo\Psr\EnterpriseBeans\EnterpriseBeansException If this method could not complete due to a system-level failure
[ "Get", "the", "point", "in", "time", "at", "which", "the", "next", "timer", "expiration", "is", "scheduled", "to", "occur", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Timer.php#L223-L241
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Timer.php
Timer.isActive
public function isActive() { return $this->timerService->isStarted() && !$this->isCanceled() && !$this->isExpired() && ($this->timerService->isScheduled($this->getId()) || $this->timerState == TimerState::CREATED); }
php
public function isActive() { return $this->timerService->isStarted() && !$this->isCanceled() && !$this->isExpired() && ($this->timerService->isScheduled($this->getId()) || $this->timerState == TimerState::CREATED); }
[ "public", "function", "isActive", "(", ")", "{", "return", "$", "this", "->", "timerService", "->", "isStarted", "(", ")", "&&", "!", "$", "this", "->", "isCanceled", "(", ")", "&&", "!", "$", "this", "->", "isExpired", "(", ")", "&&", "(", "$", "t...
Returns TRUE if this timer is active, else FALSE. A timer is considered to be "active", if its timer state is neither of the following: - TimerState::CANCELED - TimerState::EXPIRED - has not been suspended And if the corresponding timer service is still up @return boolean TRUE if the timer is active
[ "Returns", "TRUE", "if", "this", "timer", "is", "active", "else", "FALSE", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Timer.php#L400-L404
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Session/SessionHandlerFactory.php
SessionHandlerFactory.create
public static function create( SessionHandlerNodeInterface $sessionHandlerNode, SessionSettingsInterface $sessionSettings ) { // reflect the class $reflectionClass = new ReflectionClass($sessionHandlerNode->getType()); // create and initialize the session handler instance $sessionHandler = $reflectionClass->newInstanceArgs($sessionHandlerNode->getParamsAsArray()); $sessionHandler->injectSessionSettings($sessionSettings); // return the initialzed instance return $sessionHandler; }
php
public static function create( SessionHandlerNodeInterface $sessionHandlerNode, SessionSettingsInterface $sessionSettings ) { // reflect the class $reflectionClass = new ReflectionClass($sessionHandlerNode->getType()); // create and initialize the session handler instance $sessionHandler = $reflectionClass->newInstanceArgs($sessionHandlerNode->getParamsAsArray()); $sessionHandler->injectSessionSettings($sessionSettings); // return the initialzed instance return $sessionHandler; }
[ "public", "static", "function", "create", "(", "SessionHandlerNodeInterface", "$", "sessionHandlerNode", ",", "SessionSettingsInterface", "$", "sessionSettings", ")", "{", "// reflect the class", "$", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "sessionHan...
Create and return a new instance of the session handler with the passed configuration. @param \AppserverIo\Appserver\Core\Api\Node\SessionHandlerNodeInterface $sessionHandlerNode The session handler configuration @param \AppserverIo\Appserver\ServletEngine\SessionSettingsInterface $sessionSettings The session settings @return \AppserverIo\Appserver\ServletEngine\Session\SessionHandlerInterface The session handler instance
[ "Create", "and", "return", "a", "new", "instance", "of", "the", "session", "handler", "with", "the", "passed", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Session/SessionHandlerFactory.php#L48-L62
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Part.php
Part.fromHttpRequest
public static function fromHttpRequest(PartInterface $httpPart) { // create a temporary filename $httpPart->write($tmpFilename = tempnam(ini_get('upload_tmp_dir'), 'tmp_')); // initialize the servlet part instance $servletPart = new Part(); $servletPart->setName($httpPart->getName()); $servletPart->setFilename($httpPart->getFilename()); $servletPart->setTmpFilename($tmpFilename); // initialize the headers the the size $servletPart->headers = $httpPart->getHeaders(); $servletPart->size = $httpPart->getSize(); // return the servlet part instance return $servletPart; }
php
public static function fromHttpRequest(PartInterface $httpPart) { // create a temporary filename $httpPart->write($tmpFilename = tempnam(ini_get('upload_tmp_dir'), 'tmp_')); // initialize the servlet part instance $servletPart = new Part(); $servletPart->setName($httpPart->getName()); $servletPart->setFilename($httpPart->getFilename()); $servletPart->setTmpFilename($tmpFilename); // initialize the headers the the size $servletPart->headers = $httpPart->getHeaders(); $servletPart->size = $httpPart->getSize(); // return the servlet part instance return $servletPart; }
[ "public", "static", "function", "fromHttpRequest", "(", "PartInterface", "$", "httpPart", ")", "{", "// create a temporary filename", "$", "httpPart", "->", "write", "(", "$", "tmpFilename", "=", "tempnam", "(", "ini_get", "(", "'upload_tmp_dir'", ")", ",", "'tmp_...
Creates a new servlet part instance with the data from the HTTP part. @param \AppserverIo\Psr\HttpMessage\PartInterface $httpPart The HTTP part we want to copy @return \AppserverIo\Appserver\ServletEngine\Http\Part The initialized servlet part
[ "Creates", "a", "new", "servlet", "part", "instance", "with", "the", "data", "from", "the", "HTTP", "part", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Part.php#L87-L105
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Part.php
Part.init
public function init($streamWrapper = self::STREAM_WRAPPER_TEMP, $maxMemory = 5242880) { // weather we've already set a filename open the input stream if ($tmpFilename = $this->getTmpFilename()) { if (!$this->inputStream = fopen($tmpFilename, 'r+')) { throw new \Exception(sprintf('Can\'t open input temporary filename %s', $tmpFilename)); } } else { if (!$this->inputStream = fopen($streamWrapper . '/maxmemory:' . $maxMemory, 'r+')) { throw new \Exception(sprintf('Can\'t open stream wrapper %s', $streamWrapper)); } } }
php
public function init($streamWrapper = self::STREAM_WRAPPER_TEMP, $maxMemory = 5242880) { // weather we've already set a filename open the input stream if ($tmpFilename = $this->getTmpFilename()) { if (!$this->inputStream = fopen($tmpFilename, 'r+')) { throw new \Exception(sprintf('Can\'t open input temporary filename %s', $tmpFilename)); } } else { if (!$this->inputStream = fopen($streamWrapper . '/maxmemory:' . $maxMemory, 'r+')) { throw new \Exception(sprintf('Can\'t open stream wrapper %s', $streamWrapper)); } } }
[ "public", "function", "init", "(", "$", "streamWrapper", "=", "self", "::", "STREAM_WRAPPER_TEMP", ",", "$", "maxMemory", "=", "5242880", ")", "{", "// weather we've already set a filename open the input stream", "if", "(", "$", "tmpFilename", "=", "$", "this", "->"...
Initiates a http form part object @param string $streamWrapper The stream wrapper to use per default temp stream wrapper @param integer $maxMemory Maximum memory in bytes per default to 5 MB @throws \Exception @return void
[ "Initiates", "a", "http", "form", "part", "object" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Part.php#L116-L129
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Part.php
Part.putContent
public function putContent($content) { // write to io stream $this->size = fwrite($this->inputStream, $content); // rewind file pointer rewind($this->inputStream); }
php
public function putContent($content) { // write to io stream $this->size = fwrite($this->inputStream, $content); // rewind file pointer rewind($this->inputStream); }
[ "public", "function", "putContent", "(", "$", "content", ")", "{", "// write to io stream", "$", "this", "->", "size", "=", "fwrite", "(", "$", "this", "->", "inputStream", ",", "$", "content", ")", ";", "// rewind file pointer", "rewind", "(", "$", "this", ...
Puts content to input stream. @param string $content The content as string @return void
[ "Puts", "content", "to", "input", "stream", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Part.php#L138-L144
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Part.php
Part.getHeaders
public function getHeaders($name = null) { if (is_null($name)) { return $this->headers; } else { return $this->getHeader($name); } }
php
public function getHeaders($name = null) { if (is_null($name)) { return $this->headers; } else { return $this->getHeader($name); } }
[ "public", "function", "getHeaders", "(", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "headers", ";", "}", "else", "{", "return", "$", "this", "->", "getHeader", "(", "$", ...
Gets the values of the Part header with the given name. @param string $name the header name whose values to return @return array
[ "Gets", "the", "values", "of", "the", "Part", "header", "with", "the", "given", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Part.php#L305-L312
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/DtoNormalizer.php
DtoNormalizer.normalize
public function normalize(ConfigurationInterface $configuration) { $nodeType = $this->getService()->getNodeType(); return $this->newInstance($nodeType, array( $configuration )); }
php
public function normalize(ConfigurationInterface $configuration) { $nodeType = $this->getService()->getNodeType(); return $this->newInstance($nodeType, array( $configuration )); }
[ "public", "function", "normalize", "(", "ConfigurationInterface", "$", "configuration", ")", "{", "$", "nodeType", "=", "$", "this", "->", "getService", "(", ")", "->", "getNodeType", "(", ")", ";", "return", "$", "this", "->", "newInstance", "(", "$", "no...
(non-PHPdoc) @param \AppserverIo\Configuration\Interfaces\ConfigurationInterface $configuration The configuration node to normalize @return \stdClass The normalized configuration node @see \AppserverIo\Appserver\Core\Api\NormalizerInterface::normalize()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/DtoNormalizer.php#L45-L51
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/SessionFilter.php
SessionFilter.accept
public function accept() { // load the current file $splFileInfo = $this->getInnerIterator()->current(); // calculate the maximum age of sessions we want to load $aTime = time() - $this->maximumAge; // compare the session files age against the maximum age if ($splFileInfo->getATime() < $aTime) { return false; } return true; }
php
public function accept() { // load the current file $splFileInfo = $this->getInnerIterator()->current(); // calculate the maximum age of sessions we want to load $aTime = time() - $this->maximumAge; // compare the session files age against the maximum age if ($splFileInfo->getATime() < $aTime) { return false; } return true; }
[ "public", "function", "accept", "(", ")", "{", "// load the current file", "$", "splFileInfo", "=", "$", "this", "->", "getInnerIterator", "(", ")", "->", "current", "(", ")", ";", "// calculate the maximum age of sessions we want to load", "$", "aTime", "=", "time"...
This method compares the session files age against the configured maximum age of session files we want to load. @return boolean TRUE if we want to load the session, else FALSE
[ "This", "method", "compares", "the", "session", "files", "age", "against", "the", "configured", "maximum", "age", "of", "session", "files", "we", "want", "to", "load", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/SessionFilter.php#L66-L81
appserver-io/appserver
src/AppserverIo/Appserver/Logger/Formatters/VarDumperFormatter.php
VarDumperFormatter.format
public function format(LogMessageInterface $logMessage) { // initialize the parameters for the formatted message $params = array( date($this->dateFormat), gethostname(), $logMessage->getLevel(), $this->convertToString($logMessage), json_encode($logMessage->getContext()) ); // format, trim and return the message return trim(vsprintf($this->messageFormat, $params)); }
php
public function format(LogMessageInterface $logMessage) { // initialize the parameters for the formatted message $params = array( date($this->dateFormat), gethostname(), $logMessage->getLevel(), $this->convertToString($logMessage), json_encode($logMessage->getContext()) ); // format, trim and return the message return trim(vsprintf($this->messageFormat, $params)); }
[ "public", "function", "format", "(", "LogMessageInterface", "$", "logMessage", ")", "{", "// initialize the parameters for the formatted message", "$", "params", "=", "array", "(", "date", "(", "$", "this", "->", "dateFormat", ")", ",", "gethostname", "(", ")", ",...
Formats and returns a string representation of the passed log message. @param \AppserverIo\Logger\LogMessageInterface $logMessage The log message we want to format @return string The formatted string representation for the log messsage
[ "Formats", "and", "returns", "a", "string", "representation", "of", "the", "passed", "log", "message", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Logger/Formatters/VarDumperFormatter.php#L115-L129
appserver-io/appserver
src/AppserverIo/Appserver/Logger/Formatters/VarDumperFormatter.php
VarDumperFormatter.convertToString
protected function convertToString(LogMessageInterface $logMessage) { // initialize the variable for the log output $output = ''; // dump the log message $this->dumper->dump( $this->cloner->cloneVar($logMessage->getMessage()), function ($line, $depth) use (&$output) { // a negative depth means "end of dump" if ($depth >= 0) { // adds a two spaces indentation to the line $output .= str_repeat(' ', $depth) . $line . PHP_EOL; } } ); // return the log output return rtrim($output, PHP_EOL); }
php
protected function convertToString(LogMessageInterface $logMessage) { // initialize the variable for the log output $output = ''; // dump the log message $this->dumper->dump( $this->cloner->cloneVar($logMessage->getMessage()), function ($line, $depth) use (&$output) { // a negative depth means "end of dump" if ($depth >= 0) { // adds a two spaces indentation to the line $output .= str_repeat(' ', $depth) . $line . PHP_EOL; } } ); // return the log output return rtrim($output, PHP_EOL); }
[ "protected", "function", "convertToString", "(", "LogMessageInterface", "$", "logMessage", ")", "{", "// initialize the variable for the log output", "$", "output", "=", "''", ";", "// dump the log message", "$", "this", "->", "dumper", "->", "dump", "(", "$", "this",...
Convert's the passed message into an string. @param \AppserverIo\Logger\LogMessageInterface $logMessage The log message we want to convert @return string The converted message
[ "Convert", "s", "the", "passed", "message", "into", "an", "string", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Logger/Formatters/VarDumperFormatter.php#L138-L158
appserver-io/appserver
src/AppserverIo/Appserver/Core/Listeners/SwitchRootListener.php
SwitchRootListener.handle
public function handle(EventInterface $event) { try { // load the application server instance /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */ $applicationServer = $this->getApplicationServer(); // write a log message that the event has been invoked $applicationServer->getSystemLogger()->info($event->getName()); // print a message with the old UID/EUID $applicationServer->getSystemLogger()->info("Running as " . posix_getuid() . "/" . posix_geteuid()); // extract the variables $uid = 0; extract(posix_getpwnam('root')); // switcht the effective UID to the passed user if (posix_seteuid($uid) === false) { $applicationServer->getSystemLogger()->error(sprintf('Can\'t switch UID to \'%s\'', $uid)); } // print a message with the new UID/EUID $applicationServer->getSystemLogger()->info("Running as " . posix_getuid() . "/" . posix_geteuid()); // @TODO Switch group also!!!! } catch (\Exception $e) { $applicationServer->getSystemLogger()->error($e->__toString()); } }
php
public function handle(EventInterface $event) { try { // load the application server instance /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */ $applicationServer = $this->getApplicationServer(); // write a log message that the event has been invoked $applicationServer->getSystemLogger()->info($event->getName()); // print a message with the old UID/EUID $applicationServer->getSystemLogger()->info("Running as " . posix_getuid() . "/" . posix_geteuid()); // extract the variables $uid = 0; extract(posix_getpwnam('root')); // switcht the effective UID to the passed user if (posix_seteuid($uid) === false) { $applicationServer->getSystemLogger()->error(sprintf('Can\'t switch UID to \'%s\'', $uid)); } // print a message with the new UID/EUID $applicationServer->getSystemLogger()->info("Running as " . posix_getuid() . "/" . posix_geteuid()); // @TODO Switch group also!!!! } catch (\Exception $e) { $applicationServer->getSystemLogger()->error($e->__toString()); } }
[ "public", "function", "handle", "(", "EventInterface", "$", "event", ")", "{", "try", "{", "// load the application server instance", "/** @var \\AppserverIo\\Psr\\ApplicationServer\\ApplicationServerInterface $applicationServer */", "$", "applicationServer", "=", "$", "this", "-...
Handle an event. @param \League\Event\EventInterface $event The triggering event @return void @see \League\Event\ListenerInterface::handle()
[ "Handle", "an", "event", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Listeners/SwitchRootListener.php#L45-L76
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/ConnectorsNodeTrait.php
ConnectorsNodeTrait.getConnector
public function getConnector($name) { // Iterate over all connectors /** @var \AppserverIo\Appserver\Core\Api\Node\ConnectorNode $connectorNode */ foreach ($this->getConnectors() as $connectorNode) { // If we found one with a matching URI we will return it if ($connectorNode->getName() === $name) { return $connectorNode; } } // Still here? Seems we did not find anything return false; }
php
public function getConnector($name) { // Iterate over all connectors /** @var \AppserverIo\Appserver\Core\Api\Node\ConnectorNode $connectorNode */ foreach ($this->getConnectors() as $connectorNode) { // If we found one with a matching URI we will return it if ($connectorNode->getName() === $name) { return $connectorNode; } } // Still here? Seems we did not find anything return false; }
[ "public", "function", "getConnector", "(", "$", "name", ")", "{", "// Iterate over all connectors", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\ConnectorNode $connectorNode */", "foreach", "(", "$", "this", "->", "getConnectors", "(", ")", "as", "$", "connectorNode",...
Will return the connector node with the specified definition and if nothing could be found we will return false @param string $name The name of the connector in question @return \AppserverIo\Appserver\Core\Api\Node\ConnectorNode|boolean The requested connectors node
[ "Will", "return", "the", "connector", "node", "with", "the", "specified", "definition", "and", "if", "nothing", "could", "be", "found", "we", "will", "return", "false" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/ConnectorsNodeTrait.php#L63-L76
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/ConnectorsNodeTrait.php
ConnectorsNodeTrait.getConnectorsAsArray
public function getConnectorsAsArray() { // Iterate over the connectors nodes and sort them into an array $connectors = array(); /** @var \AppserverIo\Appserver\Core\Api\Node\ConnectorNode $connectorNode */ foreach ($this->getConnectors() as $connectorNode) { // Restructure to an array $connectors[] = array( 'name' => $connectorNode->getName(), 'type' => $connectorNode->getType(), 'params' => $connectorNode->getParamsAsArray() ); } // Return what we got return $connectors; }
php
public function getConnectorsAsArray() { // Iterate over the connectors nodes and sort them into an array $connectors = array(); /** @var \AppserverIo\Appserver\Core\Api\Node\ConnectorNode $connectorNode */ foreach ($this->getConnectors() as $connectorNode) { // Restructure to an array $connectors[] = array( 'name' => $connectorNode->getName(), 'type' => $connectorNode->getType(), 'params' => $connectorNode->getParamsAsArray() ); } // Return what we got return $connectors; }
[ "public", "function", "getConnectorsAsArray", "(", ")", "{", "// Iterate over the connectors nodes and sort them into an array", "$", "connectors", "=", "array", "(", ")", ";", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\ConnectorNode $connectorNode */", "foreach", "(", "$...
Returns the connectors as an associative array @return array The array with the sorted connectors
[ "Returns", "the", "connectors", "as", "an", "associative", "array" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/ConnectorsNodeTrait.php#L83-L99
appserver-io/appserver
src/AppserverIo/Appserver/Core/Modules/StorageProvider/SystemConfigurationResolverFactory.php
SystemConfigurationResolverFactory.factory
public static function factory(ServerContextInterface $serverContext, ModuleConfigurationInterface $moduleConfiguration) { // laod the system configuration from the server context $systemConfiguration = $serverContext->getContainer()->getInitialContext()->getSystemConfiguration(); // initialize the storage provider $storageProvider = new SystemConfigurationStorageProvider($systemConfiguration, $moduleConfiguration); // initialize the DNS resolver to load the DNS entries from the storage return new StackableResolver(array($storageProvider, new RecursiveProvider())); }
php
public static function factory(ServerContextInterface $serverContext, ModuleConfigurationInterface $moduleConfiguration) { // laod the system configuration from the server context $systemConfiguration = $serverContext->getContainer()->getInitialContext()->getSystemConfiguration(); // initialize the storage provider $storageProvider = new SystemConfigurationStorageProvider($systemConfiguration, $moduleConfiguration); // initialize the DNS resolver to load the DNS entries from the storage return new StackableResolver(array($storageProvider, new RecursiveProvider())); }
[ "public", "static", "function", "factory", "(", "ServerContextInterface", "$", "serverContext", ",", "ModuleConfigurationInterface", "$", "moduleConfiguration", ")", "{", "// laod the system configuration from the server context", "$", "systemConfiguration", "=", "$", "serverCo...
Factory method to create a new DNS resolver instance. @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server context for the resolver @param \AppserverIo\Server\Interfaces\ModuleConfigurationInterface $moduleConfiguration The module configuration with the initialization parameters @return \AppserverIo\DnsServer\Interfaces\StorageProviderInterface The initialized DNS resolver
[ "Factory", "method", "to", "create", "a", "new", "DNS", "resolver", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Modules/StorageProvider/SystemConfigurationResolverFactory.php#L48-L59
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractDeployment.php
AbstractDeployment.getDeploymentService
public function getDeploymentService() { if ($this->deploymentService == null) { $this->deploymentService = $this->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); } return $this->deploymentService; }
php
public function getDeploymentService() { if ($this->deploymentService == null) { $this->deploymentService = $this->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); } return $this->deploymentService; }
[ "public", "function", "getDeploymentService", "(", ")", "{", "if", "(", "$", "this", "->", "deploymentService", "==", "null", ")", "{", "$", "this", "->", "deploymentService", "=", "$", "this", "->", "newService", "(", "'AppserverIo\\Appserver\\Core\\Api\\Deployme...
Returns the deployment service instance. @return \AppserverIo\Appserver\Core\Api\DeploymentService The deployment service instance
[ "Returns", "the", "deployment", "service", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractDeployment.php#L93-L99
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractDeployment.php
AbstractDeployment.getConfigurationService
public function getConfigurationService() { if ($this->configurationService == null) { $this->configurationService = $this->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); } return $this->configurationService; }
php
public function getConfigurationService() { if ($this->configurationService == null) { $this->configurationService = $this->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); } return $this->configurationService; }
[ "public", "function", "getConfigurationService", "(", ")", "{", "if", "(", "$", "this", "->", "configurationService", "==", "null", ")", "{", "$", "this", "->", "configurationService", "=", "$", "this", "->", "newService", "(", "'AppserverIo\\Appserver\\Core\\Api\...
Returns the configuration service instance. @return \AppserverIo\Appserver\Core\Api\ConfigurationService The configuration service instance
[ "Returns", "the", "configuration", "service", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractDeployment.php#L106-L112
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractDeployment.php
AbstractDeployment.getDatasourceService
public function getDatasourceService() { if ($this->datasourceService == null) { $this->datasourceService = $this->newService('AppserverIo\Appserver\Core\Api\DatasourceService'); } return $this->datasourceService; }
php
public function getDatasourceService() { if ($this->datasourceService == null) { $this->datasourceService = $this->newService('AppserverIo\Appserver\Core\Api\DatasourceService'); } return $this->datasourceService; }
[ "public", "function", "getDatasourceService", "(", ")", "{", "if", "(", "$", "this", "->", "datasourceService", "==", "null", ")", "{", "$", "this", "->", "datasourceService", "=", "$", "this", "->", "newService", "(", "'AppserverIo\\Appserver\\Core\\Api\\Datasour...
Returns the datasource service instance. @return \AppserverIo\Appserver\Core\Api\DatasourceService The datasource service instance
[ "Returns", "the", "datasource", "service", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractDeployment.php#L119-L125
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletLocator.php
ServletLocator.locate
public function locate(ServletContextInterface $servletContext, $servletPath) { // iterate over all servlets and return the matching one foreach ($servletContext->getServletMappings() as $urlPattern => $servletName) { if (fnmatch($urlPattern, $servletPath)) { // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $servletContext->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // load the provider instance /** @var \AppserverIo\Psr\Di\ProviderInterface $provider */ $provider = $servletContext->getApplication()->search(ProviderInterface::IDENTIFIER); // load the object descriptor and re-inject the dependencies $provider->injectDependencies( $objectManager->getObjectDescriptor($servletName), $instance = $servletContext->getServlet($servletName) ); // finally return the instance return $instance; } } // throw an exception if no servlet matches the servlet path throw new ServletNotFoundException( sprintf('Can\'t find servlet for requested path "%s"', $servletPath) ); }
php
public function locate(ServletContextInterface $servletContext, $servletPath) { // iterate over all servlets and return the matching one foreach ($servletContext->getServletMappings() as $urlPattern => $servletName) { if (fnmatch($urlPattern, $servletPath)) { // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $servletContext->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // load the provider instance /** @var \AppserverIo\Psr\Di\ProviderInterface $provider */ $provider = $servletContext->getApplication()->search(ProviderInterface::IDENTIFIER); // load the object descriptor and re-inject the dependencies $provider->injectDependencies( $objectManager->getObjectDescriptor($servletName), $instance = $servletContext->getServlet($servletName) ); // finally return the instance return $instance; } } // throw an exception if no servlet matches the servlet path throw new ServletNotFoundException( sprintf('Can\'t find servlet for requested path "%s"', $servletPath) ); }
[ "public", "function", "locate", "(", "ServletContextInterface", "$", "servletContext", ",", "$", "servletPath", ")", "{", "// iterate over all servlets and return the matching one", "foreach", "(", "$", "servletContext", "->", "getServletMappings", "(", ")", "as", "$", ...
Tries to locate the resource related with the request. @param \AppserverIo\Psr\Servlet\ServletContextInterface $servletContext The servlet context that handles the servlets @param string $servletPath The servlet path to return the servlet for @return \AppserverIo\Psr\Servlet\ServletInterface The requested servlet @throws \AppserverIo\Appserver\ServletEngine\ServletNotFoundException Is thrown if no servlet can be found for the passed request @see \AppserverIo\Appserver\ServletEngine\ServletLocator::locate()
[ "Tries", "to", "locate", "the", "resource", "related", "with", "the", "request", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletLocator.php#L49-L78
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/ServerNode.php
ServerNode.merge
public function merge(ServerNodeInterface $serverNode) { // append the certificate nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\CertificateNode $certificate */ foreach ($serverNode->getCertificates() as $certificate) { $this->certificates[] = $certificate; } // append the virtual host nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\VirtualHostNode $virtualHost */ foreach ($serverNode->getVirtualHosts() as $virtualHost) { $this->virtualHosts[] = $virtualHost; } // append the location nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\LocationNode $location */ foreach ($serverNode->getLocations() as $location) { $this->locations[] = $location; } // append the environment variable nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\EnvironmentVariableNode $environmentVariable */ foreach ($serverNode->getEnvironmentVariables() as $environmentVariable) { $this->environmentVariables[] = $environmentVariable; } // append the rewrite nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\RewriteNode $rewrite */ foreach ($serverNode->getRewrites() as $rewrite) { $this->rewrites[] = $rewrite; } // append the access nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\AccessNode $access */ foreach ($serverNode->getAccesses() as $access) { $this->accesses[] = $access; } }
php
public function merge(ServerNodeInterface $serverNode) { // append the certificate nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\CertificateNode $certificate */ foreach ($serverNode->getCertificates() as $certificate) { $this->certificates[] = $certificate; } // append the virtual host nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\VirtualHostNode $virtualHost */ foreach ($serverNode->getVirtualHosts() as $virtualHost) { $this->virtualHosts[] = $virtualHost; } // append the location nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\LocationNode $location */ foreach ($serverNode->getLocations() as $location) { $this->locations[] = $location; } // append the environment variable nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\EnvironmentVariableNode $environmentVariable */ foreach ($serverNode->getEnvironmentVariables() as $environmentVariable) { $this->environmentVariables[] = $environmentVariable; } // append the rewrite nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\RewriteNode $rewrite */ foreach ($serverNode->getRewrites() as $rewrite) { $this->rewrites[] = $rewrite; } // append the access nodes found in the passed server node /** @var \AppserverIo\Appserver\Core\Api\Node\AccessNode $access */ foreach ($serverNode->getAccesses() as $access) { $this->accesses[] = $access; } }
[ "public", "function", "merge", "(", "ServerNodeInterface", "$", "serverNode", ")", "{", "// append the certificate nodes found in the passed server node", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\CertificateNode $certificate */", "foreach", "(", "$", "serverNode", "->", "...
This method merges the passed server node into this one. @param \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $serverNode The server node to merge @return void
[ "This", "method", "merges", "the", "passed", "server", "node", "into", "this", "one", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/ServerNode.php#L307-L345
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/MessageQueueValve.php
MessageQueueValve.invoke
public function invoke(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) { // load the application context /** @var \AppserverIo\Appserver\Application\Application $application */ $application = $servletRequest->getContext(); // unpack the message $message = MessageQueueProtocol::unpack($servletRequest->getBodyContent()); // load message queue name $queueName = $message->getDestination()->getName(); // lookup the message queue manager and attach the message $queueManager = $application->search(QueueContextInterface::IDENTIFIER); if ($messageQueue = $queueManager->lookup($queueName)) { $messageQueue->attach($message); } else { throw new \Exception("Can\'t find queue for message queue $queueName"); } // finally dispatch this request, because we have finished processing it $servletRequest->setDispatched(true); }
php
public function invoke(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) { // load the application context /** @var \AppserverIo\Appserver\Application\Application $application */ $application = $servletRequest->getContext(); // unpack the message $message = MessageQueueProtocol::unpack($servletRequest->getBodyContent()); // load message queue name $queueName = $message->getDestination()->getName(); // lookup the message queue manager and attach the message $queueManager = $application->search(QueueContextInterface::IDENTIFIER); if ($messageQueue = $queueManager->lookup($queueName)) { $messageQueue->attach($message); } else { throw new \Exception("Can\'t find queue for message queue $queueName"); } // finally dispatch this request, because we have finished processing it $servletRequest->setDispatched(true); }
[ "public", "function", "invoke", "(", "HttpServletRequestInterface", "$", "servletRequest", ",", "HttpServletResponseInterface", "$", "servletResponse", ")", "{", "// load the application context", "/** @var \\AppserverIo\\Appserver\\Application\\Application $application */", "$", "ap...
Processes the request by invoking the request handler that attaches the message to the requested queue in a protected context. @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The response instance @return void @throws \Exception Is thrown if the requested message queue is not available
[ "Processes", "the", "request", "by", "invoking", "the", "request", "handler", "that", "attaches", "the", "message", "to", "the", "requested", "queue", "in", "a", "protected", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/MessageQueue/MessageQueueValve.php#L52-L75
appserver-io/appserver
RoboFile.php
RoboFile.prepare
public function prepare() { $this->taskFileSystemStack() ->mkdir($this->getDistDir()) ->mkdir($this->getTargetDir()) ->mkdir($this->getReportsDir()) ->run(); }
php
public function prepare() { $this->taskFileSystemStack() ->mkdir($this->getDistDir()) ->mkdir($this->getTargetDir()) ->mkdir($this->getReportsDir()) ->run(); }
[ "public", "function", "prepare", "(", ")", "{", "$", "this", "->", "taskFileSystemStack", "(", ")", "->", "mkdir", "(", "$", "this", "->", "getDistDir", "(", ")", ")", "->", "mkdir", "(", "$", "this", "->", "getTargetDir", "(", ")", ")", "->", "mkdir...
Prepare's the environment for a new build. @return void
[ "Prepare", "s", "the", "environment", "for", "a", "new", "build", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/RoboFile.php#L102-L109
appserver-io/appserver
RoboFile.php
RoboFile.runMd
public function runMd() { // run the mess detector $this->_exec( sprintf( '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit || exit 0', $this->getVendorDir(), $this->getSrcDir(), $this->getTargetDir() ) ); }
php
public function runMd() { // run the mess detector $this->_exec( sprintf( '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit || exit 0', $this->getVendorDir(), $this->getSrcDir(), $this->getTargetDir() ) ); }
[ "public", "function", "runMd", "(", ")", "{", "// run the mess detector", "$", "this", "->", "_exec", "(", "sprintf", "(", "'%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit || exit 0'", ",", "$", "this", "->", "getVendorDir", "(", "...
Run's the PHPMD. @return void
[ "Run", "s", "the", "PHPMD", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/RoboFile.php#L116-L128
appserver-io/appserver
RoboFile.php
RoboFile.runCpd
public function runCpd() { // run the copy past detector $this->_exec( sprintf( '%s/bin/phpcpd --names-exclude=DirectoryParser.php,EntityManagerFactory.php,QueueManager.php %s --log-pmd %s/reports/pmd-cpd.xml', $this->getVendorDir(), $this->getSrcDir(), $this->getTargetDir() ) ); }
php
public function runCpd() { // run the copy past detector $this->_exec( sprintf( '%s/bin/phpcpd --names-exclude=DirectoryParser.php,EntityManagerFactory.php,QueueManager.php %s --log-pmd %s/reports/pmd-cpd.xml', $this->getVendorDir(), $this->getSrcDir(), $this->getTargetDir() ) ); }
[ "public", "function", "runCpd", "(", ")", "{", "// run the copy past detector", "$", "this", "->", "_exec", "(", "sprintf", "(", "'%s/bin/phpcpd --names-exclude=DirectoryParser.php,EntityManagerFactory.php,QueueManager.php %s --log-pmd %s/reports/pmd-cpd.xml'", ",", "$", "this", ...
Run's the PHPCPD. @return void
[ "Run", "s", "the", "PHPCPD", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/RoboFile.php#L135-L147
appserver-io/appserver
RoboFile.php
RoboFile.runCs
public function runCs() { // run the code sniffer $this->_exec( sprintf( '%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s', $this->getVendorDir(), $this->getTargetDir(), $this->getSrcDir() ) ); }
php
public function runCs() { // run the code sniffer $this->_exec( sprintf( '%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s', $this->getVendorDir(), $this->getTargetDir(), $this->getSrcDir() ) ); }
[ "public", "function", "runCs", "(", ")", "{", "// run the code sniffer", "$", "this", "->", "_exec", "(", "sprintf", "(", "'%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s'", ",", "$", "this", "->", "getVendorDir",...
Run's the PHPCodeSniffer. @return void
[ "Run", "s", "the", "PHPCodeSniffer", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/RoboFile.php#L154-L166
appserver-io/appserver
RoboFile.php
RoboFile.build
public function build() { $this->clean(); $this->prepare(); $this->runCs(); $this->runCpd(); $this->runMd(); $this->runTests(); }
php
public function build() { $this->clean(); $this->prepare(); $this->runCs(); $this->runCpd(); $this->runMd(); $this->runTests(); }
[ "public", "function", "build", "(", ")", "{", "$", "this", "->", "clean", "(", ")", ";", "$", "this", "->", "prepare", "(", ")", ";", "$", "this", "->", "runCs", "(", ")", ";", "$", "this", "->", "runCpd", "(", ")", ";", "$", "this", "->", "r...
The complete build process. @return void
[ "The", "complete", "build", "process", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/RoboFile.php#L187-L195
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/SimplePrincipal.php
SimplePrincipal.equals
public function equals(PrincipalInterface $another) { // query whether or not another principal has been passed if ($another instanceof PrincipalInterface) { $anotherName = $another->getName(); $equals = false; if ($this->name == null) { $equals = $anotherName == null; } else { $equals = $this->name->equals($anotherName); } // return the flag if the both are equal return $equals; } // return FALSE if they are not equal return false; }
php
public function equals(PrincipalInterface $another) { // query whether or not another principal has been passed if ($another instanceof PrincipalInterface) { $anotherName = $another->getName(); $equals = false; if ($this->name == null) { $equals = $anotherName == null; } else { $equals = $this->name->equals($anotherName); } // return the flag if the both are equal return $equals; } // return FALSE if they are not equal return false; }
[ "public", "function", "equals", "(", "PrincipalInterface", "$", "another", ")", "{", "// query whether or not another principal has been passed", "if", "(", "$", "another", "instanceof", "PrincipalInterface", ")", "{", "$", "anotherName", "=", "$", "another", "->", "g...
Compare this SimplePrincipal's name against another Principal. @param \AppserverIo\Psr\Security\PrincipalInterface $another The other principal to compare to @return boolean TRUE if name equals $another->getName();
[ "Compare", "this", "SimplePrincipal", "s", "name", "against", "another", "Principal", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/SimplePrincipal.php#L63-L82
appserver-io/appserver
src/AppserverIo/Appserver/Core/Listeners/StopServicesListener.php
StopServicesListener.handle
public function handle(EventInterface $event) { try { $this->getApplicationServer()->getSystemLogger()->info($event->getName()); } catch (\Exception $e) { $this->getApplicationServer()->getSystemLogger()->error($e->__toString()); } }
php
public function handle(EventInterface $event) { try { $this->getApplicationServer()->getSystemLogger()->info($event->getName()); } catch (\Exception $e) { $this->getApplicationServer()->getSystemLogger()->error($e->__toString()); } }
[ "public", "function", "handle", "(", "EventInterface", "$", "event", ")", "{", "try", "{", "$", "this", "->", "getApplicationServer", "(", ")", "->", "getSystemLogger", "(", ")", "->", "info", "(", "$", "event", "->", "getName", "(", ")", ")", ";", "}"...
Handle an event. @param \League\Event\EventInterface $event The triggering event @return void @see \League\Event\ListenerInterface::handle()
[ "Handle", "an", "event", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Listeners/StopServicesListener.php#L45-L52
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/DirectoryKeys.php
DirectoryKeys.getServerDirectoryKeysToBeCreated
public static function getServerDirectoryKeysToBeCreated() { return array( DirectoryKeys::TMP, DirectoryKeys::DEPLOY, DirectoryKeys::WEBAPPS, DirectoryKeys::VAR_TMP, DirectoryKeys::VAR_LOG, DirectoryKeys::VAR_RUN, DirectoryKeys::ETC, DirectoryKeys::ETC_APPSERVER, DirectoryKeys::ETC_APPSERVER_CONFD ); }
php
public static function getServerDirectoryKeysToBeCreated() { return array( DirectoryKeys::TMP, DirectoryKeys::DEPLOY, DirectoryKeys::WEBAPPS, DirectoryKeys::VAR_TMP, DirectoryKeys::VAR_LOG, DirectoryKeys::VAR_RUN, DirectoryKeys::ETC, DirectoryKeys::ETC_APPSERVER, DirectoryKeys::ETC_APPSERVER_CONFD ); }
[ "public", "static", "function", "getServerDirectoryKeysToBeCreated", "(", ")", "{", "return", "array", "(", "DirectoryKeys", "::", "TMP", ",", "DirectoryKeys", "::", "DEPLOY", ",", "DirectoryKeys", "::", "WEBAPPS", ",", "DirectoryKeys", "::", "VAR_TMP", ",", "Dire...
Returns the application servers directory keys for the directories that has to be created on startup. @return array The keys for the directories to be created on startup
[ "Returns", "the", "application", "servers", "directory", "keys", "for", "the", "directories", "that", "has", "to", "be", "created", "on", "startup", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/DirectoryKeys.php#L157-L170
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/DirectoryKeys.php
DirectoryKeys.getServerDirectoryKeys
public static function getServerDirectoryKeys() { return array( DirectoryKeys::BASE, DirectoryKeys::TMP, DirectoryKeys::DEPLOY, DirectoryKeys::WEBAPPS, DirectoryKeys::VAR_TMP, DirectoryKeys::VAR_LOG, DirectoryKeys::VAR_RUN, DirectoryKeys::ETC, DirectoryKeys::ETC_APPSERVER, DirectoryKeys::ETC_APPSERVER_CONFD ); }
php
public static function getServerDirectoryKeys() { return array( DirectoryKeys::BASE, DirectoryKeys::TMP, DirectoryKeys::DEPLOY, DirectoryKeys::WEBAPPS, DirectoryKeys::VAR_TMP, DirectoryKeys::VAR_LOG, DirectoryKeys::VAR_RUN, DirectoryKeys::ETC, DirectoryKeys::ETC_APPSERVER, DirectoryKeys::ETC_APPSERVER_CONFD ); }
[ "public", "static", "function", "getServerDirectoryKeys", "(", ")", "{", "return", "array", "(", "DirectoryKeys", "::", "BASE", ",", "DirectoryKeys", "::", "TMP", ",", "DirectoryKeys", "::", "DEPLOY", ",", "DirectoryKeys", "::", "WEBAPPS", ",", "DirectoryKeys", ...
Returns the all application servers directory keys. @return array All application server directory keys
[ "Returns", "the", "all", "application", "servers", "directory", "keys", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/DirectoryKeys.php#L188-L202
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.singleton
public static function singleton(NamingDirectoryInterface $namingDirectory, GenericStackable $runlevels) { // query whether we already have an instance or not if (ApplicationServer::$instance == null) { // initialize and start the application server ApplicationServer::$instance = new ApplicationServer($namingDirectory, $runlevels); ApplicationServer::$instance->start(); } // return the instance return ApplicationServer::$instance; }
php
public static function singleton(NamingDirectoryInterface $namingDirectory, GenericStackable $runlevels) { // query whether we already have an instance or not if (ApplicationServer::$instance == null) { // initialize and start the application server ApplicationServer::$instance = new ApplicationServer($namingDirectory, $runlevels); ApplicationServer::$instance->start(); } // return the instance return ApplicationServer::$instance; }
[ "public", "static", "function", "singleton", "(", "NamingDirectoryInterface", "$", "namingDirectory", ",", "GenericStackable", "$", "runlevels", ")", "{", "// query whether we already have an instance or not", "if", "(", "ApplicationServer", "::", "$", "instance", "==", "...
Creates a new singleton application server instance. @param \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory The default naming directory @param \AppserverIo\Storage\GenericStackable $runlevels The storage for the services @return \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface The singleton application instance
[ "Creates", "a", "new", "singleton", "application", "server", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L92-L104
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.runlevelToString
public function runlevelToString($runlevel) { // flip the array with the string => integer runlevel definitions $runlevels = array_flip(Runlevels::singleton()->getRunlevels()); if (isset($runlevels[$runlevel])) { return $runlevels[$runlevel]; } // throw an exception if the runlevel is unknown throw new \Exception(sprintf('Request invalid runlevel to string conversion for %s', $runlevel)); }
php
public function runlevelToString($runlevel) { // flip the array with the string => integer runlevel definitions $runlevels = array_flip(Runlevels::singleton()->getRunlevels()); if (isset($runlevels[$runlevel])) { return $runlevels[$runlevel]; } // throw an exception if the runlevel is unknown throw new \Exception(sprintf('Request invalid runlevel to string conversion for %s', $runlevel)); }
[ "public", "function", "runlevelToString", "(", "$", "runlevel", ")", "{", "// flip the array with the string => integer runlevel definitions", "$", "runlevels", "=", "array_flip", "(", "Runlevels", "::", "singleton", "(", ")", "->", "getRunlevels", "(", ")", ")", ";",...
Translates and returns a string representation of the passed runlevel. @param integer $runlevel The runlevel to return the string representation for @return string The string representation for the passed runlevel @throws \Exception Is thrown if the passed runlevel is not available
[ "Translates", "and", "returns", "a", "string", "representation", "of", "the", "passed", "runlevel", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L115-L126
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.runlevelFromString
public function runlevelFromString($runlevel) { // query whether the passed string representation is a valid runlevel if (Runlevels::singleton()->isRunlevel($runlevel)) { return Runlevels::singleton()->getRunlevel($runlevel); } // throw an exception if the runlevel is unknown throw new \Exception(sprintf('Request invalid runlevel to string conversion for %s', $runlevel)); }
php
public function runlevelFromString($runlevel) { // query whether the passed string representation is a valid runlevel if (Runlevels::singleton()->isRunlevel($runlevel)) { return Runlevels::singleton()->getRunlevel($runlevel); } // throw an exception if the runlevel is unknown throw new \Exception(sprintf('Request invalid runlevel to string conversion for %s', $runlevel)); }
[ "public", "function", "runlevelFromString", "(", "$", "runlevel", ")", "{", "// query whether the passed string representation is a valid runlevel", "if", "(", "Runlevels", "::", "singleton", "(", ")", "->", "isRunlevel", "(", "$", "runlevel", ")", ")", "{", "return",...
Translates and returns the runlevel of the passed a string representation. @param string $runlevel The string representation of the runlevel to return @return integer The runlevel of the passed string representation @throws \Exception Is thrown if the passed string representation is not a valid runlevel
[ "Translates", "and", "returns", "the", "runlevel", "of", "the", "passed", "a", "string", "representation", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L137-L147
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.init
public function init(ConnectionInterface $conn = null, $runlevel = ApplicationServerInterface::FULL) { // switch to the new runlevel $this->synchronized(function ($self, $newRunlevel) { // wait till the previous commands has been finished while ($self->locked === true) { sleep(1); } // set the command name $self->command = InitCommand::COMMAND; // lock process $self->locked = true; $self->params = $newRunlevel; // notify the AS to execute the command $self->notify(); }, $this, $runlevel); }
php
public function init(ConnectionInterface $conn = null, $runlevel = ApplicationServerInterface::FULL) { // switch to the new runlevel $this->synchronized(function ($self, $newRunlevel) { // wait till the previous commands has been finished while ($self->locked === true) { sleep(1); } // set the command name $self->command = InitCommand::COMMAND; // lock process $self->locked = true; $self->params = $newRunlevel; // notify the AS to execute the command $self->notify(); }, $this, $runlevel); }
[ "public", "function", "init", "(", "ConnectionInterface", "$", "conn", "=", "null", ",", "$", "runlevel", "=", "ApplicationServerInterface", "::", "FULL", ")", "{", "// switch to the new runlevel", "$", "this", "->", "synchronized", "(", "function", "(", "$", "s...
The runlevel to switch to. @param \React\Socket\ConnectionInterface $conn The connection resource @param integer $runlevel The new runlevel to switch to @return void
[ "The", "runlevel", "to", "switch", "to", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L295-L316
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.mode
public function mode(ConnectionInterface $conn, $mode) { // switch to the new runlevel $this->synchronized(function ($self, $newMode) { // wait till the previous commands has been finished while ($self->locked === true) { sleep(1); } // set the command name $self->command = ModeCommand::COMMAND; // lock process $self->locked = true; $self->params = $newMode; // notify the AS to execute the command $self->notify(); }, $this, $mode); }
php
public function mode(ConnectionInterface $conn, $mode) { // switch to the new runlevel $this->synchronized(function ($self, $newMode) { // wait till the previous commands has been finished while ($self->locked === true) { sleep(1); } // set the command name $self->command = ModeCommand::COMMAND; // lock process $self->locked = true; $self->params = $newMode; // notify the AS to execute the command $self->notify(); }, $this, $mode); }
[ "public", "function", "mode", "(", "ConnectionInterface", "$", "conn", ",", "$", "mode", ")", "{", "// switch to the new runlevel", "$", "this", "->", "synchronized", "(", "function", "(", "$", "self", ",", "$", "newMode", ")", "{", "// wait till the previous co...
Switch to the passed mode, which can either be 'dev', 'prod' or 'install'. @param \React\Socket\ConnectionInterface $conn The connection resource @param string $mode The setup mode to switch to @return void
[ "Switch", "to", "the", "passed", "mode", "which", "can", "either", "be", "dev", "prod", "or", "install", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L326-L347
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.shutdown
public function shutdown() { // check if there was a fatal error caused shutdown if ($lastError = error_get_last()) { // initialize type + message $type = 0; $message = ''; // extract the last error values extract($lastError); // query whether we've a fatal/user error if ($type === E_ERROR || $type === E_USER_ERROR) { error_log($message); } } }
php
public function shutdown() { // check if there was a fatal error caused shutdown if ($lastError = error_get_last()) { // initialize type + message $type = 0; $message = ''; // extract the last error values extract($lastError); // query whether we've a fatal/user error if ($type === E_ERROR || $type === E_USER_ERROR) { error_log($message); } } }
[ "public", "function", "shutdown", "(", ")", "{", "// check if there was a fatal error caused shutdown", "if", "(", "$", "lastError", "=", "error_get_last", "(", ")", ")", "{", "// initialize type + message", "$", "type", "=", "0", ";", "$", "message", "=", "''", ...
Shutdown handler that checks for fatal/user errors. @return void
[ "Shutdown", "handler", "that", "checks", "for", "fatal", "/", "user", "errors", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L369-L383
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.run
public function run() { // register a shutdown handler for controlled shutdown register_shutdown_function(array(&$this, 'shutdown')); // we need the autloader again require SERVER_AUTOLOADER; // create the service emitter $emitter = new Emitter(); // load the bootstrap configuration /** @var \AppserverIo\Appserver\Core\Api\Node\BootstrapNodeInterface $bootstrapNode */ $bootstrapNode = $this->doLoadBootstrap($this->getBootstrapConfigurationFilename()); // iterate over the listeners and add them to the emitter /** @var \AppserverIo\Appserver\Core\Api\Node\ListenerNodeInterface $listener */ foreach ($bootstrapNode->getListeners() as $listener) { // load the listener class name $listenerClassName = $listener->getType(); // create a new instance of the listener class /** @var \League\Event\ListenerInterface $listenerInstance */ $listenerInstance = new $listenerClassName(); // query whether we've to inject the application server instance or not if ($listenerInstance instanceof ApplicationServerAwareListenerInterface) { $listenerInstance->injectApplicationServer($this); } // add the listeners $emitter->addListener($listener->getEvent(), $listenerInstance); } // synchronize the emitter $this->emitter = $emitter; // override the default runlevel with the value found in the bootstrap configuration $this->runlevel = $this->runlevelFromString($bootstrapNode->getDefaultRunlevel()); // flag to keep the server running or to stop it $keepRunning = true; // initialize the actual runlevel with -1 $actualRunlevel = -1; // start with the default runlevel $this->init(null, $this->runlevel); do { try { switch ($this->command) { case InitCommand::COMMAND: // copy command params -> the requested runlevel in that case $this->runlevel = $this->params; if ($this->runlevel == ApplicationServerInterface::REBOOT) { // backup the runlevel $backupRunlevel = $actualRunlevel; // shutdown the application server for ($i = $actualRunlevel; $i >= ApplicationServerInterface::SHUTDOWN; $i--) { $this->emitter->emit(sprintf('leave.runlevel.%s', $this->runlevelToString($i)), $i); // stop the services of the PREVIOUS runlevel $this->doStopServices($i + 1); } // switch back to the runlevel we backed up before for ($z = ApplicationServerInterface::SHUTDOWN; $z <= $backupRunlevel; $z++) { $this->emitter->emit(sprintf('enter.runlevel.%s', $this->runlevelToString($z)), $z); } // set the runlevel to the one before we restart $actualRunlevel = $backupRunlevel; // reset the runlevel and the params $this->runlevel = $this->params = $actualRunlevel; } elseif ($actualRunlevel == ApplicationServerInterface::SHUTDOWN) { // we want to shutdown the application server $keepRunning = false; } elseif ($actualRunlevel < $this->runlevel) { // switch to the requested runlevel for ($i = $actualRunlevel + 1; $i <= $this->runlevel; $i++) { $this->emitter->emit(sprintf('enter.runlevel.%s', $this->runlevelToString($i)), $i); } // set the new runlevel $actualRunlevel = $this->runlevel; } elseif ($actualRunlevel > $this->runlevel) { // switch down to the requested runlevel for ($i = $actualRunlevel; $i >= $this->runlevel; $i--) { $this->emitter->emit(sprintf('leave.runlevel.%s', $this->runlevelToString($i)), $i); // stop the services of the PREVIOUS runlevel $this->doStopServices($i + 1); } // set the new runlevel $actualRunlevel = $this->runlevel; } else { // signal that we've finished switching the runlevels and wait $this->locked = false; $this->command = null; // print a message and wait $this->getSystemLogger()->info(sprintf('Switched to runlevel %s!!!', $actualRunlevel)); // wait for a new command $this->synchronized(function ($self) { $self->wait(); }, $this); } break; case ModeCommand::COMMAND: // switch the application server mode $this->doSwitchSetupMode($this->params, $this->getConfigurationFilename()); // singal that we've finished setting umask and wait $this->locked = false; $this->command = null; // wait for a new command $this->synchronized(function ($self) { $self->wait(); }, $this); break; default: // print a message and wait $this->getSystemLogger()->info('Can\'t find any command!!!'); // singal that we've finished setting umask and wait $this->locked = false; // wait for a new command $this->synchronized(function ($self) { $self->wait(); }, $this); break; } } catch (\Exception $e) { $this->getSystemLogger()->error($e->getMessage()); } } while ($keepRunning); }
php
public function run() { // register a shutdown handler for controlled shutdown register_shutdown_function(array(&$this, 'shutdown')); // we need the autloader again require SERVER_AUTOLOADER; // create the service emitter $emitter = new Emitter(); // load the bootstrap configuration /** @var \AppserverIo\Appserver\Core\Api\Node\BootstrapNodeInterface $bootstrapNode */ $bootstrapNode = $this->doLoadBootstrap($this->getBootstrapConfigurationFilename()); // iterate over the listeners and add them to the emitter /** @var \AppserverIo\Appserver\Core\Api\Node\ListenerNodeInterface $listener */ foreach ($bootstrapNode->getListeners() as $listener) { // load the listener class name $listenerClassName = $listener->getType(); // create a new instance of the listener class /** @var \League\Event\ListenerInterface $listenerInstance */ $listenerInstance = new $listenerClassName(); // query whether we've to inject the application server instance or not if ($listenerInstance instanceof ApplicationServerAwareListenerInterface) { $listenerInstance->injectApplicationServer($this); } // add the listeners $emitter->addListener($listener->getEvent(), $listenerInstance); } // synchronize the emitter $this->emitter = $emitter; // override the default runlevel with the value found in the bootstrap configuration $this->runlevel = $this->runlevelFromString($bootstrapNode->getDefaultRunlevel()); // flag to keep the server running or to stop it $keepRunning = true; // initialize the actual runlevel with -1 $actualRunlevel = -1; // start with the default runlevel $this->init(null, $this->runlevel); do { try { switch ($this->command) { case InitCommand::COMMAND: // copy command params -> the requested runlevel in that case $this->runlevel = $this->params; if ($this->runlevel == ApplicationServerInterface::REBOOT) { // backup the runlevel $backupRunlevel = $actualRunlevel; // shutdown the application server for ($i = $actualRunlevel; $i >= ApplicationServerInterface::SHUTDOWN; $i--) { $this->emitter->emit(sprintf('leave.runlevel.%s', $this->runlevelToString($i)), $i); // stop the services of the PREVIOUS runlevel $this->doStopServices($i + 1); } // switch back to the runlevel we backed up before for ($z = ApplicationServerInterface::SHUTDOWN; $z <= $backupRunlevel; $z++) { $this->emitter->emit(sprintf('enter.runlevel.%s', $this->runlevelToString($z)), $z); } // set the runlevel to the one before we restart $actualRunlevel = $backupRunlevel; // reset the runlevel and the params $this->runlevel = $this->params = $actualRunlevel; } elseif ($actualRunlevel == ApplicationServerInterface::SHUTDOWN) { // we want to shutdown the application server $keepRunning = false; } elseif ($actualRunlevel < $this->runlevel) { // switch to the requested runlevel for ($i = $actualRunlevel + 1; $i <= $this->runlevel; $i++) { $this->emitter->emit(sprintf('enter.runlevel.%s', $this->runlevelToString($i)), $i); } // set the new runlevel $actualRunlevel = $this->runlevel; } elseif ($actualRunlevel > $this->runlevel) { // switch down to the requested runlevel for ($i = $actualRunlevel; $i >= $this->runlevel; $i--) { $this->emitter->emit(sprintf('leave.runlevel.%s', $this->runlevelToString($i)), $i); // stop the services of the PREVIOUS runlevel $this->doStopServices($i + 1); } // set the new runlevel $actualRunlevel = $this->runlevel; } else { // signal that we've finished switching the runlevels and wait $this->locked = false; $this->command = null; // print a message and wait $this->getSystemLogger()->info(sprintf('Switched to runlevel %s!!!', $actualRunlevel)); // wait for a new command $this->synchronized(function ($self) { $self->wait(); }, $this); } break; case ModeCommand::COMMAND: // switch the application server mode $this->doSwitchSetupMode($this->params, $this->getConfigurationFilename()); // singal that we've finished setting umask and wait $this->locked = false; $this->command = null; // wait for a new command $this->synchronized(function ($self) { $self->wait(); }, $this); break; default: // print a message and wait $this->getSystemLogger()->info('Can\'t find any command!!!'); // singal that we've finished setting umask and wait $this->locked = false; // wait for a new command $this->synchronized(function ($self) { $self->wait(); }, $this); break; } } catch (\Exception $e) { $this->getSystemLogger()->error($e->getMessage()); } } while ($keepRunning); }
[ "public", "function", "run", "(", ")", "{", "// register a shutdown handler for controlled shutdown", "register_shutdown_function", "(", "array", "(", "&", "$", "this", ",", "'shutdown'", ")", ")", ";", "// we need the autloader again", "require", "SERVER_AUTOLOADER", ";"...
The thread's run() method that runs asynchronously. @return void @link http://www.php.net/manual/en/thread.run.php
[ "The", "thread", "s", "run", "()", "method", "that", "runs", "asynchronously", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L391-L547
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.unbindService
public function unbindService($runlevel, $name) { // stop the service instance $this->runlevels[$runlevel][$name]->stop(); // unbind the service from the naming directory $this->getNamingDirectory()->unbind(sprintf('php:services/%s/%s', $this->runlevelToString($runlevel), $name)); // unset the service instance unset($this->runlevels[$runlevel][$name]); // print a message that the service has been stopped $this->getSystemLogger()->info(sprintf('Successfully stopped service %s', $name)); }
php
public function unbindService($runlevel, $name) { // stop the service instance $this->runlevels[$runlevel][$name]->stop(); // unbind the service from the naming directory $this->getNamingDirectory()->unbind(sprintf('php:services/%s/%s', $this->runlevelToString($runlevel), $name)); // unset the service instance unset($this->runlevels[$runlevel][$name]); // print a message that the service has been stopped $this->getSystemLogger()->info(sprintf('Successfully stopped service %s', $name)); }
[ "public", "function", "unbindService", "(", "$", "runlevel", ",", "$", "name", ")", "{", "// stop the service instance", "$", "this", "->", "runlevels", "[", "$", "runlevel", "]", "[", "$", "name", "]", "->", "stop", "(", ")", ";", "// unbind the service fro...
Unbind the service with the passed name and runlevel. @param integer $runlevel The runlevel of the service @param string $name The name of the service @return void
[ "Unbind", "the", "service", "with", "the", "passed", "name", "and", "runlevel", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L570-L584
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.bindService
public function bindService($runlevel, $service) { // bind the service to the runlevel $this->runlevels[$runlevel][$service->getName()] = $service; // bind the service callback to the naming directory $this->getNamingDirectory()->bindCallback( sprintf('php:services/%s/%s', $this->runlevelToString($runlevel), $service->getName()), array(&$this, 'getService'), array($runlevel, $service->getName()) ); }
php
public function bindService($runlevel, $service) { // bind the service to the runlevel $this->runlevels[$runlevel][$service->getName()] = $service; // bind the service callback to the naming directory $this->getNamingDirectory()->bindCallback( sprintf('php:services/%s/%s', $this->runlevelToString($runlevel), $service->getName()), array(&$this, 'getService'), array($runlevel, $service->getName()) ); }
[ "public", "function", "bindService", "(", "$", "runlevel", ",", "$", "service", ")", "{", "// bind the service to the runlevel", "$", "this", "->", "runlevels", "[", "$", "runlevel", "]", "[", "$", "service", "->", "getName", "(", ")", "]", "=", "$", "serv...
Binds the passed service to the runlevel. @param integer $runlevel The runlevel to bound the service to @param object $service The service to bound @return void
[ "Binds", "the", "passed", "service", "to", "the", "runlevel", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L594-L606
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.doStopServices
protected function doStopServices($runlevel) { // iterate over all services and stop them foreach (array_flip($this->runlevels[$runlevel]) as $name) { $this->unbindService($runlevel, $name); } }
php
protected function doStopServices($runlevel) { // iterate over all services and stop them foreach (array_flip($this->runlevels[$runlevel]) as $name) { $this->unbindService($runlevel, $name); } }
[ "protected", "function", "doStopServices", "(", "$", "runlevel", ")", "{", "// iterate over all services and stop them", "foreach", "(", "array_flip", "(", "$", "this", "->", "runlevels", "[", "$", "runlevel", "]", ")", "as", "$", "name", ")", "{", "$", "this"...
Stops all services of the passed runlevel. @param integer $runlevel The runlevel to stop all services for @return void
[ "Stops", "all", "services", "of", "the", "passed", "runlevel", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L645-L651
appserver-io/appserver
src/AppserverIo/Appserver/Core/ApplicationServer.php
ApplicationServer.doSwitchSetupMode
protected function doSwitchSetupMode($newMode, $configurationFilename) { // load the current user from the naming directory $currentUser = $this->getNamingDirectory()->search('php:env/currentUser'); // load the service instance and switch to the new setup mode /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */ $service = $this->newService('AppserverIo\Appserver\Core\Api\ContainerService'); $service->switchSetupMode($newMode, $configurationFilename, $currentUser); }
php
protected function doSwitchSetupMode($newMode, $configurationFilename) { // load the current user from the naming directory $currentUser = $this->getNamingDirectory()->search('php:env/currentUser'); // load the service instance and switch to the new setup mode /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */ $service = $this->newService('AppserverIo\Appserver\Core\Api\ContainerService'); $service->switchSetupMode($newMode, $configurationFilename, $currentUser); }
[ "protected", "function", "doSwitchSetupMode", "(", "$", "newMode", ",", "$", "configurationFilename", ")", "{", "// load the current user from the naming directory", "$", "currentUser", "=", "$", "this", "->", "getNamingDirectory", "(", ")", "->", "search", "(", "'php...
Switches the running setup mode to the passed value. @param string $newMode The mode to switch to @param string $configurationFilename The path of the configuration filename @return void @throws \Exception Is thrown for an invalid setup mode passed
[ "Switches", "the", "running", "setup", "mode", "to", "the", "passed", "value", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ApplicationServer.php#L662-L671
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/SessionWrapper.php
SessionWrapper.start
public function start() { // we need the session to be started if ($this->isStarted()) { return; } // create a new cookie with the session values $cookie = new HttpCookie( $this->getName(), $this->getId(), $this->getLifetime(), $this->getMaximumAge(), $this->getDomain(), $this->getPath(), $this->isSecure(), $this->isHttpOnly() ); // start the session and set the started flag $this->getSession()->start(); // add the cookie to the response $this->getRequest()->setRequestedSessionId($this->getId()); $this->getResponse()->addCookie($cookie); }
php
public function start() { // we need the session to be started if ($this->isStarted()) { return; } // create a new cookie with the session values $cookie = new HttpCookie( $this->getName(), $this->getId(), $this->getLifetime(), $this->getMaximumAge(), $this->getDomain(), $this->getPath(), $this->isSecure(), $this->isHttpOnly() ); // start the session and set the started flag $this->getSession()->start(); // add the cookie to the response $this->getRequest()->setRequestedSessionId($this->getId()); $this->getResponse()->addCookie($cookie); }
[ "public", "function", "start", "(", ")", "{", "// we need the session to be started", "if", "(", "$", "this", "->", "isStarted", "(", ")", ")", "{", "return", ";", "}", "// create a new cookie with the session values", "$", "cookie", "=", "new", "HttpCookie", "(",...
Creates and returns the session cookie to be added to the response. @return void
[ "Creates", "and", "returns", "the", "session", "cookie", "to", "be", "added", "to", "the", "response", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/SessionWrapper.php#L85-L111
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/SessionWrapper.php
SessionWrapper.destroy
public function destroy($reason) { // check if the session has already been destroyed if ($this->getId() != null) { // create a new cookie with the session values $cookie = new HttpCookie( $this->getName(), $this->getId(), $this->getLifetime(), $this->getMaximumAge(), $this->getDomain(), $this->getPath(), $this->isSecure(), $this->isHttpOnly() ); // let the cookie expire $cookie->expire(); // and add it to the response $this->getResponse()->addCookie($cookie); } // reset the requested session ID in the request $this->getRequest()->setRequestedSessionId(null); // destroy the sessions data parent::destroy($reason); }
php
public function destroy($reason) { // check if the session has already been destroyed if ($this->getId() != null) { // create a new cookie with the session values $cookie = new HttpCookie( $this->getName(), $this->getId(), $this->getLifetime(), $this->getMaximumAge(), $this->getDomain(), $this->getPath(), $this->isSecure(), $this->isHttpOnly() ); // let the cookie expire $cookie->expire(); // and add it to the response $this->getResponse()->addCookie($cookie); } // reset the requested session ID in the request $this->getRequest()->setRequestedSessionId(null); // destroy the sessions data parent::destroy($reason); }
[ "public", "function", "destroy", "(", "$", "reason", ")", "{", "// check if the session has already been destroyed", "if", "(", "$", "this", "->", "getId", "(", ")", "!=", "null", ")", "{", "// create a new cookie with the session values", "$", "cookie", "=", "new",...
Explicitly destroys all session data and adds a cookie to the response that invalidates the session in the browser. @param string $reason The reason why the session has been destroyed @return void
[ "Explicitly", "destroys", "all", "session", "data", "and", "adds", "a", "cookie", "to", "the", "response", "that", "invalidates", "the", "session", "in", "the", "browser", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/SessionWrapper.php#L121-L150
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/SessionWrapper.php
SessionWrapper.renewId
public function renewId() { // create a new session ID $this->setId(SessionUtils::generateRandomString()); // load the session manager $sessionManager = $this->getContext()->search(SessionManagerInterface::IDENTIFIER); // attach this session with the new ID $sessionManager->attach($this->getSession()); // create a new cookie with the session values $cookie = new HttpCookie( $this->getName(), $this->getId(), $this->getLifetime(), $this->getMaximumAge(), $this->getDomain(), $this->getPath(), $this->isSecure(), $this->isHttpOnly() ); // add the cookie to the response $this->getRequest()->setRequestedSessionId($this->getId()); $this->getResponse()->addCookie($cookie); // return the new session ID return $this->getId(); }
php
public function renewId() { // create a new session ID $this->setId(SessionUtils::generateRandomString()); // load the session manager $sessionManager = $this->getContext()->search(SessionManagerInterface::IDENTIFIER); // attach this session with the new ID $sessionManager->attach($this->getSession()); // create a new cookie with the session values $cookie = new HttpCookie( $this->getName(), $this->getId(), $this->getLifetime(), $this->getMaximumAge(), $this->getDomain(), $this->getPath(), $this->isSecure(), $this->isHttpOnly() ); // add the cookie to the response $this->getRequest()->setRequestedSessionId($this->getId()); $this->getResponse()->addCookie($cookie); // return the new session ID return $this->getId(); }
[ "public", "function", "renewId", "(", ")", "{", "// create a new session ID", "$", "this", "->", "setId", "(", "SessionUtils", "::", "generateRandomString", "(", ")", ")", ";", "// load the session manager", "$", "sessionManager", "=", "$", "this", "->", "getConte...
Generates and propagates a new session ID and transfers all existing data to the new session. @return string The new session ID @throws \AppserverIo\Psr\Servlet\IllegalStateException
[ "Generates", "and", "propagates", "a", "new", "session", "ID", "and", "transfers", "all", "existing", "data", "to", "the", "new", "session", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/SessionWrapper.php#L159-L189
appserver-io/appserver
src/AppserverIo/Appserver/DependencyInjectionContainer/DeploymentDescriptorParser.php
DeploymentDescriptorParser.parse
public function parse() { // load the deployment descriptors that has to be parsed $deploymentDescriptors = $this->loadDeploymentDescriptors(); // parse the deployment descriptors from the conf.d and the application's META-INF directory foreach ($deploymentDescriptors as $deploymentDescriptor) { // query whether we found epb.xml deployment descriptor file if (file_exists($deploymentDescriptor) === false) { continue; } // validate the passed configuration file /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); $configurationService->validateFile($deploymentDescriptor, null, true); // prepare and initialize the configuration node $diNode = new DiNode(); $diNode->initFromFile($deploymentDescriptor); // query whether or not the deployment descriptor contains any preferences if ($preferences = $diNode->getPreferences()) { // parse the preferences of the deployment descriptor /** @var \AppserverIo\Description\Api\Node\PreferenceNode $preferenceNode */ foreach ($preferences as $preferenceNode) { $this->processPreferenceNode($preferenceNode); } } // query whether or not the deployment descriptor contains any beans if ($beans = $diNode->getBeans()) { // parse the beans from the deployment descriptor /** @var \AppserverIo\Description\Api\Node\BeanNode $beanNode */ foreach ($beans as $beanNode) { $this->processBeanNode($beanNode); } } } }
php
public function parse() { // load the deployment descriptors that has to be parsed $deploymentDescriptors = $this->loadDeploymentDescriptors(); // parse the deployment descriptors from the conf.d and the application's META-INF directory foreach ($deploymentDescriptors as $deploymentDescriptor) { // query whether we found epb.xml deployment descriptor file if (file_exists($deploymentDescriptor) === false) { continue; } // validate the passed configuration file /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); $configurationService->validateFile($deploymentDescriptor, null, true); // prepare and initialize the configuration node $diNode = new DiNode(); $diNode->initFromFile($deploymentDescriptor); // query whether or not the deployment descriptor contains any preferences if ($preferences = $diNode->getPreferences()) { // parse the preferences of the deployment descriptor /** @var \AppserverIo\Description\Api\Node\PreferenceNode $preferenceNode */ foreach ($preferences as $preferenceNode) { $this->processPreferenceNode($preferenceNode); } } // query whether or not the deployment descriptor contains any beans if ($beans = $diNode->getBeans()) { // parse the beans from the deployment descriptor /** @var \AppserverIo\Description\Api\Node\BeanNode $beanNode */ foreach ($beans as $beanNode) { $this->processBeanNode($beanNode); } } } }
[ "public", "function", "parse", "(", ")", "{", "// load the deployment descriptors that has to be parsed", "$", "deploymentDescriptors", "=", "$", "this", "->", "loadDeploymentDescriptors", "(", ")", ";", "// parse the deployment descriptors from the conf.d and the application's MET...
Parses the bean context's deployment descriptor file for beans that has to be registered in the object manager. @return void
[ "Parses", "the", "bean", "context", "s", "deployment", "descriptor", "file", "for", "beans", "that", "has", "to", "be", "registered", "in", "the", "object", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/DependencyInjectionContainer/DeploymentDescriptorParser.php#L45-L85
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Doctrine/V2/CacheFactories/RedisCacheFactory.php
RedisCacheFactory.get
public static function get(array $configuration = array()) { if (extension_loaded('redis')) { $redis = new \Redis(); $redis->connect($configuration[CacheKeys::HOST]); $cache = new RedisCache(); $cache->setRedis($redis); return $cache; } }
php
public static function get(array $configuration = array()) { if (extension_loaded('redis')) { $redis = new \Redis(); $redis->connect($configuration[CacheKeys::HOST]); $cache = new RedisCache(); $cache->setRedis($redis); return $cache; } }
[ "public", "static", "function", "get", "(", "array", "$", "configuration", "=", "array", "(", ")", ")", "{", "if", "(", "extension_loaded", "(", "'redis'", ")", ")", "{", "$", "redis", "=", "new", "\\", "Redis", "(", ")", ";", "$", "redis", "->", "...
Return's the new cache instance. @param array $configuration The cache configuration @return \Doctrine\Common\Cache\CacheProvider The cache instance
[ "Return", "s", "the", "new", "cache", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Doctrine/V2/CacheFactories/RedisCacheFactory.php#L45-L54
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/DependencyInjection/DeploymentDescriptorParser.php
DeploymentDescriptorParser.parse
public function parse() { // load the deployment descriptors that has to be parsed $deploymentDescriptors = $this->loadDeploymentDescriptors(); // parse the deployment descriptors from the conf.d and the application's META-INF directory foreach ($deploymentDescriptors as $deploymentDescriptor) { // query whether we found epb.xml deployment descriptor file if (file_exists($deploymentDescriptor) === false) { continue; } // validate the passed configuration file /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); $configurationService->validateFile($deploymentDescriptor, null, true); // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // prepare and initialize the configuration node $webAppNode = new WebAppNode(); $webAppNode->initFromFile($deploymentDescriptor); /** @var \AppserverIo\Appserver\Core\Api\Node\ServletNode $servletNode */ foreach ($webAppNode->getServlets() as $servletNode) { // iterate over all configured descriptors and try to load object description /** \AppserverIo\Appserver\Core\Api\Node\DescriptorNode $descriptor */ foreach ($this->getDescriptors() as $descriptor) { try { // load the descriptor class $descriptorClass = $descriptor->getNodeValue()->getValue(); // load the object descriptor, initialize the servlet mappings and add it to the object manager /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromConfiguration($servletNode)) { /** @var \AppserverIo\Appserver\Core\Api\Node\ServletMappingNode $servletMappingNode */ foreach ($webAppNode->getServletMappings() as $servletMappingNode) { // query whether or not we've to add the URL pattern for the servlet if ((string) $servletNode->getServletName() === (string) $servletMappingNode->getServletName()) { $objectDescriptor->addUrlPattern((string) $servletMappingNode->getUrlPattern()); } } // add the object descriptor for the servlet $objectManager->addObjectDescriptor($objectDescriptor, true); } // proceed with the next descriptor continue; // if class can not be reflected continue with next class } catch (\Exception $e) { // log an error message $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString()); // proceed with the next descriptor continue; } } } // initialize the session configuration if available /** @var \AppserverIo\Appserver\Core\Api\Node\SessionConfigNode $sessionConfig */ if ($sessionConfig = $webAppNode->getSessionConfig()) { foreach ($sessionConfig->toArray() as $key => $value) { $this->getManager()->addSessionParameter($key, $value); } } // initialize the error page configuration if available /** @var \AppserverIo\Appserver\Core\Api\Node\ErrorPageNode $errorPageNode */ foreach ($webAppNode->getErrorPages() as $errorPageNode) { $this->getManager()->addErrorPage((string) $errorPageNode->getErrorCodePattern(), (string) $errorPageNode->getErrorLocation()); } // initialize the context with the context parameters /** @var \AppserverIo\Appserver\Core\Api\Node\ContextParamNode $contextParamNode */ foreach ($webAppNode->getContextParams() as $contextParamNode) { $this->getManager()->addInitParameter((string) $contextParamNode->getParamName(), (string) $contextParamNode->getParamValue()); } } }
php
public function parse() { // load the deployment descriptors that has to be parsed $deploymentDescriptors = $this->loadDeploymentDescriptors(); // parse the deployment descriptors from the conf.d and the application's META-INF directory foreach ($deploymentDescriptors as $deploymentDescriptor) { // query whether we found epb.xml deployment descriptor file if (file_exists($deploymentDescriptor) === false) { continue; } // validate the passed configuration file /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); $configurationService->validateFile($deploymentDescriptor, null, true); // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // prepare and initialize the configuration node $webAppNode = new WebAppNode(); $webAppNode->initFromFile($deploymentDescriptor); /** @var \AppserverIo\Appserver\Core\Api\Node\ServletNode $servletNode */ foreach ($webAppNode->getServlets() as $servletNode) { // iterate over all configured descriptors and try to load object description /** \AppserverIo\Appserver\Core\Api\Node\DescriptorNode $descriptor */ foreach ($this->getDescriptors() as $descriptor) { try { // load the descriptor class $descriptorClass = $descriptor->getNodeValue()->getValue(); // load the object descriptor, initialize the servlet mappings and add it to the object manager /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromConfiguration($servletNode)) { /** @var \AppserverIo\Appserver\Core\Api\Node\ServletMappingNode $servletMappingNode */ foreach ($webAppNode->getServletMappings() as $servletMappingNode) { // query whether or not we've to add the URL pattern for the servlet if ((string) $servletNode->getServletName() === (string) $servletMappingNode->getServletName()) { $objectDescriptor->addUrlPattern((string) $servletMappingNode->getUrlPattern()); } } // add the object descriptor for the servlet $objectManager->addObjectDescriptor($objectDescriptor, true); } // proceed with the next descriptor continue; // if class can not be reflected continue with next class } catch (\Exception $e) { // log an error message $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString()); // proceed with the next descriptor continue; } } } // initialize the session configuration if available /** @var \AppserverIo\Appserver\Core\Api\Node\SessionConfigNode $sessionConfig */ if ($sessionConfig = $webAppNode->getSessionConfig()) { foreach ($sessionConfig->toArray() as $key => $value) { $this->getManager()->addSessionParameter($key, $value); } } // initialize the error page configuration if available /** @var \AppserverIo\Appserver\Core\Api\Node\ErrorPageNode $errorPageNode */ foreach ($webAppNode->getErrorPages() as $errorPageNode) { $this->getManager()->addErrorPage((string) $errorPageNode->getErrorCodePattern(), (string) $errorPageNode->getErrorLocation()); } // initialize the context with the context parameters /** @var \AppserverIo\Appserver\Core\Api\Node\ContextParamNode $contextParamNode */ foreach ($webAppNode->getContextParams() as $contextParamNode) { $this->getManager()->addInitParameter((string) $contextParamNode->getParamName(), (string) $contextParamNode->getParamValue()); } } }
[ "public", "function", "parse", "(", ")", "{", "// load the deployment descriptors that has to be parsed", "$", "deploymentDescriptors", "=", "$", "this", "->", "loadDeploymentDescriptors", "(", ")", ";", "// parse the deployment descriptors from the conf.d and the application's MET...
Parses the servlet context's deployment descriptor file for servlets that has to be registered in the object manager. @return void
[ "Parses", "the", "servlet", "context", "s", "deployment", "descriptor", "file", "for", "servlets", "that", "has", "to", "be", "registered", "in", "the", "object", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/DependencyInjection/DeploymentDescriptorParser.php#L45-L129
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardSessionMarshaller.php
StandardSessionMarshaller.marshall
public function marshall(ServletSessionInterface $servletSession) { // create the stdClass (that can easy be transformed into an JSON object) $sessionData = array(); // copy the values to the stdClass $sessionData[StandardSessionMarshaller::ID] = $servletSession->getId(); $sessionData[StandardSessionMarshaller::NAME] = $servletSession->getName(); $sessionData[StandardSessionMarshaller::LIFETIME] = $servletSession->getLifetime(); $sessionData[StandardSessionMarshaller::MAXIMUM_AGE] = $servletSession->getMaximumAge(); $sessionData[StandardSessionMarshaller::DOMAIN] = $servletSession->getDomain(); $sessionData[StandardSessionMarshaller::PATH] = $servletSession->getPath(); $sessionData[StandardSessionMarshaller::SECURE] = $servletSession->isSecure(); $sessionData[StandardSessionMarshaller::HTTP_ONLY] = $servletSession->isHttpOnly(); $sessionData[StandardSessionMarshaller::LAST_ACTIVITY_TIMESTAMP] = $servletSession->getLastActivityTimestamp(); // initialize the array for the session data $sessionData[StandardSessionMarshaller::DATA] = array(); // append the session data foreach ($servletSession->data as $key => $value) { $sessionData[StandardSessionMarshaller::DATA][$key] = serialize($value); } // JSON encode the session instance $encodedSession = json_encode($sessionData); // query whether or not the session data has been decoded successfully if (json_last_error() !== JSON_ERROR_NONE) { throw new SessionDataNotReadableException(json_last_error_msg()); } // return the JSON encoded session data return $encodedSession; }
php
public function marshall(ServletSessionInterface $servletSession) { // create the stdClass (that can easy be transformed into an JSON object) $sessionData = array(); // copy the values to the stdClass $sessionData[StandardSessionMarshaller::ID] = $servletSession->getId(); $sessionData[StandardSessionMarshaller::NAME] = $servletSession->getName(); $sessionData[StandardSessionMarshaller::LIFETIME] = $servletSession->getLifetime(); $sessionData[StandardSessionMarshaller::MAXIMUM_AGE] = $servletSession->getMaximumAge(); $sessionData[StandardSessionMarshaller::DOMAIN] = $servletSession->getDomain(); $sessionData[StandardSessionMarshaller::PATH] = $servletSession->getPath(); $sessionData[StandardSessionMarshaller::SECURE] = $servletSession->isSecure(); $sessionData[StandardSessionMarshaller::HTTP_ONLY] = $servletSession->isHttpOnly(); $sessionData[StandardSessionMarshaller::LAST_ACTIVITY_TIMESTAMP] = $servletSession->getLastActivityTimestamp(); // initialize the array for the session data $sessionData[StandardSessionMarshaller::DATA] = array(); // append the session data foreach ($servletSession->data as $key => $value) { $sessionData[StandardSessionMarshaller::DATA][$key] = serialize($value); } // JSON encode the session instance $encodedSession = json_encode($sessionData); // query whether or not the session data has been decoded successfully if (json_last_error() !== JSON_ERROR_NONE) { throw new SessionDataNotReadableException(json_last_error_msg()); } // return the JSON encoded session data return $encodedSession; }
[ "public", "function", "marshall", "(", "ServletSessionInterface", "$", "servletSession", ")", "{", "// create the stdClass (that can easy be transformed into an JSON object)", "$", "sessionData", "=", "array", "(", ")", ";", "// copy the values to the stdClass", "$", "sessionDa...
Transforms the passed session instance into a JSON encoded string. If the data contains objects, each of them will be serialized before store them to the persistence layer. @param \AppserverIo\Psr\Servlet\ServletSessionInterface $servletSession The session to be transformed @return string The JSON encoded session representation @throws \AppserverIo\Appserver\ServletEngine\DataNotSerializableException Is thrown, if the session can't be encoded @see \AppserverIo\Appserver\ServletEngine\SessionMarshallerInterface::marshall()
[ "Transforms", "the", "passed", "session", "instance", "into", "a", "JSON", "encoded", "string", ".", "If", "the", "data", "contains", "objects", "each", "of", "them", "will", "be", "serialized", "before", "store", "them", "to", "the", "persistence", "layer", ...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardSessionMarshaller.php#L117-L152
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardSessionMarshaller.php
StandardSessionMarshaller.unmarshall
public function unmarshall(ServletSessionInterface $servletSession, $marshalled) { // try to decode the string $decodedSession = json_decode($marshalled, true); // query whether or not the session data has been encoded successfully if (json_last_error() !== JSON_ERROR_NONE) { throw new SessionDataNotReadableException(json_last_error_msg()); } // extract the values $id = $decodedSession[StandardSessionMarshaller::ID]; $name = $decodedSession[StandardSessionMarshaller::NAME]; $lifetime = $decodedSession[StandardSessionMarshaller::LIFETIME]; $maximumAge = $decodedSession[StandardSessionMarshaller::MAXIMUM_AGE]; $domain = $decodedSession[StandardSessionMarshaller::DOMAIN]; $path = $decodedSession[StandardSessionMarshaller::PATH]; $secure = $decodedSession[StandardSessionMarshaller::SECURE]; $httpOnly = $decodedSession[StandardSessionMarshaller::HTTP_ONLY]; $data = $decodedSession[StandardSessionMarshaller::DATA]; $lastActivityTimestamp = $decodedSession[StandardSessionMarshaller::LAST_ACTIVITY_TIMESTAMP]; // initialize the instance $servletSession->init($id, $name, $lifetime, $maximumAge, $domain, $path, $secure, $httpOnly, $lastActivityTimestamp); // append the session data foreach ($data as $key => $value) { $servletSession->putData($key, unserialize($value)); } }
php
public function unmarshall(ServletSessionInterface $servletSession, $marshalled) { // try to decode the string $decodedSession = json_decode($marshalled, true); // query whether or not the session data has been encoded successfully if (json_last_error() !== JSON_ERROR_NONE) { throw new SessionDataNotReadableException(json_last_error_msg()); } // extract the values $id = $decodedSession[StandardSessionMarshaller::ID]; $name = $decodedSession[StandardSessionMarshaller::NAME]; $lifetime = $decodedSession[StandardSessionMarshaller::LIFETIME]; $maximumAge = $decodedSession[StandardSessionMarshaller::MAXIMUM_AGE]; $domain = $decodedSession[StandardSessionMarshaller::DOMAIN]; $path = $decodedSession[StandardSessionMarshaller::PATH]; $secure = $decodedSession[StandardSessionMarshaller::SECURE]; $httpOnly = $decodedSession[StandardSessionMarshaller::HTTP_ONLY]; $data = $decodedSession[StandardSessionMarshaller::DATA]; $lastActivityTimestamp = $decodedSession[StandardSessionMarshaller::LAST_ACTIVITY_TIMESTAMP]; // initialize the instance $servletSession->init($id, $name, $lifetime, $maximumAge, $domain, $path, $secure, $httpOnly, $lastActivityTimestamp); // append the session data foreach ($data as $key => $value) { $servletSession->putData($key, unserialize($value)); } }
[ "public", "function", "unmarshall", "(", "ServletSessionInterface", "$", "servletSession", ",", "$", "marshalled", ")", "{", "// try to decode the string", "$", "decodedSession", "=", "json_decode", "(", "$", "marshalled", ",", "true", ")", ";", "// query whether or n...
Initializes the session instance from the passed JSON string. If the encoded data contains objects, they will be un-serialized before reattached to the session instance. @param \AppserverIo\Psr\Servlet\ServletSessionInterface $servletSession The empty session instance we want the un-marshaled data be added to @param string $marshalled The marshaled session representation @return \AppserverIo\Psr\Servlet\ServletSessionInterface The decoded session instance @throws \AppserverIo\Appserver\ServletEngine\SessionDataNotReadableException Is thrown, if the session data can not be unmarshalled @see \AppserverIo\Appserver\ServletEngine\SessionMarshallerInterface::unmarshall()
[ "Initializes", "the", "session", "instance", "from", "the", "passed", "JSON", "string", ".", "If", "the", "encoded", "data", "contains", "objects", "they", "will", "be", "un", "-", "serialized", "before", "reattached", "to", "the", "session", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardSessionMarshaller.php#L166-L196
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/ConfigurationService.php
ConfigurationService.findSchemaFile
protected function findSchemaFile($fileName) { // check if we got a specific schema file we have to use, otherwise use the default one $this->schemaFile = realpath(__DIR__ . '/../../../../../') . DIRECTORY_SEPARATOR . self::DEFAULT_XML_SCHEMA; $fileName = pathinfo($fileName, PATHINFO_FILENAME); if (isset($this->schemaFiles[$fileName])) { $this->schemaFile = $this->schemaFiles[$fileName]; } }
php
protected function findSchemaFile($fileName) { // check if we got a specific schema file we have to use, otherwise use the default one $this->schemaFile = realpath(__DIR__ . '/../../../../../') . DIRECTORY_SEPARATOR . self::DEFAULT_XML_SCHEMA; $fileName = pathinfo($fileName, PATHINFO_FILENAME); if (isset($this->schemaFiles[$fileName])) { $this->schemaFile = $this->schemaFiles[$fileName]; } }
[ "protected", "function", "findSchemaFile", "(", "$", "fileName", ")", "{", "// check if we got a specific schema file we have to use, otherwise use the default one", "$", "this", "->", "schemaFile", "=", "realpath", "(", "__DIR__", ".", "'/../../../../../'", ")", ".", "DIRE...
Will try to find the appropriate schema file for the file to validate @param string $fileName Name of the file to find the schema for @return null
[ "Will", "try", "to", "find", "the", "appropriate", "schema", "file", "for", "the", "file", "to", "validate" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/ConfigurationService.php#L91-L99
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/ConfigurationService.php
ConfigurationService.init
public function init() { $this->errors = array(); $this->schemaFile = realpath(__DIR__ . '/../../../../../') . DIRECTORY_SEPARATOR . self::DEFAULT_XML_SCHEMA; $this->schemaFiles = array(); }
php
public function init() { $this->errors = array(); $this->schemaFile = realpath(__DIR__ . '/../../../../../') . DIRECTORY_SEPARATOR . self::DEFAULT_XML_SCHEMA; $this->schemaFiles = array(); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "errors", "=", "array", "(", ")", ";", "$", "this", "->", "schemaFile", "=", "realpath", "(", "__DIR__", ".", "'/../../../../../'", ")", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "DEFAU...
Initializes the configuration tester. Will reset traces of any former usage @return null
[ "Initializes", "the", "configuration", "tester", ".", "Will", "reset", "traces", "of", "any", "former", "usage" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/ConfigurationService.php#L107-L112