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/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php
AbstractLoginModule.commit
public function commit() { // we can only commit if the login has been successful if ($this->loginOk === false) { return false; } // add the identity to the subject's principals $principals = $this->subject->getPrincipals(); $principals->add($this->getIdentity()); // load the groups $roleSets = $this->getRoleSets(); // iterate over the groups and add them to the subject for ($g = 0; $g < sizeof($roleSets); $g++) { // initialize group, name and subject group $group = $roleSets[$g]; $name = $group->getName(); $subjectGroup = $this->createGroup($name, $principals); /* if ($subjectGroup instanceof NestableGroup) { // a NestableGroup only allows Groups to be added to it so we need to add a SimpleGroup to subjectRoles to contain the roles $tmp = new SimpleGroup('Roles'); $subjectGroup->addMember($tmp); $subjectGroup = $tmp; } */ // copy the group members to the Subject group foreach ($group->getMembers() as $member) { $subjectGroup->addMember($member); } } // return TRUE if we succeed return true; }
php
public function commit() { // we can only commit if the login has been successful if ($this->loginOk === false) { return false; } // add the identity to the subject's principals $principals = $this->subject->getPrincipals(); $principals->add($this->getIdentity()); // load the groups $roleSets = $this->getRoleSets(); // iterate over the groups and add them to the subject for ($g = 0; $g < sizeof($roleSets); $g++) { // initialize group, name and subject group $group = $roleSets[$g]; $name = $group->getName(); $subjectGroup = $this->createGroup($name, $principals); /* if ($subjectGroup instanceof NestableGroup) { // a NestableGroup only allows Groups to be added to it so we need to add a SimpleGroup to subjectRoles to contain the roles $tmp = new SimpleGroup('Roles'); $subjectGroup->addMember($tmp); $subjectGroup = $tmp; } */ // copy the group members to the Subject group foreach ($group->getMembers() as $member) { $subjectGroup->addMember($member); } } // return TRUE if we succeed return true; }
[ "public", "function", "commit", "(", ")", "{", "// we can only commit if the login has been successful", "if", "(", "$", "this", "->", "loginOk", "===", "false", ")", "{", "return", "false", ";", "}", "// add the identity to the subject's principals", "$", "principals",...
Method to commit the authentication process (phase 2). If the login method completed successfully as indicated by loginOk == true, this method adds the getIdentity() value to the subject getPrincipals() Set. It also adds the members of each Group returned by getRoleSets() to the subject getPrincipals() Set. @return true always. @throws \AppserverIo\Psr\Security\Auth\Login\LoginException If login can't be committed'
[ "Method", "to", "commit", "the", "authentication", "process", "(", "phase", "2", ")", ".", "If", "the", "login", "method", "completed", "successfully", "as", "indicated", "by", "loginOk", "==", "true", "this", "method", "adds", "the", "getIdentity", "()", "v...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php#L231-L268
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php
AbstractLoginModule.getUsernameAndPassword
public function getUsernameAndPassword() { // create and initialize an ArrayList for the callback handlers $list = new ArrayList(); $list->add($nameCallback = new NameCallback()); $list->add($passwordCallback = new PasswordCallback()); // handle the callbacks $this->callbackHandler->handle($list); // return an array with the username and callback return array($nameCallback->getName(), $passwordCallback->getPassword()); }
php
public function getUsernameAndPassword() { // create and initialize an ArrayList for the callback handlers $list = new ArrayList(); $list->add($nameCallback = new NameCallback()); $list->add($passwordCallback = new PasswordCallback()); // handle the callbacks $this->callbackHandler->handle($list); // return an array with the username and callback return array($nameCallback->getName(), $passwordCallback->getPassword()); }
[ "public", "function", "getUsernameAndPassword", "(", ")", "{", "// create and initialize an ArrayList for the callback handlers", "$", "list", "=", "new", "ArrayList", "(", ")", ";", "$", "list", "->", "add", "(", "$", "nameCallback", "=", "new", "NameCallback", "("...
Called by login() to acquire the username and password strings for authentication. This method does no validation of either. @return array Array with name and password, e. g. array(0 => $name, 1 => $password) @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if name and password can't be loaded
[ "Called", "by", "login", "()", "to", "acquire", "the", "username", "and", "password", "strings", "for", "authentication", ".", "This", "method", "does", "no", "validation", "of", "either", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php#L288-L301
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php
AbstractLoginModule.createIdentity
public function createIdentity(String $name) { //initialize the principal $principal = null; // query whether or not a principal class name has been specified if ($this->principalClassName == null) { $principal = new SimplePrincipal($name); } else { $reflectionClass = new ReflectionClass($this->principalClassName->__toString()); $principal = $reflectionClass->newInstanceArgs(array($name)); } // return the principal instance return $principal; }
php
public function createIdentity(String $name) { //initialize the principal $principal = null; // query whether or not a principal class name has been specified if ($this->principalClassName == null) { $principal = new SimplePrincipal($name); } else { $reflectionClass = new ReflectionClass($this->principalClassName->__toString()); $principal = $reflectionClass->newInstanceArgs(array($name)); } // return the principal instance return $principal; }
[ "public", "function", "createIdentity", "(", "String", "$", "name", ")", "{", "//initialize the principal", "$", "principal", "=", "null", ";", "// query whether or not a principal class name has been specified", "if", "(", "$", "this", "->", "principalClassName", "==", ...
Utility method to create a Principal for the given username. This creates an instance of the principalClassName type if this option was specified. If principalClassName was not specified, a SimplePrincipal is created. @param \AppserverIo\Lang\String $name The name of the principal @return \AppserverIo\Psr\Security\PrincipalInterface The principal instance @throws \Exception Is thrown if the custom principal type cannot be created
[ "Utility", "method", "to", "create", "a", "Principal", "for", "the", "given", "username", ".", "This", "creates", "an", "instance", "of", "the", "principalClassName", "type", "if", "this", "option", "was", "specified", ".", "If", "principalClassName", "was", "...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php#L314-L330
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php
AbstractLoginModule.createGroup
protected function createGroup(String $name, CollectionInterface $principals) { // initialize the group /** \AppserverIo\Psr\Security\Acl\GroupInterface $roles */ $roles = null; // iterate over the passed principals foreach ($principals as $principal) { // query whether we found a group or not, proceed if not if (($principal instanceof GroupInterface) == false) { continue; } // the principal is a group $grp = $principal; // if the group already exists, stop searching if ($grp->getName()->equals($name)) { $roles = $grp; break; } } // if we did not find a group create one if ($roles == null) { $roles = new SimpleGroup($name); $principals->add($roles); } // return the group return $roles; }
php
protected function createGroup(String $name, CollectionInterface $principals) { // initialize the group /** \AppserverIo\Psr\Security\Acl\GroupInterface $roles */ $roles = null; // iterate over the passed principals foreach ($principals as $principal) { // query whether we found a group or not, proceed if not if (($principal instanceof GroupInterface) == false) { continue; } // the principal is a group $grp = $principal; // if the group already exists, stop searching if ($grp->getName()->equals($name)) { $roles = $grp; break; } } // if we did not find a group create one if ($roles == null) { $roles = new SimpleGroup($name); $principals->add($roles); } // return the group return $roles; }
[ "protected", "function", "createGroup", "(", "String", "$", "name", ",", "CollectionInterface", "$", "principals", ")", "{", "// initialize the group", "/** \\AppserverIo\\Psr\\Security\\Acl\\GroupInterface $roles */", "$", "roles", "=", "null", ";", "// iterate over the pass...
Find or create a Group with the given name. Subclasses should use this method to locate the 'Roles' group or create additional types of groups. @param \AppserverIo\Lang\String $name The name of the group to create @param \AppserverIo\Collections\CollectionInterface $principals The list of principals @return \AppserverIo\Psr\Security\Acl\GroupInterface A named group from the principals set
[ "Find", "or", "create", "a", "Group", "with", "the", "given", "name", ".", "Subclasses", "should", "use", "this", "method", "to", "locate", "the", "Roles", "group", "or", "create", "additional", "types", "of", "groups", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php#L341-L373
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/HeartbeatScanner.php
HeartbeatScanner.init
public function init() { // Build up the complete path to the heartbeat file $this->heartbeatFile = APPSERVER_BP . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'run' . DIRECTORY_SEPARATOR . self::HEARTBEAT_FILE_NAME; // Init the parent as well, as we have to get some mappings parent::init(); }
php
public function init() { // Build up the complete path to the heartbeat file $this->heartbeatFile = APPSERVER_BP . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'run' . DIRECTORY_SEPARATOR . self::HEARTBEAT_FILE_NAME; // Init the parent as well, as we have to get some mappings parent::init(); }
[ "public", "function", "init", "(", ")", "{", "// Build up the complete path to the heartbeat file", "$", "this", "->", "heartbeatFile", "=", "APPSERVER_BP", ".", "DIRECTORY_SEPARATOR", ".", "'var'", ".", "DIRECTORY_SEPARATOR", ".", "'run'", ".", "DIRECTORY_SEPARATOR", "...
Initializes the scanner @return void @see \AppserverIo\Appserver\Core\AbstractThread::init()
[ "Initializes", "the", "scanner" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/HeartbeatScanner.php#L88-L96
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/HeartbeatScanner.php
HeartbeatScanner.main
public function main() { // log the configured deployment directory $this->getSystemLogger()->debug( sprintf( "Start watching heartbeat file %s", $this->getHeartbeatFile() ) ); // wait until the server has been successfully started at least once while ($this->getLastFileTouch($this->getHeartbeatFile()) === 0) { $this->getSystemLogger()->debug('Heartbeat scanner is waiting for first successful startup ...'); sleep(1); } // watch the heartbeat file while (true) { // load the current file change time of the heartbeat file and store it $oldMTime = $this->getLastFileTouch($this->getHeartbeatFile()); // Get the current time $currentTime = time(); // log the found directory hash value $this->getSystemLogger()->debug( sprintf( "Comparing heartbeat mTimes %s (previous) : %s (actual)", $oldMTime, $currentTime ) ); // compare the mTime values, if they differ more than allowed we have to take action if (($currentTime - $oldMTime) > self::HEARTBEAT_INTERVAL) { // log that changes have been found $this->getSystemLogger()->debug( sprintf( "Found heartbeat missing for %s seconds.", $currentTime - $oldMTime ) ); // as long as the heartbeat does not come back up we will try to restart the appserver while ($oldMTime === $this->getLastFileTouch($this->getHeartbeatFile())) { // tell them we try to restart $this->getSystemLogger()->debug("Will try to restart the appserver."); // restart the appserver $this->restart(); // wait until restart has been finished, but only wait for so long for ($i = 0; $i <= self::RESTART_INTERVAL; $i ++) { // sleep a little sleep(1); } } // log that the appserver has been restarted successfully $this->getSystemLogger()->debug("appserver has successfully been restarted."); } else { // if no changes has been found, wait a second sleep(1); } } }
php
public function main() { // log the configured deployment directory $this->getSystemLogger()->debug( sprintf( "Start watching heartbeat file %s", $this->getHeartbeatFile() ) ); // wait until the server has been successfully started at least once while ($this->getLastFileTouch($this->getHeartbeatFile()) === 0) { $this->getSystemLogger()->debug('Heartbeat scanner is waiting for first successful startup ...'); sleep(1); } // watch the heartbeat file while (true) { // load the current file change time of the heartbeat file and store it $oldMTime = $this->getLastFileTouch($this->getHeartbeatFile()); // Get the current time $currentTime = time(); // log the found directory hash value $this->getSystemLogger()->debug( sprintf( "Comparing heartbeat mTimes %s (previous) : %s (actual)", $oldMTime, $currentTime ) ); // compare the mTime values, if they differ more than allowed we have to take action if (($currentTime - $oldMTime) > self::HEARTBEAT_INTERVAL) { // log that changes have been found $this->getSystemLogger()->debug( sprintf( "Found heartbeat missing for %s seconds.", $currentTime - $oldMTime ) ); // as long as the heartbeat does not come back up we will try to restart the appserver while ($oldMTime === $this->getLastFileTouch($this->getHeartbeatFile())) { // tell them we try to restart $this->getSystemLogger()->debug("Will try to restart the appserver."); // restart the appserver $this->restart(); // wait until restart has been finished, but only wait for so long for ($i = 0; $i <= self::RESTART_INTERVAL; $i ++) { // sleep a little sleep(1); } } // log that the appserver has been restarted successfully $this->getSystemLogger()->debug("appserver has successfully been restarted."); } else { // if no changes has been found, wait a second sleep(1); } } }
[ "public", "function", "main", "(", ")", "{", "// log the configured deployment directory", "$", "this", "->", "getSystemLogger", "(", ")", "->", "debug", "(", "sprintf", "(", "\"Start watching heartbeat file %s\"", ",", "$", "this", "->", "getHeartbeatFile", "(", ")...
The thread implementation main method which will be called from run in abstractness @return void
[ "The", "thread", "implementation", "main", "method", "which", "will", "be", "called", "from", "run", "in", "abstractness" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/HeartbeatScanner.php#L113-L180
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.newFromApplication
public function newFromApplication(ApplicationInterface $application) { // create a new AppNode and initialize it $appNode = new AppNode(); $appNode->initFromApplication($application); $appNode->setParentUuid($this->getSystemConfiguration()->getUuid()); // persist the AppNode instance $this->persist($appNode); }
php
public function newFromApplication(ApplicationInterface $application) { // create a new AppNode and initialize it $appNode = new AppNode(); $appNode->initFromApplication($application); $appNode->setParentUuid($this->getSystemConfiguration()->getUuid()); // persist the AppNode instance $this->persist($appNode); }
[ "public", "function", "newFromApplication", "(", "ApplicationInterface", "$", "application", ")", "{", "// create a new AppNode and initialize it", "$", "appNode", "=", "new", "AppNode", "(", ")", ";", "$", "appNode", "->", "initFromApplication", "(", "$", "applicatio...
Creates a new app node for the passed application and attaches it to the system configuration. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application to create a new AppNode for @return void
[ "Creates", "a", "new", "app", "node", "for", "the", "passed", "application", "and", "attaches", "it", "to", "the", "system", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L64-L73
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.findAll
public function findAll() { $appNodes = array(); foreach ($this->getSystemConfiguration()->getApps() as $appNode) { $appNodes[$appNode->getPrimaryKey()] = $appNode; } return $appNodes; }
php
public function findAll() { $appNodes = array(); foreach ($this->getSystemConfiguration()->getApps() as $appNode) { $appNodes[$appNode->getPrimaryKey()] = $appNode; } return $appNodes; }
[ "public", "function", "findAll", "(", ")", "{", "$", "appNodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getApps", "(", ")", "as", "$", "appNode", ")", "{", "$", "appNodes", "[", "$",...
Returns all deployed applications. @return array All deployed applications @see \AppserverIo\Psr\ApplicationServer\ServiceInterface::findAll()
[ "Returns", "all", "deployed", "applications", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L81-L88
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.findAllByName
public function findAllByName($name) { $appNodes = array(); foreach ($this->findAll() as $appNode) { if ($appNode->getName() == $name) { $appNodes[$appNode->getPrimaryKey()] = $appNode; } } return $appNodes; }
php
public function findAllByName($name) { $appNodes = array(); foreach ($this->findAll() as $appNode) { if ($appNode->getName() == $name) { $appNodes[$appNode->getPrimaryKey()] = $appNode; } } return $appNodes; }
[ "public", "function", "findAllByName", "(", "$", "name", ")", "{", "$", "appNodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "findAll", "(", ")", "as", "$", "appNode", ")", "{", "if", "(", "$", "appNode", "->", "getName", "("...
Returns the applications with the passed name. @param string $name Name of the application to return @return array The applications with the name passed as parameter
[ "Returns", "the", "applications", "with", "the", "passed", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L97-L106
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.getExtractor
public function getExtractor() { // we will have a phar extractor by default if (!isset($this->extractor)) { $configuration = $this->getSystemConfiguration()->getExtractors(); if (isset($configuration[self::DEFAULT_EXTRACTOR_NAME])) { // create a new extractor with the default configuration $this->extractor = new PharExtractor($this->getInitialContext(), $configuration[self::DEFAULT_EXTRACTOR_NAME]); } else { $this->getInitialContext()->getSystemLogger()->warning(sprintf( 'Did not find configuration for default extractor %s nor was an extractor injected.', self::DEFAULT_EXTRACTOR_NAME )); $this->extractor = null; } } return $this->extractor; }
php
public function getExtractor() { // we will have a phar extractor by default if (!isset($this->extractor)) { $configuration = $this->getSystemConfiguration()->getExtractors(); if (isset($configuration[self::DEFAULT_EXTRACTOR_NAME])) { // create a new extractor with the default configuration $this->extractor = new PharExtractor($this->getInitialContext(), $configuration[self::DEFAULT_EXTRACTOR_NAME]); } else { $this->getInitialContext()->getSystemLogger()->warning(sprintf( 'Did not find configuration for default extractor %s nor was an extractor injected.', self::DEFAULT_EXTRACTOR_NAME )); $this->extractor = null; } } return $this->extractor; }
[ "public", "function", "getExtractor", "(", ")", "{", "// we will have a phar extractor by default", "if", "(", "!", "isset", "(", "$", "this", "->", "extractor", ")", ")", "{", "$", "configuration", "=", "$", "this", "->", "getSystemConfiguration", "(", ")", "...
Getter for this service's extractor @return \AppserverIo\Appserver\Core\Interfaces\ExtractorInterface|null
[ "Getter", "for", "this", "service", "s", "extractor" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L113-L132
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.load
public function load($uuid) { foreach ($this->findAll() as $appNode) { if ($appNode->getPrimaryKey() == $uuid) { return $appNode; } } }
php
public function load($uuid) { foreach ($this->findAll() as $appNode) { if ($appNode->getPrimaryKey() == $uuid) { return $appNode; } } }
[ "public", "function", "load", "(", "$", "uuid", ")", "{", "foreach", "(", "$", "this", "->", "findAll", "(", ")", "as", "$", "appNode", ")", "{", "if", "(", "$", "appNode", "->", "getPrimaryKey", "(", ")", "==", "$", "uuid", ")", "{", "return", "...
Returns the application with the passed UUID. @param string $uuid UUID of the application to return @return \AppserverIo\Appserver\Core\Api\Node\AppNode|null The application with the UUID passed as parameter @see \AppserverIo\Psr\ApplicationServer\ServiceInterface::load()
[ "Returns", "the", "application", "with", "the", "passed", "UUID", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L154-L161
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.loadByWebappPath
public function loadByWebappPath($webappPath) { foreach ($this->findAll() as $appNode) { if ($appNode->getWebappPath() == $webappPath) { return $appNode; } } }
php
public function loadByWebappPath($webappPath) { foreach ($this->findAll() as $appNode) { if ($appNode->getWebappPath() == $webappPath) { return $appNode; } } }
[ "public", "function", "loadByWebappPath", "(", "$", "webappPath", ")", "{", "foreach", "(", "$", "this", "->", "findAll", "(", ")", "as", "$", "appNode", ")", "{", "if", "(", "$", "appNode", "->", "getWebappPath", "(", ")", "==", "$", "webappPath", ")"...
Returns the application with the passed webapp path. @param string $webappPath webapp path of the application to return @return \AppserverIo\Appserver\Core\Api\Node\AppNode|null The application with the webapp path passed as parameter
[ "Returns", "the", "application", "with", "the", "passed", "webapp", "path", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L171-L178
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.persist
public function persist(NodeInterface $appNode) { $systemConfiguration = $this->getSystemConfiguration(); $systemConfiguration->attachApp($appNode); $this->setSystemConfiguration($systemConfiguration); }
php
public function persist(NodeInterface $appNode) { $systemConfiguration = $this->getSystemConfiguration(); $systemConfiguration->attachApp($appNode); $this->setSystemConfiguration($systemConfiguration); }
[ "public", "function", "persist", "(", "NodeInterface", "$", "appNode", ")", "{", "$", "systemConfiguration", "=", "$", "this", "->", "getSystemConfiguration", "(", ")", ";", "$", "systemConfiguration", "->", "attachApp", "(", "$", "appNode", ")", ";", "$", "...
Persists the system configuration. @param \AppserverIo\Configuration\Interfaces\NodeInterface $appNode The application node object @return void
[ "Persists", "the", "system", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L187-L192
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.soak
public function soak(ContainerConfigurationInterface $containerNode, \SplFileInfo $archive) { $extractor = $this->getExtractor(); $extractor->soakArchive($containerNode, $archive); }
php
public function soak(ContainerConfigurationInterface $containerNode, \SplFileInfo $archive) { $extractor = $this->getExtractor(); $extractor->soakArchive($containerNode, $archive); }
[ "public", "function", "soak", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "\\", "SplFileInfo", "$", "archive", ")", "{", "$", "extractor", "=", "$", "this", "->", "getExtractor", "(", ")", ";", "$", "extractor", "->", "soakArchive", "(",...
Soaks the passed archive into from a location in the filesystem to the deploy directory. @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container the archive is bound to @param \SplFileInfo $archive The archive to soak @return void
[ "Soaks", "the", "passed", "archive", "into", "from", "a", "location", "in", "the", "filesystem", "to", "the", "deploy", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L203-L207
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.deploy
public function deploy(ContainerConfigurationInterface $containerNode, NodeInterface $appNode) { // prepare file name $extractor = $this->getExtractor(); $fileName = $appNode->getName() . $extractor->getExtensionSuffix(); // load the file info $archive = new \SplFileInfo($this->getDeployDir($containerNode) . DIRECTORY_SEPARATOR . $fileName); // flag the archive => deploy it with the next restart $extractor->flagArchive($archive, ExtractorInterface::FLAG_DODEPLOY); }
php
public function deploy(ContainerConfigurationInterface $containerNode, NodeInterface $appNode) { // prepare file name $extractor = $this->getExtractor(); $fileName = $appNode->getName() . $extractor->getExtensionSuffix(); // load the file info $archive = new \SplFileInfo($this->getDeployDir($containerNode) . DIRECTORY_SEPARATOR . $fileName); // flag the archive => deploy it with the next restart $extractor->flagArchive($archive, ExtractorInterface::FLAG_DODEPLOY); }
[ "public", "function", "deploy", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "NodeInterface", "$", "appNode", ")", "{", "// prepare file name", "$", "extractor", "=", "$", "this", "->", "getExtractor", "(", ")", ";", "$", "fileName", "=", "...
Adds the .dodeploy flag file in the deploy folder, therefore the app will be deployed with the next restart. @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container the app is bound to @param \AppserverIo\Configuration\Interfaces\NodeInterface $appNode The application node object @return void
[ "Adds", "the", ".", "dodeploy", "flag", "file", "in", "the", "deploy", "folder", "therefore", "the", "app", "will", "be", "deployed", "with", "the", "next", "restart", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L218-L229
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.undeploy
public function undeploy(ContainerConfigurationInterface $containerNode, $uuid) { // try to load the app node with the passe UUID if ($appNode = $this->load($uuid)) { // prepare file name $extractor = $this->getExtractor(); $fileName = $appNode->getName() . $extractor->getExtensionSuffix(); // load the file info $archive = new \SplFileInfo($this->getDeployDir($containerNode) . DIRECTORY_SEPARATOR . $fileName); // un-flag the archiv => un-deploy it with the next restart $extractor->unflagArchive($archive); } }
php
public function undeploy(ContainerConfigurationInterface $containerNode, $uuid) { // try to load the app node with the passe UUID if ($appNode = $this->load($uuid)) { // prepare file name $extractor = $this->getExtractor(); $fileName = $appNode->getName() . $extractor->getExtensionSuffix(); // load the file info $archive = new \SplFileInfo($this->getDeployDir($containerNode) . DIRECTORY_SEPARATOR . $fileName); // un-flag the archiv => un-deploy it with the next restart $extractor->unflagArchive($archive); } }
[ "public", "function", "undeploy", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "$", "uuid", ")", "{", "// try to load the app node with the passe UUID", "if", "(", "$", "appNode", "=", "$", "this", "->", "load", "(", "$", "uuid", ")", ")", ...
Removes the .deployed flag file from the deploy folder, therefore the app will be undeployed with the next restart. @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container the app is bound to @param string $uuid UUID of the application to delete @return void @todo Add functionality to delete the deployed app
[ "Removes", "the", ".", "deployed", "flag", "file", "from", "the", "deploy", "folder", "therefore", "the", "app", "will", "be", "undeployed", "with", "the", "next", "restart", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L241-L256
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.createTmpFolders
public function createTmpFolders(ApplicationInterface $application) { // create the directory we want to store the sessions in $tmpFolders = array( new \SplFileInfo($application->getTmpDir()), new \SplFileInfo($application->getDataDir()), new \SplFileInfo($application->getCacheDir()), new \SplFileInfo($application->getSessionDir()) ); // create the applications temporary directories foreach ($tmpFolders as $tmpFolder) { $this->createDirectory($tmpFolder); } }
php
public function createTmpFolders(ApplicationInterface $application) { // create the directory we want to store the sessions in $tmpFolders = array( new \SplFileInfo($application->getTmpDir()), new \SplFileInfo($application->getDataDir()), new \SplFileInfo($application->getCacheDir()), new \SplFileInfo($application->getSessionDir()) ); // create the applications temporary directories foreach ($tmpFolders as $tmpFolder) { $this->createDirectory($tmpFolder); } }
[ "public", "function", "createTmpFolders", "(", "ApplicationInterface", "$", "application", ")", "{", "// create the directory we want to store the sessions in", "$", "tmpFolders", "=", "array", "(", "new", "\\", "SplFileInfo", "(", "$", "application", "->", "getTmpDir", ...
Creates the temporary directory for the webapp. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application to create the temporary directories for @return void
[ "Creates", "the", "temporary", "directory", "for", "the", "webapp", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L265-L280
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AppService.php
AppService.cleanUpFolders
public function cleanUpFolders(ApplicationInterface $application) { // load the directories we want to clean-up on appserver restart $cleanUpFolders = array(new \SplFileInfo($application->getCacheDir())); // clean-up the directories foreach ($cleanUpFolders as $cleanUpFolder) { $this->cleanUpDir($cleanUpFolder); } }
php
public function cleanUpFolders(ApplicationInterface $application) { // load the directories we want to clean-up on appserver restart $cleanUpFolders = array(new \SplFileInfo($application->getCacheDir())); // clean-up the directories foreach ($cleanUpFolders as $cleanUpFolder) { $this->cleanUpDir($cleanUpFolder); } }
[ "public", "function", "cleanUpFolders", "(", "ApplicationInterface", "$", "application", ")", "{", "// load the directories we want to clean-up on appserver restart", "$", "cleanUpFolders", "=", "array", "(", "new", "\\", "SplFileInfo", "(", "$", "application", "->", "get...
Clean up the the directories for the webapp, e. g. to delete cached stuff that has to be recreated after a restart. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application to clean up the directories for @return void
[ "Clean", "up", "the", "the", "directories", "for", "the", "webapp", "e", ".", "g", ".", "to", "delete", "cached", "stuff", "that", "has", "to", "be", "recreated", "after", "a", "restart", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AppService.php#L290-L300
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/UpstreamServersNodeTrait.php
UpstreamServersNodeTrait.getUpstreamServersAsArray
public function getUpstreamServersAsArray() { // iterate over all upstream servers nodes and transform them to an array $upstreamServers = array(); /** @var \AppserverIo\Appserver\Core\Api\Node\UpstreamServerNode $upstreamServerNode */ foreach ($this->getUpstreamServers() as $upstreamServerNode) { // build up array $upstreamServers[] = array( 'name' => $upstreamServerNode->getName(), 'type' => $upstreamServerNode->getType(), 'params' => $upstreamServerNode->getParamsAsArray() ); } // return upstream servers array return $upstreamServers; }
php
public function getUpstreamServersAsArray() { // iterate over all upstream servers nodes and transform them to an array $upstreamServers = array(); /** @var \AppserverIo\Appserver\Core\Api\Node\UpstreamServerNode $upstreamServerNode */ foreach ($this->getUpstreamServers() as $upstreamServerNode) { // build up array $upstreamServers[] = array( 'name' => $upstreamServerNode->getName(), 'type' => $upstreamServerNode->getType(), 'params' => $upstreamServerNode->getParamsAsArray() ); } // return upstream servers array return $upstreamServers; }
[ "public", "function", "getUpstreamServersAsArray", "(", ")", "{", "// iterate over all upstream servers nodes and transform them to an array", "$", "upstreamServers", "=", "array", "(", ")", ";", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\UpstreamServerNode $upstreamServerNode ...
Returns the upstream servers as an associative array @return array The array with the upstream servers
[ "Returns", "the", "upstream", "servers", "as", "an", "associative", "array" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/UpstreamServersNodeTrait.php#L59-L74
appserver-io/appserver
src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php
Setup.getLinuxDistro
public static function getLinuxDistro() { // declare Linux distros (extensible list). $distros = array( SetupKeys::OS_ARCH => 'arch-release', SetupKeys::OS_DEBIAN => 'debian_version', SetupKeys::OS_FEDORA => 'fedora-release', SetupKeys::OS_UBUNTU => 'lsb-release', SetupKeys::OS_REDHAT => 'redhat-release', SetupKeys::OS_CENTOS => 'centos-release' ); // get everything from /etc directory. $etcList = scandir('/etc'); // loop through /etc results... $distro = ''; // iterate over all found files foreach ($etcList as $entry) { // loop through list of distros.. foreach ($distros as $distroReleaseFile) { // match was found. if ($distroReleaseFile === $entry) { // find distros array key (i.e. distro name) by value (i.e. distro release file) $distro = array_search($distroReleaseFile, $distros); break 2; // break inner and outer loop. } } } // return the found distro string return $distro; }
php
public static function getLinuxDistro() { // declare Linux distros (extensible list). $distros = array( SetupKeys::OS_ARCH => 'arch-release', SetupKeys::OS_DEBIAN => 'debian_version', SetupKeys::OS_FEDORA => 'fedora-release', SetupKeys::OS_UBUNTU => 'lsb-release', SetupKeys::OS_REDHAT => 'redhat-release', SetupKeys::OS_CENTOS => 'centos-release' ); // get everything from /etc directory. $etcList = scandir('/etc'); // loop through /etc results... $distro = ''; // iterate over all found files foreach ($etcList as $entry) { // loop through list of distros.. foreach ($distros as $distroReleaseFile) { // match was found. if ($distroReleaseFile === $entry) { // find distros array key (i.e. distro name) by value (i.e. distro release file) $distro = array_search($distroReleaseFile, $distros); break 2; // break inner and outer loop. } } } // return the found distro string return $distro; }
[ "public", "static", "function", "getLinuxDistro", "(", ")", "{", "// declare Linux distros (extensible list).", "$", "distros", "=", "array", "(", "SetupKeys", "::", "OS_ARCH", "=>", "'arch-release'", ",", "SetupKeys", "::", "OS_DEBIAN", "=>", "'debian_version'", ",",...
Returns the Linux distribution we're running on. @return string The Linux distribution we're running on
[ "Returns", "the", "Linux", "distribution", "we", "re", "running", "on", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php#L111-L145
appserver-io/appserver
src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php
Setup.prepareProperties
public static function prepareProperties($os, array $contextProperties) { // merge all properties Setup::$mergedProperties = array_merge( $contextProperties, Setup::$defaultProperties, Setup::$osProperties[$os] ); // prepare the properties for the OS identifier, e. g. iron-horse_debian_x86_64 Setup::$mergedProperties[SetupKeys::OS_IDENTIFIER] = sprintf( '%s_%s_%s', str_replace(' ', '-', strtolower(Setup::$mergedProperties[SetupKeys::RELEASE_NAME])), $os, Setup::$mergedProperties[SetupKeys::OS_ARCHITECTURE] ); // prepare the properties for the software identifier, e. g. appserver/1.0.0 (debian) PHP/5.5.21 Setup::$mergedProperties[SetupKeys::SOFTWARE_IDENTIFIER] = sprintf( 'appserver/%s (%s) PHP/%s', Setup::$mergedProperties[SetupKeys::VERSION], Setup::$mergedProperties[SetupKeys::OS_FAMILY], Setup::$mergedProperties[SetupKeys::PHP_VERSION] ); }
php
public static function prepareProperties($os, array $contextProperties) { // merge all properties Setup::$mergedProperties = array_merge( $contextProperties, Setup::$defaultProperties, Setup::$osProperties[$os] ); // prepare the properties for the OS identifier, e. g. iron-horse_debian_x86_64 Setup::$mergedProperties[SetupKeys::OS_IDENTIFIER] = sprintf( '%s_%s_%s', str_replace(' ', '-', strtolower(Setup::$mergedProperties[SetupKeys::RELEASE_NAME])), $os, Setup::$mergedProperties[SetupKeys::OS_ARCHITECTURE] ); // prepare the properties for the software identifier, e. g. appserver/1.0.0 (debian) PHP/5.5.21 Setup::$mergedProperties[SetupKeys::SOFTWARE_IDENTIFIER] = sprintf( 'appserver/%s (%s) PHP/%s', Setup::$mergedProperties[SetupKeys::VERSION], Setup::$mergedProperties[SetupKeys::OS_FAMILY], Setup::$mergedProperties[SetupKeys::PHP_VERSION] ); }
[ "public", "static", "function", "prepareProperties", "(", "$", "os", ",", "array", "$", "contextProperties", ")", "{", "// merge all properties", "Setup", "::", "$", "mergedProperties", "=", "array_merge", "(", "$", "contextProperties", ",", "Setup", "::", "$", ...
Merge the properties based on the passed OS. @param string $os The OS we want to merge the properties for @param array $contextProperties The properties to merge @return void
[ "Merge", "the", "properties", "based", "on", "the", "passed", "OS", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php#L155-L180
appserver-io/appserver
src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php
Setup.prepareContext
public static function prepareContext($installDir = null, $event = null) { // initialize the installation directory if (is_null($installDir)) { $installDir = getcwd(); } // check if we've a file with the actual version number $version = ''; if (file_exists($filename = $installDir .'/etc/appserver/.release-version')) { $version = file_get_contents($filename); } else { // load the version (GIT) of this package as fallback if called with event instance if (!is_null($event)) { $version = $event->getComposer()->getPackage()->getPrettyVersion(); } } // check if we've a file with the actual release name if (file_exists($filename = $installDir .'/etc/appserver/.release-name')) { $releaseName = file_get_contents($filename); } else { // set the release name to 'Unknown' if not $releaseName = 'Unknown'; } // prepare the context properties $contextProperties = array( SetupKeys::VERSION => $version, SetupKeys::INSTALL_DIR => $installDir, SetupKeys::RELEASE_NAME => $releaseName ); // load the OS signature => sscanf is necessary to detect Windows, e. g. Windows NT for Windows 7 list($os, ) = sscanf(strtolower(php_uname('s')), '%s %s'); // check what OS we are running on switch ($os) { // installation running on Linux case SetupKeys::OS_FAMILY_LINUX: // get the distribution $distribution = Setup::getLinuxDistro(); // if we cant find one of the supported systems if ($distribution == null) { // set debian as default $distribution = SetupKeys::OS_DEBIAN; // write a message to the console if called with event instance if (!is_null($event)) { $event->getIo()->write( sprintf( '<warning>Unknown Linux distribution found, use Debian default values: ' . 'Please check user/group configuration in etc/appserver/appserver.xml</warning>' ) ); } } // merge the properties for the found Linux distribution Setup::prepareProperties($distribution, $contextProperties); break; // installation running on Mac OS X case SetupKeys::OS_FAMILY_DARWIN: // merge the properties for Mac OS X Setup::prepareProperties($os, $contextProperties); break; // installation running on Windows case SetupKeys::OS_FAMILY_WINDOWS: // merge the properties for Windows Setup::prepareProperties($os, $contextProperties); break; // all other OS are NOT supported actually default: break; } }
php
public static function prepareContext($installDir = null, $event = null) { // initialize the installation directory if (is_null($installDir)) { $installDir = getcwd(); } // check if we've a file with the actual version number $version = ''; if (file_exists($filename = $installDir .'/etc/appserver/.release-version')) { $version = file_get_contents($filename); } else { // load the version (GIT) of this package as fallback if called with event instance if (!is_null($event)) { $version = $event->getComposer()->getPackage()->getPrettyVersion(); } } // check if we've a file with the actual release name if (file_exists($filename = $installDir .'/etc/appserver/.release-name')) { $releaseName = file_get_contents($filename); } else { // set the release name to 'Unknown' if not $releaseName = 'Unknown'; } // prepare the context properties $contextProperties = array( SetupKeys::VERSION => $version, SetupKeys::INSTALL_DIR => $installDir, SetupKeys::RELEASE_NAME => $releaseName ); // load the OS signature => sscanf is necessary to detect Windows, e. g. Windows NT for Windows 7 list($os, ) = sscanf(strtolower(php_uname('s')), '%s %s'); // check what OS we are running on switch ($os) { // installation running on Linux case SetupKeys::OS_FAMILY_LINUX: // get the distribution $distribution = Setup::getLinuxDistro(); // if we cant find one of the supported systems if ($distribution == null) { // set debian as default $distribution = SetupKeys::OS_DEBIAN; // write a message to the console if called with event instance if (!is_null($event)) { $event->getIo()->write( sprintf( '<warning>Unknown Linux distribution found, use Debian default values: ' . 'Please check user/group configuration in etc/appserver/appserver.xml</warning>' ) ); } } // merge the properties for the found Linux distribution Setup::prepareProperties($distribution, $contextProperties); break; // installation running on Mac OS X case SetupKeys::OS_FAMILY_DARWIN: // merge the properties for Mac OS X Setup::prepareProperties($os, $contextProperties); break; // installation running on Windows case SetupKeys::OS_FAMILY_WINDOWS: // merge the properties for Windows Setup::prepareProperties($os, $contextProperties); break; // all other OS are NOT supported actually default: break; } }
[ "public", "static", "function", "prepareContext", "(", "$", "installDir", "=", "null", ",", "$", "event", "=", "null", ")", "{", "// initialize the installation directory", "if", "(", "is_null", "(", "$", "installDir", ")", ")", "{", "$", "installDir", "=", ...
Prepares the context by given event or without event for other usage @param null|string $installDir The install dir to check for info files @param null|Event $event The event instance or null @return void
[ "Prepares", "the", "context", "by", "given", "event", "or", "without", "event", "for", "other", "usage" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php#L190-L273
appserver-io/appserver
src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php
Setup.postInstall
public static function postInstall(Event $event) { // initialize the installation directory $override = false; $installDir = getcwd(); // check the arguments for an installation directory foreach ($event->getArguments() as $arg) { // extract arguments list ($key, ) = explode('=', $arg); // query we want to override files if ($key === SetupKeys::ARG_OVERRIDE) { $override = true; } // query for a custom installation directory if ($key === SetupKeys::ARG_INSTALL_DIR) { $installDir = str_replace("$key=", '', $arg); } } Setup::prepareContext($installDir, $event); // process and move the configuration files their target directory Setup::processTemplate('etc/appserver/appserver.xml', $override); Setup::processTemplate('etc/appserver/appserver-runner.xml', $override); // write a message to the console $event->getIo()->write( sprintf( '%s<info>Successfully invoked appserver.io Composer post-install-cmd script ...</info>', Setup::$logo ) ); }
php
public static function postInstall(Event $event) { // initialize the installation directory $override = false; $installDir = getcwd(); // check the arguments for an installation directory foreach ($event->getArguments() as $arg) { // extract arguments list ($key, ) = explode('=', $arg); // query we want to override files if ($key === SetupKeys::ARG_OVERRIDE) { $override = true; } // query for a custom installation directory if ($key === SetupKeys::ARG_INSTALL_DIR) { $installDir = str_replace("$key=", '', $arg); } } Setup::prepareContext($installDir, $event); // process and move the configuration files their target directory Setup::processTemplate('etc/appserver/appserver.xml', $override); Setup::processTemplate('etc/appserver/appserver-runner.xml', $override); // write a message to the console $event->getIo()->write( sprintf( '%s<info>Successfully invoked appserver.io Composer post-install-cmd script ...</info>', Setup::$logo ) ); }
[ "public", "static", "function", "postInstall", "(", "Event", "$", "event", ")", "{", "// initialize the installation directory", "$", "override", "=", "false", ";", "$", "installDir", "=", "getcwd", "(", ")", ";", "// check the arguments for an installation directory", ...
This method will be invoked by composer after a successful installation and creates the application server configuration file under etc/appserver/appserver.xml. @param \Composer\Script\Event $event The event that invokes this method @return void
[ "This", "method", "will", "be", "invoked", "by", "composer", "after", "a", "successful", "installation", "and", "creates", "the", "application", "server", "configuration", "file", "under", "etc", "/", "appserver", "/", "appserver", ".", "xml", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php#L296-L329
appserver-io/appserver
src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php
Setup.copyOsSpecificResource
public static function copyOsSpecificResource($os, $resource, $override = false, $mode = 0644) { // we need the installation directory $installDir = Setup::getValue(SetupKeys::INSTALL_DIR); // prepare source and target directory $source = Setup::prepareOsSpecificPath(sprintf('%s/resources/os-specific/%s/%s', $installDir, $os, $resource)); $target = Setup::prepareOsSpecificPath(sprintf('%s/%s', $installDir, $resource)); // query whether we've to override the file if ($override === false && is_file($target) === true) { return; } // prepare the target directory Setup::prepareDirectory($target); // copy the file to the target directory copy($source, $target); // set the correct mode for the file Setup::changeFilePermissions($target, $mode); }
php
public static function copyOsSpecificResource($os, $resource, $override = false, $mode = 0644) { // we need the installation directory $installDir = Setup::getValue(SetupKeys::INSTALL_DIR); // prepare source and target directory $source = Setup::prepareOsSpecificPath(sprintf('%s/resources/os-specific/%s/%s', $installDir, $os, $resource)); $target = Setup::prepareOsSpecificPath(sprintf('%s/%s', $installDir, $resource)); // query whether we've to override the file if ($override === false && is_file($target) === true) { return; } // prepare the target directory Setup::prepareDirectory($target); // copy the file to the target directory copy($source, $target); // set the correct mode for the file Setup::changeFilePermissions($target, $mode); }
[ "public", "static", "function", "copyOsSpecificResource", "(", "$", "os", ",", "$", "resource", ",", "$", "override", "=", "false", ",", "$", "mode", "=", "0644", ")", "{", "// we need the installation directory", "$", "installDir", "=", "Setup", "::", "getVal...
Copies the passed OS specific resource file to the target directory. @param string $os The OS we want to copy the files for @param string $resource The resource file we want to copy @param boolean $override TRUE if the file should be overwritten if exists, else FALSE @param integer $mode The mode of the target file @return void
[ "Copies", "the", "passed", "OS", "specific", "resource", "file", "to", "the", "target", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php#L355-L378
appserver-io/appserver
src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php
Setup.processOsSpecificTemplate
public static function processOsSpecificTemplate($os, $template, $override = false, $mode = 0644) { // prepare the target filename $targetFile = Setup::prepareOsSpecificPath($template); // query whether we've to override the file if ($override === false && is_file($targetFile) === true) { return; } // prepare the target directory Setup::prepareDirectory($template); // process the template and store the result in the passed file ob_start(); include Setup::prepareOsSpecificPath(sprintf('resources/templates/os-specific/%s/%s.phtml', $os, $template)); file_put_contents($targetFile, ob_get_clean()); // set the correct mode for the file Setup::changeFilePermissions($template, $mode); }
php
public static function processOsSpecificTemplate($os, $template, $override = false, $mode = 0644) { // prepare the target filename $targetFile = Setup::prepareOsSpecificPath($template); // query whether we've to override the file if ($override === false && is_file($targetFile) === true) { return; } // prepare the target directory Setup::prepareDirectory($template); // process the template and store the result in the passed file ob_start(); include Setup::prepareOsSpecificPath(sprintf('resources/templates/os-specific/%s/%s.phtml', $os, $template)); file_put_contents($targetFile, ob_get_clean()); // set the correct mode for the file Setup::changeFilePermissions($template, $mode); }
[ "public", "static", "function", "processOsSpecificTemplate", "(", "$", "os", ",", "$", "template", ",", "$", "override", "=", "false", ",", "$", "mode", "=", "0644", ")", "{", "// prepare the target filename", "$", "targetFile", "=", "Setup", "::", "prepareOsS...
Processes the OS specific template and replace the properties with the OS specific values. @param string $os The OS we want to process the template for @param string $template The path to the template @param boolean $override TRUE if the file should be overwritten if exists, else FALSE @param integer $mode The mode of the target file @return void
[ "Processes", "the", "OS", "specific", "template", "and", "replace", "the", "properties", "with", "the", "OS", "specific", "values", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php#L390-L411
appserver-io/appserver
src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php
Setup.changeFilePermissions
public static function changeFilePermissions($filename, $mode = 0644) { // make the passed filename OS compliant $toBeChanged = Setup::prepareOsSpecificPath($filename); // change the mode, if we're not on Windows if (SetupKeys::OS_FAMILY_WINDOWS !== strtolower(php_uname('s'))) { chmod($toBeChanged, $mode); } }
php
public static function changeFilePermissions($filename, $mode = 0644) { // make the passed filename OS compliant $toBeChanged = Setup::prepareOsSpecificPath($filename); // change the mode, if we're not on Windows if (SetupKeys::OS_FAMILY_WINDOWS !== strtolower(php_uname('s'))) { chmod($toBeChanged, $mode); } }
[ "public", "static", "function", "changeFilePermissions", "(", "$", "filename", ",", "$", "mode", "=", "0644", ")", "{", "// make the passed filename OS compliant", "$", "toBeChanged", "=", "Setup", "::", "prepareOsSpecificPath", "(", "$", "filename", ")", ";", "//...
Sets the passed mode for the file if NOT on Windows. @param string $filename The filename to set the mode for @param integer $mode The mode to set @return void
[ "Sets", "the", "passed", "mode", "for", "the", "file", "if", "NOT", "on", "Windows", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php#L453-L463
appserver-io/appserver
src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php
Setup.prepareDirectory
public static function prepareDirectory($directory, $mode = 0775) { // make the passed directory OS compliant $toBePreapared = Setup::prepareOsSpecificPath($directory); // make sure the directory exists if (is_dir(dirname($toBePreapared)) === false) { mkdir(dirname($toBePreapared), $mode, true); } }
php
public static function prepareDirectory($directory, $mode = 0775) { // make the passed directory OS compliant $toBePreapared = Setup::prepareOsSpecificPath($directory); // make sure the directory exists if (is_dir(dirname($toBePreapared)) === false) { mkdir(dirname($toBePreapared), $mode, true); } }
[ "public", "static", "function", "prepareDirectory", "(", "$", "directory", ",", "$", "mode", "=", "0775", ")", "{", "// make the passed directory OS compliant", "$", "toBePreapared", "=", "Setup", "::", "prepareOsSpecificPath", "(", "$", "directory", ")", ";", "//...
Prepares the passed directory if necessary. @param string $directory The directory to prepare @param integer $mode The mode of the directory @return void
[ "Prepares", "the", "passed", "directory", "if", "necessary", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Meta/Composer/Script/Setup.php#L473-L483
appserver-io/appserver
src/AppserverIo/Appserver/Core/ProxyClassLoaderFactory.php
ProxyClassLoaderFactory.visit
public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration) { $application->addClassLoader(new ProxyClassLoader($application->getCacheDir()), $configuration); }
php
public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration) { $application->addClassLoader(new ProxyClassLoader($application->getCacheDir()), $configuration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ClassLoaderNodeInterface", "$", "configuration", ")", "{", "$", "application", "->", "addClassLoader", "(", "new", "ProxyClassLoader", "(", "$", "application", "->", "get...
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/ProxyClassLoaderFactory.php#L47-L50
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoader.php
DgClassLoader.init
public function init(StackableStructureMap $structureMap, AspectRegister $aspectRegister) { // collect the passed instances $this->structureMap = $structureMap; $this->aspectRegister = $aspectRegister; // load the configuration $config = $this->getConfig(); // pre-load the configuration values $this->cacheDir = $config->getValue('cache/dir'); $this->environment = $config->getValue('environment'); // we want to know if there are namespaces to be omitted from autoloading if ($config->hasValue('autoloader/omit')) { $autoloadingOmitted = $config->getValue('autoloader/omit'); $this->autoloaderOmit = !empty($autoloadingOmitted); } // we now have a structure map instance, so fill it initially $this->getStructureMap()->fill(); }
php
public function init(StackableStructureMap $structureMap, AspectRegister $aspectRegister) { // collect the passed instances $this->structureMap = $structureMap; $this->aspectRegister = $aspectRegister; // load the configuration $config = $this->getConfig(); // pre-load the configuration values $this->cacheDir = $config->getValue('cache/dir'); $this->environment = $config->getValue('environment'); // we want to know if there are namespaces to be omitted from autoloading if ($config->hasValue('autoloader/omit')) { $autoloadingOmitted = $config->getValue('autoloader/omit'); $this->autoloaderOmit = !empty($autoloadingOmitted); } // we now have a structure map instance, so fill it initially $this->getStructureMap()->fill(); }
[ "public", "function", "init", "(", "StackableStructureMap", "$", "structureMap", ",", "AspectRegister", "$", "aspectRegister", ")", "{", "// collect the passed instances", "$", "this", "->", "structureMap", "=", "$", "structureMap", ";", "$", "this", "->", "aspectRe...
Initializes the autoloader with the values from the configuration and creates and fills the structure map instance. @param \AppserverIo\Appserver\Core\StackableStructureMap $structureMap Structure map to be used @param \AppserverIo\Doppelgaenger\AspectRegister $aspectRegister The register for all found aspects @return void
[ "Initializes", "the", "autoloader", "with", "the", "values", "from", "the", "configuration", "and", "creates", "and", "fills", "the", "structure", "map", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoader.php#L109-L131
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoader.php
DgClassLoader.createCache
public function createCache() { // Check if there are files in the cache. // If not we will fill the cache, if there are we will check if there have been any changes to the enforced dirs $fileIterator = new \FilesystemIterator($this->getConfig()->getValue('cache/dir'), \FilesystemIterator::SKIP_DOTS); if (iterator_count($fileIterator) <= 1 || $this->getConfig()->getValue('environment') === 'development') { // Fill the cache $this->fillCache(); } else { if (!$this->structureMap->isRecent()) { $this->refillCache(); } } }
php
public function createCache() { // Check if there are files in the cache. // If not we will fill the cache, if there are we will check if there have been any changes to the enforced dirs $fileIterator = new \FilesystemIterator($this->getConfig()->getValue('cache/dir'), \FilesystemIterator::SKIP_DOTS); if (iterator_count($fileIterator) <= 1 || $this->getConfig()->getValue('environment') === 'development') { // Fill the cache $this->fillCache(); } else { if (!$this->structureMap->isRecent()) { $this->refillCache(); } } }
[ "public", "function", "createCache", "(", ")", "{", "// Check if there are files in the cache.", "// If not we will fill the cache, if there are we will check if there have been any changes to the enforced dirs", "$", "fileIterator", "=", "new", "\\", "FilesystemIterator", "(", "$", ...
Will start the generation of the cache based on the known structures @return null
[ "Will", "start", "the", "generation", "of", "the", "cache", "based", "on", "the", "known", "structures" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoader.php#L150-L164
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoader.php
DgClassLoader.createDefinitions
protected function createDefinitions() { // Get all the structures we found $structures = $this->structureMap->getEntries(); // We will need a CacheMap instance which we can pass to the generator // We need the caching configuration $cacheMap = new CacheMap($this->getConfig()->getValue('cache/dir'), array(), $this->getConfig()); // We need a generator so we can create our proxies initially $generator = new Generator($this->structureMap, $cacheMap, $this->getConfig(), $this->getAspectRegister()); // Iterate over all found structures and generate their proxies, but ignore the ones with omitted // namespaces $omittedNamespaces = array(); if ($this->getConfig()->hasValue('autoloader/omit')) { $omittedNamespaces = $this->getConfig()->getValue('autoloader/omit'); } // Now check which structures we have to create and split them up for multi-threaded creation $generatorStack = array(); /** @var \AppserverIo\Doppelgaenger\Entities\Definitions\Structure $structure */ foreach ($structures as $identifier => $structure) { // Working on our own files has very weird side effects, so don't do it if (strpos($structure->getIdentifier(), 'AppserverIo\Doppelgaenger') !== false) { continue; } // Might this be an omitted structure after all? foreach ($omittedNamespaces as $omittedNamespace) { // If our class name begins with the omitted part e.g. it's namespace if (strpos($structure->getIdentifier(), $omittedNamespace) === 0) { continue 2; } } // adding all structures to the generator stack as we cannot assure cross references from aspects here $generatorStack[$identifier] = $structure; } // Chuck the stack and start generating $generatorStack = array_chunk($generatorStack, self::GENERATOR_STACK_COUNT, true); // Generate all the structures! $generatorThreads = array(); foreach ($generatorStack as $key => $generatorStackChunk) { $generatorThreads[$key] = new GeneratorThread($generator, $generatorStackChunk); $generatorThreads[$key]->start(); } // Wait on the threads foreach ($generatorThreads as $generatorThread) { $generatorThread->join(); } // mark this instance as production ready cachewise $this->cacheIsReady = true; // Still here? Sounds about right return true; }
php
protected function createDefinitions() { // Get all the structures we found $structures = $this->structureMap->getEntries(); // We will need a CacheMap instance which we can pass to the generator // We need the caching configuration $cacheMap = new CacheMap($this->getConfig()->getValue('cache/dir'), array(), $this->getConfig()); // We need a generator so we can create our proxies initially $generator = new Generator($this->structureMap, $cacheMap, $this->getConfig(), $this->getAspectRegister()); // Iterate over all found structures and generate their proxies, but ignore the ones with omitted // namespaces $omittedNamespaces = array(); if ($this->getConfig()->hasValue('autoloader/omit')) { $omittedNamespaces = $this->getConfig()->getValue('autoloader/omit'); } // Now check which structures we have to create and split them up for multi-threaded creation $generatorStack = array(); /** @var \AppserverIo\Doppelgaenger\Entities\Definitions\Structure $structure */ foreach ($structures as $identifier => $structure) { // Working on our own files has very weird side effects, so don't do it if (strpos($structure->getIdentifier(), 'AppserverIo\Doppelgaenger') !== false) { continue; } // Might this be an omitted structure after all? foreach ($omittedNamespaces as $omittedNamespace) { // If our class name begins with the omitted part e.g. it's namespace if (strpos($structure->getIdentifier(), $omittedNamespace) === 0) { continue 2; } } // adding all structures to the generator stack as we cannot assure cross references from aspects here $generatorStack[$identifier] = $structure; } // Chuck the stack and start generating $generatorStack = array_chunk($generatorStack, self::GENERATOR_STACK_COUNT, true); // Generate all the structures! $generatorThreads = array(); foreach ($generatorStack as $key => $generatorStackChunk) { $generatorThreads[$key] = new GeneratorThread($generator, $generatorStackChunk); $generatorThreads[$key]->start(); } // Wait on the threads foreach ($generatorThreads as $generatorThread) { $generatorThread->join(); } // mark this instance as production ready cachewise $this->cacheIsReady = true; // Still here? Sounds about right return true; }
[ "protected", "function", "createDefinitions", "(", ")", "{", "// Get all the structures we found", "$", "structures", "=", "$", "this", "->", "structureMap", "->", "getEntries", "(", ")", ";", "// We will need a CacheMap instance which we can pass to the generator", "// We ne...
Creates the definitions by given structure map @return bool
[ "Creates", "the", "definitions", "by", "given", "structure", "map" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoader.php#L171-L231
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoader.php
DgClassLoader.loadClassProductionNoOmit
public function loadClassProductionNoOmit($className) { // prepare the cache path $cachePath = $this->cacheDir . DIRECTORY_SEPARATOR . str_replace('\\', '_', $className) . '.php'; // check if the file is readable if (is_readable($cachePath)) { require $cachePath; return; } }
php
public function loadClassProductionNoOmit($className) { // prepare the cache path $cachePath = $this->cacheDir . DIRECTORY_SEPARATOR . str_replace('\\', '_', $className) . '.php'; // check if the file is readable if (is_readable($cachePath)) { require $cachePath; return; } }
[ "public", "function", "loadClassProductionNoOmit", "(", "$", "className", ")", "{", "// prepare the cache path", "$", "cachePath", "=", "$", "this", "->", "cacheDir", ".", "DIRECTORY_SEPARATOR", ".", "str_replace", "(", "'\\\\'", ",", "'_'", ",", "$", "className",...
Will load any given structure based on it's availability in our structure map which depends on the configured project directories. If the structure cannot be found we will redirect to the composer autoloader which we registered as a fallback @param string $className The name of the structure we will try to load @return null
[ "Will", "load", "any", "given", "structure", "based", "on", "it", "s", "availability", "in", "our", "structure", "map", "which", "depends", "on", "the", "configured", "project", "directories", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoader.php#L296-L307
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoader.php
DgClassLoader.loadClass
public function loadClass($className) { // might the class be a omitted one? If so we can require the original. if ($this->autoloaderOmit) { $omittedNamespaces = $this->config->getValue('autoloader/omit'); foreach ($omittedNamespaces as $omitted) { // If our class name begins with the omitted part e.g. it's namespace if (strpos($className, str_replace('\\\\', '\\', $omitted)) === 0) { return; } } } // do we have the file in our cache dir? If we are in development mode we have to ignore this. if ($this->environment !== 'development') { $this->loadClassProductionNoOmit($className); if (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false)) { return true; } } // if we are loading something of our own library we can skip to composer if (strpos($className, 'AppserverIo\Doppelgaenger') === 0 || strpos($className, 'AppserverIo\Appserver\Core\StackableStructureMap') !== false) { return; } // get the file from the map $file = $this->structureMap->getEntry($className); // did we get something? If so we have to load it if ($file instanceof Structure) { require $file->getPath(); return true; } }
php
public function loadClass($className) { // might the class be a omitted one? If so we can require the original. if ($this->autoloaderOmit) { $omittedNamespaces = $this->config->getValue('autoloader/omit'); foreach ($omittedNamespaces as $omitted) { // If our class name begins with the omitted part e.g. it's namespace if (strpos($className, str_replace('\\\\', '\\', $omitted)) === 0) { return; } } } // do we have the file in our cache dir? If we are in development mode we have to ignore this. if ($this->environment !== 'development') { $this->loadClassProductionNoOmit($className); if (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false)) { return true; } } // if we are loading something of our own library we can skip to composer if (strpos($className, 'AppserverIo\Doppelgaenger') === 0 || strpos($className, 'AppserverIo\Appserver\Core\StackableStructureMap') !== false) { return; } // get the file from the map $file = $this->structureMap->getEntry($className); // did we get something? If so we have to load it if ($file instanceof Structure) { require $file->getPath(); return true; } }
[ "public", "function", "loadClass", "(", "$", "className", ")", "{", "// might the class be a omitted one? If so we can require the original.", "if", "(", "$", "this", "->", "autoloaderOmit", ")", "{", "$", "omittedNamespaces", "=", "$", "this", "->", "config", "->", ...
Will load any given structure based on it's availability in our structure map which depends on the configured project directories. If the structure cannot be found we will redirect to the composer autoloader which we registered as a fallback @param string $className The name of the structure we will try to load @return null
[ "Will", "load", "any", "given", "structure", "based", "on", "it", "s", "availability", "in", "our", "structure", "map", "which", "depends", "on", "the", "configured", "project", "directories", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoader.php#L319-L354
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoader.php
DgClassLoader.refillCache
protected function refillCache() { // lets clear the cache so we can fill it anew foreach (new \DirectoryIterator($this->getConfig()->getValue('cache/dir')) as $fileInfo) { if (!$fileInfo->isDot() && !$fileInfo->isDir()) { // unlink the file unlink($fileInfo->getPathname()); } } // lets create the definitions anew return $this->createDefinitions(); }
php
protected function refillCache() { // lets clear the cache so we can fill it anew foreach (new \DirectoryIterator($this->getConfig()->getValue('cache/dir')) as $fileInfo) { if (!$fileInfo->isDot() && !$fileInfo->isDir()) { // unlink the file unlink($fileInfo->getPathname()); } } // lets create the definitions anew return $this->createDefinitions(); }
[ "protected", "function", "refillCache", "(", ")", "{", "// lets clear the cache so we can fill it anew", "foreach", "(", "new", "\\", "DirectoryIterator", "(", "$", "this", "->", "getConfig", "(", ")", "->", "getValue", "(", "'cache/dir'", ")", ")", "as", "$", "...
We will refill the cache dir by emptying it and filling it again @return bool
[ "We", "will", "refill", "the", "cache", "dir", "by", "emptying", "it", "and", "filling", "it", "again" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoader.php#L361-L374
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoader.php
DgClassLoader.register
public function register($throw = true, $prepend = true) { // now we have a config no matter what, we can store any instance we might need $this->getConfig()->storeInstances(); // query whether the cache is ready or if we aren't in production mode if (!$this->cacheIsReady || $this->environment !== 'production') { // If yes, load the appropriate autoloader method spl_autoload_register(array($this, self::OUR_LOADER), $throw, $prepend); return; } // the cache is ready, so register the simple class loader spl_autoload_register(array($this, self::OUR_LOADER_PROD_NO_OMIT), $throw, $prepend); }
php
public function register($throw = true, $prepend = true) { // now we have a config no matter what, we can store any instance we might need $this->getConfig()->storeInstances(); // query whether the cache is ready or if we aren't in production mode if (!$this->cacheIsReady || $this->environment !== 'production') { // If yes, load the appropriate autoloader method spl_autoload_register(array($this, self::OUR_LOADER), $throw, $prepend); return; } // the cache is ready, so register the simple class loader spl_autoload_register(array($this, self::OUR_LOADER_PROD_NO_OMIT), $throw, $prepend); }
[ "public", "function", "register", "(", "$", "throw", "=", "true", ",", "$", "prepend", "=", "true", ")", "{", "// now we have a config no matter what, we can store any instance we might need", "$", "this", "->", "getConfig", "(", ")", "->", "storeInstances", "(", ")...
Will register our autoloading method at the beginning of the spl autoloader stack @param boolean $throw Should we throw an exception on error? @param boolean $prepend If you want to NOT prepend you might, but you should not @return null
[ "Will", "register", "our", "autoloading", "method", "at", "the", "beginning", "of", "the", "spl", "autoloader", "stack" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoader.php#L384-L399
appserver-io/appserver
src/AppserverIo/Appserver/Core/DgClassLoader.php
DgClassLoader.unregister
public function unregister() { // query whether the cache is ready or if we aren't in production mode if (!$this->cacheIsReady || $this->environment !== 'production') { // If yes, unload the appropriate autoloader method spl_autoload_unregister(array($this, self::OUR_LOADER)); return; } // the cache has been ready, so unregister the simple class loader spl_autoload_unregister(array($this, self::OUR_LOADER_PROD_NO_OMIT)); }
php
public function unregister() { // query whether the cache is ready or if we aren't in production mode if (!$this->cacheIsReady || $this->environment !== 'production') { // If yes, unload the appropriate autoloader method spl_autoload_unregister(array($this, self::OUR_LOADER)); return; } // the cache has been ready, so unregister the simple class loader spl_autoload_unregister(array($this, self::OUR_LOADER_PROD_NO_OMIT)); }
[ "public", "function", "unregister", "(", ")", "{", "// query whether the cache is ready or if we aren't in production mode", "if", "(", "!", "$", "this", "->", "cacheIsReady", "||", "$", "this", "->", "environment", "!==", "'production'", ")", "{", "// If yes, unload th...
Uninstalls this class loader from the SPL autoloader stack. @return void
[ "Uninstalls", "this", "class", "loader", "from", "the", "SPL", "autoloader", "stack", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/DgClassLoader.php#L406-L418
appserver-io/appserver
src/AppserverIo/Appserver/Core/Storage.php
Storage.set
public function set($key, $value, $subKey = null) { if (!is_null($subKey) && (is_array($this->data[$key]))) { $this->data[$key][$subKey] = $value; } else { $this->data[$key] = $value; } }
php
public function set($key, $value, $subKey = null) { if (!is_null($subKey) && (is_array($this->data[$key]))) { $this->data[$key][$subKey] = $value; } else { $this->data[$key] = $value; } }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "subKey", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "subKey", ")", "&&", "(", "is_array", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ...
Sets value for specific key with optional subkey @param string $key The key to set value for @param mixed $value The value to set @param string $subKey The optional subKey to set value for @return void @Synchronized
[ "Sets", "value", "for", "specific", "key", "with", "optional", "subkey" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Storage.php#L62-L69
appserver-io/appserver
src/AppserverIo/Appserver/Core/Storage.php
Storage.get
public function get($key, $subKey = null) { if (!is_null($subKey) && (is_array($this->data[$key]))) { return $this->data[$key][$subKey]; } else { return $this->data[$key]; } }
php
public function get($key, $subKey = null) { if (!is_null($subKey) && (is_array($this->data[$key]))) { return $this->data[$key][$subKey]; } else { return $this->data[$key]; } }
[ "public", "function", "get", "(", "$", "key", ",", "$", "subKey", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "subKey", ")", "&&", "(", "is_array", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", ")", "{", "ret...
Gets value for specific key with optional subkey @param string $key The key to set value for @param string $subKey The optional subKey to set value for @return mixed
[ "Gets", "value", "for", "specific", "key", "with", "optional", "subkey" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Storage.php#L79-L86
appserver-io/appserver
src/AppserverIo/Appserver/Core/Storage.php
Storage.has
public function has($key, $subKey = null) { if (!is_null($subKey) && (is_array($this->data[$key]))) { return isset($this->data[$key][$subKey]); } else { return isset($this->data[$key]); } }
php
public function has($key, $subKey = null) { if (!is_null($subKey) && (is_array($this->data[$key]))) { return isset($this->data[$key][$subKey]); } else { return isset($this->data[$key]); } }
[ "public", "function", "has", "(", "$", "key", ",", "$", "subKey", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "subKey", ")", "&&", "(", "is_array", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", ")", "{", "ret...
Checks if specific key with options subkey exists @param string $key The key to set value for @param string $subKey The optional subKey to set value for @return bool
[ "Checks", "if", "specific", "key", "with", "options", "subkey", "exists" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Storage.php#L96-L103
appserver-io/appserver
src/AppserverIo/Appserver/Core/Storage.php
Storage.del
public function del($key, $subKey = null) { if (!is_null($subKey) && (is_array($this->data[$key]))) { unset($this->data[$key][$subKey]); } else { unset($this->data[$key]); } }
php
public function del($key, $subKey = null) { if (!is_null($subKey) && (is_array($this->data[$key]))) { unset($this->data[$key][$subKey]); } else { unset($this->data[$key]); } }
[ "public", "function", "del", "(", "$", "key", ",", "$", "subKey", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "subKey", ")", "&&", "(", "is_array", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", ")", "{", "uns...
Deletes specific key with options subkey entry in data @param string $key The key to set value for @param string $subKey The optional subKey to set value for @return void
[ "Deletes", "specific", "key", "with", "options", "subkey", "entry", "in", "data" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Storage.php#L113-L120
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Session/AbstractSessionHandler.php
AbstractSessionHandler.unmarshall
protected function unmarshall($marshalled) { // create a new and empty servlet session instance $servletSession = Session::emptyInstance(); // unmarshall the session data $this->getSessionMarshaller()->unmarshall($servletSession, $marshalled); // returns the initialized servlet session instance return $servletSession; }
php
protected function unmarshall($marshalled) { // create a new and empty servlet session instance $servletSession = Session::emptyInstance(); // unmarshall the session data $this->getSessionMarshaller()->unmarshall($servletSession, $marshalled); // returns the initialized servlet session instance return $servletSession; }
[ "protected", "function", "unmarshall", "(", "$", "marshalled", ")", "{", "// create a new and empty servlet session instance", "$", "servletSession", "=", "Session", "::", "emptyInstance", "(", ")", ";", "// unmarshall the session data", "$", "this", "->", "getSessionMars...
Initializes the session instance from the passed JSON string. If the encoded data contains objects, they will be unserialized before reattached to the session instance. @param string $marshalled The marshaled session representation @return \AppserverIo\Psr\Servlet\ServletSessionInterface The un-marshaled servlet session instance
[ "Initializes", "the", "session", "instance", "from", "the", "passed", "JSON", "string", ".", "If", "the", "encoded", "data", "contains", "objects", "they", "will", "be", "unserialized", "before", "reattached", "to", "the", "session", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Session/AbstractSessionHandler.php#L138-L149
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Session/AbstractSessionHandler.php
AbstractSessionHandler.sessionTimedOut
protected function sessionTimedOut(ServletSessionInterface $session) { // we want to know what inactivity timeout we've to check the sessions for $inactivityTimeout = $this->getSessionSettings()->getInactivityTimeout(); // load the sessions last activity timestamp $lastActivitySecondsAgo = time() - $session->getLastActivityTimestamp(); // query whether or not an inactivity timeout has been set if ($inactivityTimeout < 1) { // if NOT, the inactivity timeout has to be higher than // the last activity timestamp to avoid session timeout $inactivityTimeout = $lastActivitySecondsAgo + 1; } // return TRUE it the last ativity timeout OR the session lifetime has been reached return $lastActivitySecondsAgo > $inactivityTimeout || $session->getLifetime() < time(); }
php
protected function sessionTimedOut(ServletSessionInterface $session) { // we want to know what inactivity timeout we've to check the sessions for $inactivityTimeout = $this->getSessionSettings()->getInactivityTimeout(); // load the sessions last activity timestamp $lastActivitySecondsAgo = time() - $session->getLastActivityTimestamp(); // query whether or not an inactivity timeout has been set if ($inactivityTimeout < 1) { // if NOT, the inactivity timeout has to be higher than // the last activity timestamp to avoid session timeout $inactivityTimeout = $lastActivitySecondsAgo + 1; } // return TRUE it the last ativity timeout OR the session lifetime has been reached return $lastActivitySecondsAgo > $inactivityTimeout || $session->getLifetime() < time(); }
[ "protected", "function", "sessionTimedOut", "(", "ServletSessionInterface", "$", "session", ")", "{", "// we want to know what inactivity timeout we've to check the sessions for", "$", "inactivityTimeout", "=", "$", "this", "->", "getSessionSettings", "(", ")", "->", "getInac...
Querys whether or not the passed session has timed out. @param \AppserverIo\Psr\Servlet\ServletSessionInterface $session The session to query for @return boolean TRUE if the session has timed out, else FALSE
[ "Querys", "whether", "or", "not", "the", "passed", "session", "has", "timed", "out", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Session/AbstractSessionHandler.php#L158-L176
appserver-io/appserver
src/AppserverIo/Appserver/Doctrine/Utils/ConnectionUtil.php
ConnectionUtil.fromDatabaseNode
public function fromDatabaseNode(DatabaseConfigurationInterface $databaseNode) { // initialize the connection parameters with the mandatory driver $connectionParameters = array( 'driver' => $databaseNode->getDriver()->getNodeValue()->__toString() ); // initialize the path/memory to the database when we use sqlite for example if ($pathNode = $databaseNode->getPath()) { $connectionParameters['path'] = $pathNode->getNodeValue()->__toString(); } elseif ($memoryNode = $databaseNode->getMemory()) { $connectionParameters['memory'] = Boolean::valueOf(new String($memoryNode->getNodeValue()->__toString()))->booleanValue(); } else { // do nothing here, because there is NO option } // add username, if specified if ($userNode = $databaseNode->getUser()) { $connectionParameters['user'] = $userNode->getNodeValue()->__toString(); } // add password, if specified if ($passwordNode = $databaseNode->getPassword()) { $connectionParameters['password'] = $passwordNode->getNodeValue()->__toString(); } // add database name if using another PDO driver than sqlite if ($databaseNameNode = $databaseNode->getDatabaseName()) { $connectionParameters['dbname'] = $databaseNameNode->getNodeValue()->__toString(); } // add database host if using another PDO driver than sqlite if ($databaseHostNode = $databaseNode->getDatabaseHost()) { $connectionParameters['host'] = $databaseHostNode->getNodeValue()->__toString(); } // add database port if using another PDO driver than sqlite if ($databasePortNode = $databaseNode->getDatabasePort()) { $connectionParameters['port'] = $databasePortNode->getNodeValue()->__toString(); } // add charset, if specified if ($charsetNode = $databaseNode->getCharset()) { $connectionParameters['charset'] = $charsetNode->getNodeValue()->__toString(); } // add driver options, if specified if ($unixSocketNode = $databaseNode->getUnixSocket()) { $connectionParameters['unix_socket'] = $unixSocketNode->getNodeValue()->__toString(); } // add server version, if specified if ($serverVersionNode = $databaseNode->getServerVersion()) { $connectionParameters['server_version'] = $serverVersionNode->getNodeValue()->__toString(); } // set platform, if specified if ($platformNode = $databaseNode->getPlatform()) { $platform = $platformNode->getNodeValue()->__toString(); $connectionParameters['platform'] = new $platform(); } // add driver options, if specified if ($driverOptionsNode = $databaseNode->getDriverOptions()) { // explode the raw options separated with a semicolon $rawOptions = explode(';', $driverOptionsNode->getNodeValue()->__toString()); // prepare the array with the driver options key/value pair (separated with a =) $options = array(); foreach ($rawOptions as $rawOption) { list ($key, $value) = explode('=', $rawOption); $options[$key] = $value; } // set the driver options $connectionParameters['driverOptions'] = $options; } // returns the connection parameters return $connectionParameters; }
php
public function fromDatabaseNode(DatabaseConfigurationInterface $databaseNode) { // initialize the connection parameters with the mandatory driver $connectionParameters = array( 'driver' => $databaseNode->getDriver()->getNodeValue()->__toString() ); // initialize the path/memory to the database when we use sqlite for example if ($pathNode = $databaseNode->getPath()) { $connectionParameters['path'] = $pathNode->getNodeValue()->__toString(); } elseif ($memoryNode = $databaseNode->getMemory()) { $connectionParameters['memory'] = Boolean::valueOf(new String($memoryNode->getNodeValue()->__toString()))->booleanValue(); } else { // do nothing here, because there is NO option } // add username, if specified if ($userNode = $databaseNode->getUser()) { $connectionParameters['user'] = $userNode->getNodeValue()->__toString(); } // add password, if specified if ($passwordNode = $databaseNode->getPassword()) { $connectionParameters['password'] = $passwordNode->getNodeValue()->__toString(); } // add database name if using another PDO driver than sqlite if ($databaseNameNode = $databaseNode->getDatabaseName()) { $connectionParameters['dbname'] = $databaseNameNode->getNodeValue()->__toString(); } // add database host if using another PDO driver than sqlite if ($databaseHostNode = $databaseNode->getDatabaseHost()) { $connectionParameters['host'] = $databaseHostNode->getNodeValue()->__toString(); } // add database port if using another PDO driver than sqlite if ($databasePortNode = $databaseNode->getDatabasePort()) { $connectionParameters['port'] = $databasePortNode->getNodeValue()->__toString(); } // add charset, if specified if ($charsetNode = $databaseNode->getCharset()) { $connectionParameters['charset'] = $charsetNode->getNodeValue()->__toString(); } // add driver options, if specified if ($unixSocketNode = $databaseNode->getUnixSocket()) { $connectionParameters['unix_socket'] = $unixSocketNode->getNodeValue()->__toString(); } // add server version, if specified if ($serverVersionNode = $databaseNode->getServerVersion()) { $connectionParameters['server_version'] = $serverVersionNode->getNodeValue()->__toString(); } // set platform, if specified if ($platformNode = $databaseNode->getPlatform()) { $platform = $platformNode->getNodeValue()->__toString(); $connectionParameters['platform'] = new $platform(); } // add driver options, if specified if ($driverOptionsNode = $databaseNode->getDriverOptions()) { // explode the raw options separated with a semicolon $rawOptions = explode(';', $driverOptionsNode->getNodeValue()->__toString()); // prepare the array with the driver options key/value pair (separated with a =) $options = array(); foreach ($rawOptions as $rawOption) { list ($key, $value) = explode('=', $rawOption); $options[$key] = $value; } // set the driver options $connectionParameters['driverOptions'] = $options; } // returns the connection parameters return $connectionParameters; }
[ "public", "function", "fromDatabaseNode", "(", "DatabaseConfigurationInterface", "$", "databaseNode", ")", "{", "// initialize the connection parameters with the mandatory driver", "$", "connectionParameters", "=", "array", "(", "'driver'", "=>", "$", "databaseNode", "->", "g...
Creates an array with the connection parameters for a Doctrine DBAL connection from the passed database node. @param \AppserverIo\Psr\ApplicationServer\Configuration\DatabaseConfigurationInterface $databaseNode The database node to create the connection parameters from @return array The DBAL connection parameters
[ "Creates", "an", "array", "with", "the", "connection", "parameters", "for", "a", "Doctrine", "DBAL", "connection", "from", "the", "passed", "database", "node", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Doctrine/Utils/ConnectionUtil.php#L96-L177
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/GenericObjectFactory.php
GenericObjectFactory.newInstance
public function newInstance($className) { // lock the method \Mutex::lock($this->mutex); // we're not dispatched $this->dispatched = false; // initialize the data $this->className = $className; // notify the thread $this->notify(); // wait till we've dispatched the request while ($this->dispatched === false) { usleep(100); } // try to load the last created instance if (isset($this->instances[$last = sizeof($this->instances) - 1])) { $instance = $this->instances[$last]; } else { throw new \Exception('Requested instance can\'t be created'); } // unlock the method \Mutex::unlock($this->mutex); // return the created instance return $instance; }
php
public function newInstance($className) { // lock the method \Mutex::lock($this->mutex); // we're not dispatched $this->dispatched = false; // initialize the data $this->className = $className; // notify the thread $this->notify(); // wait till we've dispatched the request while ($this->dispatched === false) { usleep(100); } // try to load the last created instance if (isset($this->instances[$last = sizeof($this->instances) - 1])) { $instance = $this->instances[$last]; } else { throw new \Exception('Requested instance can\'t be created'); } // unlock the method \Mutex::unlock($this->mutex); // return the created instance return $instance; }
[ "public", "function", "newInstance", "(", "$", "className", ")", "{", "// lock the method", "\\", "Mutex", "::", "lock", "(", "$", "this", "->", "mutex", ")", ";", "// we're not dispatched", "$", "this", "->", "dispatched", "=", "false", ";", "// initialize th...
Create a new instance with the passed data. @param string $className The fully qualified class name to return the instance for @return object The instance itself @throws \Exception
[ "Create", "a", "new", "instance", "with", "the", "passed", "data", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/GenericObjectFactory.php#L97-L129
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/GenericObjectFactory.php
GenericObjectFactory.iterate
public function iterate($timeout) { // call parent method and sleep for the default timeout parent::iterate($timeout); // create the instance and stack it $this->synchronized(function ($self) { // create the instance only if we're NOT dispatched and a class name is available if ($self->dispatched === false && $self->className) { // create the instance $instance = $self->getApplication()->search(ProviderInterface::IDENTIFIER)->get($self->className); // stack the instance $self->instances[] = $instance; // we're dispatched now $self->dispatched = true; } }, $this); }
php
public function iterate($timeout) { // call parent method and sleep for the default timeout parent::iterate($timeout); // create the instance and stack it $this->synchronized(function ($self) { // create the instance only if we're NOT dispatched and a class name is available if ($self->dispatched === false && $self->className) { // create the instance $instance = $self->getApplication()->search(ProviderInterface::IDENTIFIER)->get($self->className); // stack the instance $self->instances[] = $instance; // we're dispatched now $self->dispatched = true; } }, $this); }
[ "public", "function", "iterate", "(", "$", "timeout", ")", "{", "// call parent method and sleep for the default timeout", "parent", "::", "iterate", "(", "$", "timeout", ")", ";", "// create the instance and stack it", "$", "this", "->", "synchronized", "(", "function"...
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/GenericObjectFactory.php#L163-L185
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/AuthenticationsNodeTrait.php
AuthenticationsNodeTrait.getAuthentication
public function getAuthentication($uri) { // iterate over all authentications /** @var \AppserverIo\Appserver\Core\Api\Node\AuthenticationNode $authenticationNode */ foreach ($this->getAuthentications() as $authenticationNode) { // if we found one with a matching URI we will return it if ($authenticationNode->getUri() === $uri) { return $authenticationNode; } } // we did not find anything return false; }
php
public function getAuthentication($uri) { // iterate over all authentications /** @var \AppserverIo\Appserver\Core\Api\Node\AuthenticationNode $authenticationNode */ foreach ($this->getAuthentications() as $authenticationNode) { // if we found one with a matching URI we will return it if ($authenticationNode->getUri() === $uri) { return $authenticationNode; } } // we did not find anything return false; }
[ "public", "function", "getAuthentication", "(", "$", "uri", ")", "{", "// iterate over all authentications", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\AuthenticationNode $authenticationNode */", "foreach", "(", "$", "this", "->", "getAuthentications", "(", ")", "as", ...
Will return the authentication node with the specified definition and if nothing could be found we will return false. @param string $uri The URI of the authentication in question @return \AppserverIo\Appserver\Core\Api\Node\AuthenticationNode|boolean The requested authentication node
[ "Will", "return", "the", "authentication", "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/AuthenticationsNodeTrait.php#L64-L78
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/AuthenticationsNodeTrait.php
AuthenticationsNodeTrait.getAuthenticationsAsArray
public function getAuthenticationsAsArray() { // initialize the array for the authentications $authentications = array(); // iterate over the authentication nodes and sort them into an array /** @var \AppserverIo\Appserver\Core\Api\Node\AuthenticationNode $authenticationNode */ foreach ($this->getAuthentications() as $authenticationNode) { $authentications[$authenticationNode->getUri()] = $authenticationNode->getParamsAsArray(); } // return the array return $authentications; }
php
public function getAuthenticationsAsArray() { // initialize the array for the authentications $authentications = array(); // iterate over the authentication nodes and sort them into an array /** @var \AppserverIo\Appserver\Core\Api\Node\AuthenticationNode $authenticationNode */ foreach ($this->getAuthentications() as $authenticationNode) { $authentications[$authenticationNode->getUri()] = $authenticationNode->getParamsAsArray(); } // return the array return $authentications; }
[ "public", "function", "getAuthenticationsAsArray", "(", ")", "{", "// initialize the array for the authentications", "$", "authentications", "=", "array", "(", ")", ";", "// iterate over the authentication nodes and sort them into an array", "/** @var \\AppserverIo\\Appserver\\Core\\Ap...
Returns the authentications as an associative array. @return array The array with the sorted authentications
[ "Returns", "the", "authentications", "as", "an", "associative", "array", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/AuthenticationsNodeTrait.php#L85-L99
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/DirectoryScannerFactory.php
DirectoryScannerFactory.visit
public static function visit(ApplicationServerInterface $server, ScannerNodeInterface $scannerNode) { // load the initial context instance /** @var \AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext */ $initialContext = $server->getInitialContext(); // iterate over the configured directories and create a scanner instance for each of them /** @var \AppserverIo\Appserver\Core\Api\Node\DirectoryNodeInterface $directoryNode */ foreach ($scannerNode->getDirectories() as $directoryNode) { // load the reflection class for the scanner type $reflectionClass = new \ReflectionClass($scannerNode->getType()); // prepare the unique scanner name $scannerName = sprintf('%s-%s', $scannerNode->getName(), $directoryNode->getNodeValue()->__toString()); // prepare the scanner params $scannerParams = array($initialContext, $scannerName, $directoryNode->getNodeValue()->__toString()); $scannerParams = array_merge($scannerParams, $scannerNode->getParamsAsArray()); // register and start the scanner as daemon $server->bindService(ApplicationServerInterface::DAEMON, $reflectionClass->newInstanceArgs($scannerParams)); } }
php
public static function visit(ApplicationServerInterface $server, ScannerNodeInterface $scannerNode) { // load the initial context instance /** @var \AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext */ $initialContext = $server->getInitialContext(); // iterate over the configured directories and create a scanner instance for each of them /** @var \AppserverIo\Appserver\Core\Api\Node\DirectoryNodeInterface $directoryNode */ foreach ($scannerNode->getDirectories() as $directoryNode) { // load the reflection class for the scanner type $reflectionClass = new \ReflectionClass($scannerNode->getType()); // prepare the unique scanner name $scannerName = sprintf('%s-%s', $scannerNode->getName(), $directoryNode->getNodeValue()->__toString()); // prepare the scanner params $scannerParams = array($initialContext, $scannerName, $directoryNode->getNodeValue()->__toString()); $scannerParams = array_merge($scannerParams, $scannerNode->getParamsAsArray()); // register and start the scanner as daemon $server->bindService(ApplicationServerInterface::DAEMON, $reflectionClass->newInstanceArgs($scannerParams)); } }
[ "public", "static", "function", "visit", "(", "ApplicationServerInterface", "$", "server", ",", "ScannerNodeInterface", "$", "scannerNode", ")", "{", "// load the initial context instance", "/** @var \\AppserverIo\\Appserver\\Application\\Interfaces\\ContextInterface $initialContext */...
Creates a new scanner instance and attaches it to the passed server instance. @param \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $server The server instance to add the scanner to @param \AppserverIo\Appserver\Core\Api\Node\ScannerNodeInterface $scannerNode The scanner configuration @return object The scanner instance
[ "Creates", "a", "new", "scanner", "instance", "and", "attaches", "it", "to", "the", "passed", "server", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/DirectoryScannerFactory.php#L46-L69
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerService.php
TimerService.createIntervalTimer
public function createIntervalTimer($initialExpiration, $intervalDuration, \Serializable $info = null, $persistent = true) { // create the actual date and add the initial expiration $now = new \DateTime(); $now->add(new \DateInterval(sprintf('PT%dS', $initialExpiration / 1000000))); // create a new timer return $this->createTimer($now, $intervalDuration, $info, $persistent); }
php
public function createIntervalTimer($initialExpiration, $intervalDuration, \Serializable $info = null, $persistent = true) { // create the actual date and add the initial expiration $now = new \DateTime(); $now->add(new \DateInterval(sprintf('PT%dS', $initialExpiration / 1000000))); // create a new timer return $this->createTimer($now, $intervalDuration, $info, $persistent); }
[ "public", "function", "createIntervalTimer", "(", "$", "initialExpiration", ",", "$", "intervalDuration", ",", "\\", "Serializable", "$", "info", "=", "null", ",", "$", "persistent", "=", "true", ")", "{", "// create the actual date and add the initial expiration", "$...
Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval. @param integer $initialExpiration The number of milliseconds that must elapse before the first timer expiration notification @param integer $intervalDuration The number of milliseconds that must elapse between timer expiration notifications. Expiration notifications are scheduled relative to the time of the first expiration. If expiration is delayed(e.g. due to the interleaving of other method calls on the bean) two or more expiration notifications may occur in close succession to "catch up". @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 The newly created Timer @throws \AppserverIo\Psr\EnterpriseBeans\EnterpriseBeansException If this method could not complete due to a system-level failure
[ "Create", "an", "interval", "timer", "whose", "first", "expiration", "occurs", "at", "a", "given", "point", "in", "time", "and", "whose", "subsequent", "expirations", "occur", "after", "a", "specified", "interval", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerService.php#L173-L182
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerService.php
TimerService.createSingleActionTimer
public function createSingleActionTimer($duration, \Serializable $info = null, $persistent = true) { // create the actual date and add the initial expiration $now = new \DateTime(); $now->add(new \DateInterval(sprintf('PT%dS', $duration / 1000000))); // we don't have an interval $intervalDuration = 0; // create and return the timer instance return $this->createTimer($now, $intervalDuration, $info, $persistent); }
php
public function createSingleActionTimer($duration, \Serializable $info = null, $persistent = true) { // create the actual date and add the initial expiration $now = new \DateTime(); $now->add(new \DateInterval(sprintf('PT%dS', $duration / 1000000))); // we don't have an interval $intervalDuration = 0; // create and return the timer instance return $this->createTimer($now, $intervalDuration, $info, $persistent); }
[ "public", "function", "createSingleActionTimer", "(", "$", "duration", ",", "\\", "Serializable", "$", "info", "=", "null", ",", "$", "persistent", "=", "true", ")", "{", "// create the actual date and add the initial expiration", "$", "now", "=", "new", "\\", "Da...
Create a single-action timer that expires after a specified duration. @param integer $duration The number of microseconds that must elapse before the timer expires @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 The newly created Timer. @throws \AppserverIo\Psr\EnterpriseBeans\EnterpriseBeansException If this method could not complete due to a system-level failure.
[ "Create", "a", "single", "-", "action", "timer", "that", "expires", "after", "a", "specified", "duration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerService.php#L194-L206
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerService.php
TimerService.createCalendarTimer
public function createCalendarTimer(ScheduleExpression $schedule, \Serializable $info = null, $persistent = true, MethodInterface $timeoutMethod = null) { // create the calendar timer $timer = $this->getCalendarTimerFactory()->createTimer($this, $schedule, $info, $persistent, $timeoutMethod); // persist the timer $this->persistTimer($timer, true); // now "start" the timer. This involves, moving the timer to an ACTIVE state and scheduling the timer task $this->startTimer($timer); // return the timer return $timer; }
php
public function createCalendarTimer(ScheduleExpression $schedule, \Serializable $info = null, $persistent = true, MethodInterface $timeoutMethod = null) { // create the calendar timer $timer = $this->getCalendarTimerFactory()->createTimer($this, $schedule, $info, $persistent, $timeoutMethod); // persist the timer $this->persistTimer($timer, true); // now "start" the timer. This involves, moving the timer to an ACTIVE state and scheduling the timer task $this->startTimer($timer); // return the timer return $timer; }
[ "public", "function", "createCalendarTimer", "(", "ScheduleExpression", "$", "schedule", ",", "\\", "Serializable", "$", "info", "=", "null", ",", "$", "persistent", "=", "true", ",", "MethodInterface", "$", "timeoutMethod", "=", "null", ")", "{", "// create the...
Create a calendar-based timer based on the input schedule expression. @param \AppserverIo\Psr\EnterpriseBeans\ScheduleExpression $schedule A schedule expression describing the timeouts for this timer @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 @param \AppserverIo\Lang\Reflection\MethodInterface $timeoutMethod The timeout method to be invoked @return \AppserverIo\Psr\EnterpriseBeans\TimerInterface The newly created Timer. @throws \AppserverIo\Psr\EnterpriseBeans\EnterpriseBeansException If this method could not complete due to a system-level failure.
[ "Create", "a", "calendar", "-", "based", "timer", "based", "on", "the", "input", "schedule", "expression", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerService.php#L219-L233
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerService.php
TimerService.createTimer
public function createTimer(\DateTime $initialExpiration, $intervalDuration = 0, \Serializable $info = null, $persistent = true) { // create the timer $timer = $this->getTimerFactory()->createTimer($this, $initialExpiration, $intervalDuration, $info, $persistent); // persist the timer $this->persistTimer($timer, true); // now 'start' the timer. This involves, moving the timer to an ACTIVE state and scheduling the timer task $this->startTimer($timer); // return the newly created timer return $timer; }
php
public function createTimer(\DateTime $initialExpiration, $intervalDuration = 0, \Serializable $info = null, $persistent = true) { // create the timer $timer = $this->getTimerFactory()->createTimer($this, $initialExpiration, $intervalDuration, $info, $persistent); // persist the timer $this->persistTimer($timer, true); // now 'start' the timer. This involves, moving the timer to an ACTIVE state and scheduling the timer task $this->startTimer($timer); // return the newly created timer return $timer; }
[ "public", "function", "createTimer", "(", "\\", "DateTime", "$", "initialExpiration", ",", "$", "intervalDuration", "=", "0", ",", "\\", "Serializable", "$", "info", "=", "null", ",", "$", "persistent", "=", "true", ")", "{", "// create the timer", "$", "tim...
Create a new timer instance with the passed data. @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
[ "Create", "a", "new", "timer", "instance", "with", "the", "passed", "data", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerService.php#L264-L278
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerService.php
TimerService.scheduleTimeout
public function scheduleTimeout(TimerInterface $timer, $newTimer) { // check if this timer has been cancelled by another thread if ($newTimer === false && $this->getTimers()->has($timer->getId()) === false) { return; // if yes, we just return } // if next expiration is NULL, no more tasks will be scheduled for this timer if ($timer->getNextExpiration() == null) { return; // we just return } // create the timer task and schedule it $this->getTimerServiceExecutor()->schedule($timer); }
php
public function scheduleTimeout(TimerInterface $timer, $newTimer) { // check if this timer has been cancelled by another thread if ($newTimer === false && $this->getTimers()->has($timer->getId()) === false) { return; // if yes, we just return } // if next expiration is NULL, no more tasks will be scheduled for this timer if ($timer->getNextExpiration() == null) { return; // we just return } // create the timer task and schedule it $this->getTimerServiceExecutor()->schedule($timer); }
[ "public", "function", "scheduleTimeout", "(", "TimerInterface", "$", "timer", ",", "$", "newTimer", ")", "{", "// check if this timer has been cancelled by another thread", "if", "(", "$", "newTimer", "===", "false", "&&", "$", "this", "->", "getTimers", "(", ")", ...
Creates and schedules a timer task for the next timeout of the passed timer. @param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer The timer we want to schedule a task for @param boolean $newTimer TRUE if this is a new timer being scheduled, and not a re-schedule due to a timeout @return void
[ "Creates", "and", "schedules", "a", "timer", "task", "for", "the", "next", "timeout", "of", "the", "passed", "timer", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerService.php#L313-L328
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerService.php
TimerService.start
public function start() { // load the timeout methods annotated with @Schedule foreach ($this->getTimedObjectInvoker()->getTimeoutMethods() as $timeoutMethod) { // make sure we've a timeout method if ($timeoutMethod instanceof MethodInterface) { // load the Doctrine annotation reader $annatationReader = new AnnotationReader(); // create the schedule annotation instance with the loaded data $schedule = $annatationReader->getMethodAnnotation($timeoutMethod->toPhpReflectionMethod(), Schedule::class)->toScheduleExpression(); // create and add a new calendar timer $this->createCalendarTimer($schedule, null, true, $timeoutMethod); } } // mark timer service as started $this->started = true; }
php
public function start() { // load the timeout methods annotated with @Schedule foreach ($this->getTimedObjectInvoker()->getTimeoutMethods() as $timeoutMethod) { // make sure we've a timeout method if ($timeoutMethod instanceof MethodInterface) { // load the Doctrine annotation reader $annatationReader = new AnnotationReader(); // create the schedule annotation instance with the loaded data $schedule = $annatationReader->getMethodAnnotation($timeoutMethod->toPhpReflectionMethod(), Schedule::class)->toScheduleExpression(); // create and add a new calendar timer $this->createCalendarTimer($schedule, null, true, $timeoutMethod); } } // mark timer service as started $this->started = true; }
[ "public", "function", "start", "(", ")", "{", "// load the timeout methods annotated with @Schedule", "foreach", "(", "$", "this", "->", "getTimedObjectInvoker", "(", ")", "->", "getTimeoutMethods", "(", ")", "as", "$", "timeoutMethod", ")", "{", "// make sure we've a...
Creates the auto timer instances. @return void
[ "Creates", "the", "auto", "timer", "instances", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerService.php#L335-L355
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.getFlags
protected function getFlags() { return array( ExtractorInterface::FLAG_DEPLOYED, ExtractorInterface::FLAG_DEPLOYING, ExtractorInterface::FLAG_DODEPLOY, ExtractorInterface::FLAG_FAILED, ExtractorInterface::FLAG_UNDEPLOYED, ExtractorInterface::FLAG_UNDEPLOYING ); }
php
protected function getFlags() { return array( ExtractorInterface::FLAG_DEPLOYED, ExtractorInterface::FLAG_DEPLOYING, ExtractorInterface::FLAG_DODEPLOY, ExtractorInterface::FLAG_FAILED, ExtractorInterface::FLAG_UNDEPLOYED, ExtractorInterface::FLAG_UNDEPLOYING ); }
[ "protected", "function", "getFlags", "(", ")", "{", "return", "array", "(", "ExtractorInterface", "::", "FLAG_DEPLOYED", ",", "ExtractorInterface", "::", "FLAG_DEPLOYING", ",", "ExtractorInterface", "::", "FLAG_DODEPLOY", ",", "ExtractorInterface", "::", "FLAG_FAILED", ...
Returns all flags in array. @return array
[ "Returns", "all", "flags", "in", "array", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L82-L92
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.deployWebapps
public function deployWebapps() { // iterate over the deploy directories and deploy all archives /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getService()->getSystemConfiguration()->getContainers() as $containerNode) { // check if deploy dir exists if (is_dir($deployDir = $this->getService()->getBaseDirectory($containerNode->getHost()->getDeployBase()))) { // init file iterator on deployment directory $fileIterator = new \FilesystemIterator($deployDir); // Iterate through all phar files and extract them to tmp dir foreach (new \RegexIterator($fileIterator, '/^.*\\' . $this->getExtensionSuffix() . '$/') as $archive) { $this->undeployArchive($containerNode, $archive); $this->deployArchive($containerNode, $archive); } } // prepare the filename for the file with the last successful deployment timestamp $successFile = sprintf('%s/%s', $deployDir, ExtractorInterface::FILE_DEPLOYMENT_SUCCESSFULL); // create a flag file with date of the last successful deployment touch($successFile); } }
php
public function deployWebapps() { // iterate over the deploy directories and deploy all archives /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getService()->getSystemConfiguration()->getContainers() as $containerNode) { // check if deploy dir exists if (is_dir($deployDir = $this->getService()->getBaseDirectory($containerNode->getHost()->getDeployBase()))) { // init file iterator on deployment directory $fileIterator = new \FilesystemIterator($deployDir); // Iterate through all phar files and extract them to tmp dir foreach (new \RegexIterator($fileIterator, '/^.*\\' . $this->getExtensionSuffix() . '$/') as $archive) { $this->undeployArchive($containerNode, $archive); $this->deployArchive($containerNode, $archive); } } // prepare the filename for the file with the last successful deployment timestamp $successFile = sprintf('%s/%s', $deployDir, ExtractorInterface::FILE_DEPLOYMENT_SUCCESSFULL); // create a flag file with date of the last successful deployment touch($successFile); } }
[ "public", "function", "deployWebapps", "(", ")", "{", "// iterate over the deploy directories and deploy all archives", "/** @var \\AppserverIo\\Psr\\ApplicationServer\\Configuration\\ContainerConfigurationInterface $containerNode */", "foreach", "(", "$", "this", "->", "getService", "("...
Will actually deploy all webapps. @return void
[ "Will", "actually", "deploy", "all", "webapps", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L99-L122
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.flagArchive
public function flagArchive(\SplFileInfo $archive, $flag) { // delete all old flags $this->unflagArchive($archive); // flag the passed archive file_put_contents($archive->getPathname() . $flag, $archive->getPathname()); // set correct user/group for the flag file $this->setUserRight(new \SplFileInfo($archive->getPathname() . $flag)); }
php
public function flagArchive(\SplFileInfo $archive, $flag) { // delete all old flags $this->unflagArchive($archive); // flag the passed archive file_put_contents($archive->getPathname() . $flag, $archive->getPathname()); // set correct user/group for the flag file $this->setUserRight(new \SplFileInfo($archive->getPathname() . $flag)); }
[ "public", "function", "flagArchive", "(", "\\", "SplFileInfo", "$", "archive", ",", "$", "flag", ")", "{", "// delete all old flags", "$", "this", "->", "unflagArchive", "(", "$", "archive", ")", ";", "// flag the passed archive", "file_put_contents", "(", "$", ...
Flags the archive in specific states of extraction @param \SplFileInfo $archive The archive to flag @param string $flag The flag to set @return void
[ "Flags", "the", "archive", "in", "specific", "states", "of", "extraction" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L132-L140
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.unflagArchive
public function unflagArchive(\SplFileInfo $archive) { foreach ($this->getFlags() as $flagString) { if (file_exists($archive->getRealPath() . $flagString)) { unlink($archive->getRealPath() . $flagString); } } }
php
public function unflagArchive(\SplFileInfo $archive) { foreach ($this->getFlags() as $flagString) { if (file_exists($archive->getRealPath() . $flagString)) { unlink($archive->getRealPath() . $flagString); } } }
[ "public", "function", "unflagArchive", "(", "\\", "SplFileInfo", "$", "archive", ")", "{", "foreach", "(", "$", "this", "->", "getFlags", "(", ")", "as", "$", "flagString", ")", "{", "if", "(", "file_exists", "(", "$", "archive", "->", "getRealPath", "("...
Deletes all old flags, so the app will be undeployed with the next appserver restart. @param \SplFileInfo $archive The archive to unflag @return void
[ "Deletes", "all", "old", "flags", "so", "the", "app", "will", "be", "undeployed", "with", "the", "next", "appserver", "restart", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L150-L157
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.isDeployable
public function isDeployable(\SplFileInfo $archive) { // check if the .dodeploy flag file exists if (file_exists($archive->getPathname() . ExtractorInterface::FLAG_DODEPLOY)) { return true; } // by default it's NOT deployable return false; }
php
public function isDeployable(\SplFileInfo $archive) { // check if the .dodeploy flag file exists if (file_exists($archive->getPathname() . ExtractorInterface::FLAG_DODEPLOY)) { return true; } // by default it's NOT deployable return false; }
[ "public", "function", "isDeployable", "(", "\\", "SplFileInfo", "$", "archive", ")", "{", "// check if the .dodeploy flag file exists", "if", "(", "file_exists", "(", "$", "archive", "->", "getPathname", "(", ")", ".", "ExtractorInterface", "::", "FLAG_DODEPLOY", ")...
(non-PHPdoc) @param \SplFileInfo $archive The archive object @return bool @see \AppserverIo\Appserver\Core\Interfaces\ExtractorInterface::isDeployable()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L167-L177
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.isUndeployable
public function isUndeployable(\SplFileInfo $archive) { // make sure that NO flag for the archive is available foreach ($this->getFlags() as $flag) { if (file_exists($archive->getPathname() . $flag)) { return false; } } // it's undeployable if NOT marker file exists return true; }
php
public function isUndeployable(\SplFileInfo $archive) { // make sure that NO flag for the archive is available foreach ($this->getFlags() as $flag) { if (file_exists($archive->getPathname() . $flag)) { return false; } } // it's undeployable if NOT marker file exists return true; }
[ "public", "function", "isUndeployable", "(", "\\", "SplFileInfo", "$", "archive", ")", "{", "// make sure that NO flag for the archive is available", "foreach", "(", "$", "this", "->", "getFlags", "(", ")", "as", "$", "flag", ")", "{", "if", "(", "file_exists", ...
(non-PHPdoc) @param \SplFileInfo $archive The archive object @return bool @see \AppserverIo\Appserver\Core\Interfaces\ExtractorInterface::isUndeployable()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L187-L199
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.soakArchive
public function soakArchive(ContainerConfigurationInterface $containerNode, \SplFileInfo $archive) { // prepare the upload target in the deploy directory $target = $this->getDeployDir($containerNode, $archive->getFilename()); // move the uploaded file from the tmp to the deploy directory rename($archive->getPathname(), $target); // mark the file to be deployed with the next restart $this->flagArchive(new \SplFileInfo($target), ExtractorInterface::FLAG_DODEPLOY); }
php
public function soakArchive(ContainerConfigurationInterface $containerNode, \SplFileInfo $archive) { // prepare the upload target in the deploy directory $target = $this->getDeployDir($containerNode, $archive->getFilename()); // move the uploaded file from the tmp to the deploy directory rename($archive->getPathname(), $target); // mark the file to be deployed with the next restart $this->flagArchive(new \SplFileInfo($target), ExtractorInterface::FLAG_DODEPLOY); }
[ "public", "function", "soakArchive", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "\\", "SplFileInfo", "$", "archive", ")", "{", "// prepare the upload target in the deploy directory", "$", "target", "=", "$", "this", "->", "getDeployDir", "(", "$"...
(non-PHPdoc) @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container the archive belongs to @param \SplFileInfo $archive The archive to be soaked @return void @see \AppserverIo\Appserver\Core\Interfaces\ExtractorInterface::soakArchive()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L210-L221
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.undeployArchive
public function undeployArchive(ContainerConfigurationInterface $containerNode, \SplFileInfo $archive) { try { // create webapp folder name based on the archive's basename $webappFolderName = new \SplFileInfo( $this->getWebappsDir($containerNode, basename($archive->getFilename(), $this->getExtensionSuffix())) ); // check if app has to be undeployed if ($this->isUndeployable($archive) && $webappFolderName->isDir()) { // flag webapp as undeploing $this->flagArchive($archive, ExtractorInterface::FLAG_UNDEPLOYING); // backup files that are NOT part of the archive $this->backupArchive($containerNode, $archive); // delete directories previously backed up $this->removeDir($webappFolderName); // flag webapp as undeployed $this->flagArchive($archive, ExtractorInterface::FLAG_UNDEPLOYED); // log a message that the application has successfully been deployed $this->getInitialContext()->getSystemLogger()->info( sprintf('Application archive %s has succussfully been undeployed', $archive->getBasename($this->getExtensionSuffix())) ); } } catch (\Exception $e) { // log error $this->getInitialContext()->getSystemLogger()->error($e->__toString()); // flag webapp as failed $this->flagArchive($archive, ExtractorInterface::FLAG_FAILED); } }
php
public function undeployArchive(ContainerConfigurationInterface $containerNode, \SplFileInfo $archive) { try { // create webapp folder name based on the archive's basename $webappFolderName = new \SplFileInfo( $this->getWebappsDir($containerNode, basename($archive->getFilename(), $this->getExtensionSuffix())) ); // check if app has to be undeployed if ($this->isUndeployable($archive) && $webappFolderName->isDir()) { // flag webapp as undeploing $this->flagArchive($archive, ExtractorInterface::FLAG_UNDEPLOYING); // backup files that are NOT part of the archive $this->backupArchive($containerNode, $archive); // delete directories previously backed up $this->removeDir($webappFolderName); // flag webapp as undeployed $this->flagArchive($archive, ExtractorInterface::FLAG_UNDEPLOYED); // log a message that the application has successfully been deployed $this->getInitialContext()->getSystemLogger()->info( sprintf('Application archive %s has succussfully been undeployed', $archive->getBasename($this->getExtensionSuffix())) ); } } catch (\Exception $e) { // log error $this->getInitialContext()->getSystemLogger()->error($e->__toString()); // flag webapp as failed $this->flagArchive($archive, ExtractorInterface::FLAG_FAILED); } }
[ "public", "function", "undeployArchive", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "\\", "SplFileInfo", "$", "archive", ")", "{", "try", "{", "// create webapp folder name based on the archive's basename", "$", "webappFolderName", "=", "new", "\\", ...
(non-PHPdoc) @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container the archive belongs to @param \SplFileInfo $archive The archive file to be undeployed @throws \Exception @return void @see \AppserverIo\Appserver\Core\Interfaces\ExtractorInterface::undeployArchive()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L233-L268
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.restoreBackup
public function restoreBackup(ContainerConfigurationInterface $containerNode, \SplFileInfo $archive) { // if we don't want create backups we can't restore them, so do nothing if ($this->getExtractorNode()->isCreateBackups() === false || $this->getExtractorNode()->isRestoreBackups() === false) { return; } // create tmp & webapp folder name based on the archive's basename $webappFolderName = $this->getWebappsDir($containerNode, basename($archive->getFilename(), $this->getExtensionSuffix())); $tmpFolderName = $this->getTmpDir($containerNode, md5(basename($archive->getFilename(), $this->getExtensionSuffix()))); // copy backup to webapp directory $this->copyDir($tmpFolderName, $webappFolderName); }
php
public function restoreBackup(ContainerConfigurationInterface $containerNode, \SplFileInfo $archive) { // if we don't want create backups we can't restore them, so do nothing if ($this->getExtractorNode()->isCreateBackups() === false || $this->getExtractorNode()->isRestoreBackups() === false) { return; } // create tmp & webapp folder name based on the archive's basename $webappFolderName = $this->getWebappsDir($containerNode, basename($archive->getFilename(), $this->getExtensionSuffix())); $tmpFolderName = $this->getTmpDir($containerNode, md5(basename($archive->getFilename(), $this->getExtensionSuffix()))); // copy backup to webapp directory $this->copyDir($tmpFolderName, $webappFolderName); }
[ "public", "function", "restoreBackup", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "\\", "SplFileInfo", "$", "archive", ")", "{", "// if we don't want create backups we can't restore them, so do nothing", "if", "(", "$", "this", "->", "getExtractorNode"...
Restores the backup files from the backup directory. @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container the archive belongs to @param \SplFileInfo $archive To restore the files for @return void
[ "Restores", "the", "backup", "files", "from", "the", "backup", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L278-L292
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.removeDir
protected function removeDir(\SplFileInfo $dir, $alsoRemoveFiles = true) { // clean up the directory $this->getService()->cleanUpDir($dir, $alsoRemoveFiles); // check if the directory exists, if not return immediately if ($dir->isDir() === false) { return; } // delete the directory itself if empty @rmdir($dir->getPathname()); }
php
protected function removeDir(\SplFileInfo $dir, $alsoRemoveFiles = true) { // clean up the directory $this->getService()->cleanUpDir($dir, $alsoRemoveFiles); // check if the directory exists, if not return immediately if ($dir->isDir() === false) { return; } // delete the directory itself if empty @rmdir($dir->getPathname()); }
[ "protected", "function", "removeDir", "(", "\\", "SplFileInfo", "$", "dir", ",", "$", "alsoRemoveFiles", "=", "true", ")", "{", "// clean up the directory", "$", "this", "->", "getService", "(", ")", "->", "cleanUpDir", "(", "$", "dir", ",", "$", "alsoRemove...
Removes a directory recursively. @param \SplFileInfo $dir The directory to remove @param bool $alsoRemoveFiles The flag for removing files also @return void
[ "Removes", "a", "directory", "recursively", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L302-L315
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractExtractor.php
AbstractExtractor.getWebappsDir
public function getWebappsDir(ContainerConfigurationInterface $containerNode, $relativePathToAppend = '') { return $this->getService()->realpath( $this->getService()->makePathAbsolute( $containerNode->getHost()->getAppBase() . $this->getService()->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getWebappsDir(ContainerConfigurationInterface $containerNode, $relativePathToAppend = '') { return $this->getService()->realpath( $this->getService()->makePathAbsolute( $containerNode->getHost()->getAppBase() . $this->getService()->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getWebappsDir", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "getService", "(", ")", "->", "realpath", "(", "$", "this", "->", "getService...
Returns the container's webapps directory. @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container to return the temporary directory for @param string $relativePathToAppend A relative path to append @return string The web application directory
[ "Returns", "the", "container", "s", "webapps", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractExtractor.php#L402-L409
appserver-io/appserver
src/AppserverIo/Appserver/Core/Listeners/PrepareFileSystemListener.php
PrepareFileSystemListener.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()); // load the service instance and prepare the filesystem /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */ $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\ContainerService'); $service->prepareFileSystem(); } 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()); // load the service instance and prepare the filesystem /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */ $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\ContainerService'); $service->prepareFileSystem(); } 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/PrepareFileSystemListener.php#L45-L64
appserver-io/appserver
src/AppserverIo/Appserver/Core/Listeners/LoadConfigurationListener.php
LoadConfigurationListener.handle
public function handle(EventInterface $event) { try { // load the application server and the naming directory instance /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */ $applicationServer = $this->getApplicationServer(); /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */ $namingDirectory = $applicationServer->getNamingDirectory(); // initialize configuration and schema file name $configurationFileName = $applicationServer->getConfigurationFilename(); // get an instance of our configuration tester $configurationService = new ConfigurationService(new InitialContext(new AppserverNode())); // load the parsed system configuration /** @var \DOMDocument $doc */ $doc = $configurationService->loadConfigurationByFilename($configurationFileName); // validate the configuration file with the schema $configurationService->validateXml($doc, null, true); try { // query whether we're in configuration test mode or not if ($namingDirectory->search('php:env/args/t')) { echo 'Syntax OK' . PHP_EOL; exit(0); } } catch (NamingException $ne) { // do nothing, because we're NOT in configuration test mode } // initialize the SimpleXMLElement with the content XML configuration file $configuration = new Configuration(); $configuration->initFromString($doc->saveXML()); // initialize the configuration and the base directory $systemConfiguration = new AppserverNode(); $systemConfiguration->initFromConfiguration($configuration); // re-initialize the container service with the real system configuration $configurationService->setSystemConfiguration($systemConfiguration); // then we can replace the system properties $properties = $configurationService->getSystemProperties(); $systemConfiguration->replaceProperties($properties); // set the system configuration in the application server instance $applicationServer->setSystemConfiguration($systemConfiguration); } catch (\Exception $e) { // render the validation errors and exit immediately echo $e . PHP_EOL; exit(0); } }
php
public function handle(EventInterface $event) { try { // load the application server and the naming directory instance /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */ $applicationServer = $this->getApplicationServer(); /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */ $namingDirectory = $applicationServer->getNamingDirectory(); // initialize configuration and schema file name $configurationFileName = $applicationServer->getConfigurationFilename(); // get an instance of our configuration tester $configurationService = new ConfigurationService(new InitialContext(new AppserverNode())); // load the parsed system configuration /** @var \DOMDocument $doc */ $doc = $configurationService->loadConfigurationByFilename($configurationFileName); // validate the configuration file with the schema $configurationService->validateXml($doc, null, true); try { // query whether we're in configuration test mode or not if ($namingDirectory->search('php:env/args/t')) { echo 'Syntax OK' . PHP_EOL; exit(0); } } catch (NamingException $ne) { // do nothing, because we're NOT in configuration test mode } // initialize the SimpleXMLElement with the content XML configuration file $configuration = new Configuration(); $configuration->initFromString($doc->saveXML()); // initialize the configuration and the base directory $systemConfiguration = new AppserverNode(); $systemConfiguration->initFromConfiguration($configuration); // re-initialize the container service with the real system configuration $configurationService->setSystemConfiguration($systemConfiguration); // then we can replace the system properties $properties = $configurationService->getSystemProperties(); $systemConfiguration->replaceProperties($properties); // set the system configuration in the application server instance $applicationServer->setSystemConfiguration($systemConfiguration); } catch (\Exception $e) { // render the validation errors and exit immediately echo $e . PHP_EOL; exit(0); } }
[ "public", "function", "handle", "(", "EventInterface", "$", "event", ")", "{", "try", "{", "// load the application server and the naming directory 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/LoadConfigurationListener.php#L50-L107
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Tasks/TimerTask.php
TimerTask.run
public function run() { // register the default autoloader require SERVER_AUTOLOADER; // synchronize the application instance and register the class loaders $application = $this->application; $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // sychronize timer instance $timer = $this->timer; // we lock the timer for this check, because if a cancel is in progress then we do not want to // do the isActive check, but wait for the cancelling transaction to finish one way or another $timer->lock(); try { // check if the timer is active if ($timer->isActive() === false) { // create the actual date $now = new \DateTime('now'); // log an info that the timer is NOT active $application->getInitialContext()->getSystemLogger()->info( sprintf( 'Timer is not active, skipping this scheduled execution at: %s for %s', $now->format('Y-m-d'), $timer->getId() ) ); return; // return without do anything } // set the current date as the "previous run" of the timer $timer->setPreviousRun(new \DateTime()); // set the next timeout, if one is available if ($nextTimeout = $this->calculateNextTimeout($timer)) { $timer->setNextTimeout($nextTimeout->format(ScheduleExpression::DATE_FORMAT)); } else { $timer->setNextTimeout(null); } // change the state to mark it as in timeout method $timer->setTimerState(TimerState::IN_TIMEOUT); // persist changes $timer->getTimerService()->persistTimer($timer, false); } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->error($e->__toString()); } // unlock after timeout recalculation $timer->unlock(); // call timeout method $this->callTimeout($timer); }
php
public function run() { // register the default autoloader require SERVER_AUTOLOADER; // synchronize the application instance and register the class loaders $application = $this->application; $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // sychronize timer instance $timer = $this->timer; // we lock the timer for this check, because if a cancel is in progress then we do not want to // do the isActive check, but wait for the cancelling transaction to finish one way or another $timer->lock(); try { // check if the timer is active if ($timer->isActive() === false) { // create the actual date $now = new \DateTime('now'); // log an info that the timer is NOT active $application->getInitialContext()->getSystemLogger()->info( sprintf( 'Timer is not active, skipping this scheduled execution at: %s for %s', $now->format('Y-m-d'), $timer->getId() ) ); return; // return without do anything } // set the current date as the "previous run" of the timer $timer->setPreviousRun(new \DateTime()); // set the next timeout, if one is available if ($nextTimeout = $this->calculateNextTimeout($timer)) { $timer->setNextTimeout($nextTimeout->format(ScheduleExpression::DATE_FORMAT)); } else { $timer->setNextTimeout(null); } // change the state to mark it as in timeout method $timer->setTimerState(TimerState::IN_TIMEOUT); // persist changes $timer->getTimerService()->persistTimer($timer, false); } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->error($e->__toString()); } // unlock after timeout recalculation $timer->unlock(); // call timeout method $this->callTimeout($timer); }
[ "public", "function", "run", "(", ")", "{", "// register the default autoloader", "require", "SERVER_AUTOLOADER", ";", "// synchronize the application instance and register the class loaders", "$", "application", "=", "$", "this", "->", "application", ";", "$", "application",...
We process the timer here. @return void
[ "We", "process", "the", "timer", "here", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Tasks/TimerTask.php#L86-L148
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Tasks/TimerTask.php
TimerTask.callTimeout
protected function callTimeout(TimerInterface $timer) { // if we have any more schedules remaining, then schedule a new task if ($timer->getNextExpiration() != null && !$timer->isInRetry()) { $timer->scheduleTimeout(false); } // invoke the timeout on the timed object $timer->getTimerService()->getTimedObjectInvoker()->callTimeout($timer); }
php
protected function callTimeout(TimerInterface $timer) { // if we have any more schedules remaining, then schedule a new task if ($timer->getNextExpiration() != null && !$timer->isInRetry()) { $timer->scheduleTimeout(false); } // invoke the timeout on the timed object $timer->getTimerService()->getTimedObjectInvoker()->callTimeout($timer); }
[ "protected", "function", "callTimeout", "(", "TimerInterface", "$", "timer", ")", "{", "// if we have any more schedules remaining, then schedule a new task", "if", "(", "$", "timer", "->", "getNextExpiration", "(", ")", "!=", "null", "&&", "!", "$", "timer", "->", ...
Invokes the timeout on the passed timer. @param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer The timer we want to invoke the timeout for @return void
[ "Invokes", "the", "timeout", "on", "the", "passed", "timer", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Tasks/TimerTask.php#L157-L167
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Tasks/TimerTask.php
TimerTask.calculateNextTimeout
protected function calculateNextTimeout(TimerInterface $timer) { // try to load the interval $intervalDuration = $timer->getIntervalDuration(); // check if we've a interval if ($intervalDuration > 0) { // load the next expiration date $nextExpiration = $timer->getNextExpiration(); // compute and return the next expiration date return $nextExpiration->add(new \DateInterval(sprintf('PT%sS', $intervalDuration / 1000000))); } // return nothing return null; }
php
protected function calculateNextTimeout(TimerInterface $timer) { // try to load the interval $intervalDuration = $timer->getIntervalDuration(); // check if we've a interval if ($intervalDuration > 0) { // load the next expiration date $nextExpiration = $timer->getNextExpiration(); // compute and return the next expiration date return $nextExpiration->add(new \DateInterval(sprintf('PT%sS', $intervalDuration / 1000000))); } // return nothing return null; }
[ "protected", "function", "calculateNextTimeout", "(", "TimerInterface", "$", "timer", ")", "{", "// try to load the interval", "$", "intervalDuration", "=", "$", "timer", "->", "getIntervalDuration", "(", ")", ";", "// check if we've a interval", "if", "(", "$", "inte...
Calculates and returns the next timeout for the passed timer. @param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer The timer we want to calculate the next timeout for @return \DateTime|null The next expiration timeout
[ "Calculates", "and", "returns", "the", "next", "timeout", "for", "the", "passed", "timer", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Tasks/TimerTask.php#L176-L193
appserver-io/appserver
src/AppserverIo/Appserver/Core/GenericDeployment.php
GenericDeployment.getDatasourceFiles
protected function getDatasourceFiles() { // if we have a valid app base we will collect all datasources $datasourceFiles = array(); if (is_dir($appBase = $this->getAppBase())) { // get all the global datasource files first $datasourceFiles = array_merge( $datasourceFiles, $this->prepareDatasourceFiles( $this->getDeploymentService()->globDir($appBase . DIRECTORY_SEPARATOR . '*-ds.xml', 0, false) ) ); // iterate over all applications and collect the environment specific datasources foreach (glob($appBase . '/*', GLOB_ONLYDIR) as $webappPath) { // append the datasource files of the webapp $datasourceFiles = array_merge( $datasourceFiles, $this->prepareDatasourceFiles( $this->getDeploymentService()->globDir(AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, 'META-INF' . DIRECTORY_SEPARATOR . '*-ds')) ) ); } } // return the found datasource files return $datasourceFiles; }
php
protected function getDatasourceFiles() { // if we have a valid app base we will collect all datasources $datasourceFiles = array(); if (is_dir($appBase = $this->getAppBase())) { // get all the global datasource files first $datasourceFiles = array_merge( $datasourceFiles, $this->prepareDatasourceFiles( $this->getDeploymentService()->globDir($appBase . DIRECTORY_SEPARATOR . '*-ds.xml', 0, false) ) ); // iterate over all applications and collect the environment specific datasources foreach (glob($appBase . '/*', GLOB_ONLYDIR) as $webappPath) { // append the datasource files of the webapp $datasourceFiles = array_merge( $datasourceFiles, $this->prepareDatasourceFiles( $this->getDeploymentService()->globDir(AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, 'META-INF' . DIRECTORY_SEPARATOR . '*-ds')) ) ); } } // return the found datasource files return $datasourceFiles; }
[ "protected", "function", "getDatasourceFiles", "(", ")", "{", "// if we have a valid app base we will collect all datasources", "$", "datasourceFiles", "=", "array", "(", ")", ";", "if", "(", "is_dir", "(", "$", "appBase", "=", "$", "this", "->", "getAppBase", "(", ...
Returns all datasource files we potentially use @return array
[ "Returns", "all", "datasource", "files", "we", "potentially", "use" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/GenericDeployment.php#L48-L73
appserver-io/appserver
src/AppserverIo/Appserver/Core/GenericDeployment.php
GenericDeployment.prepareDatasourceFiles
protected function prepareDatasourceFiles(array $datasourceFiles) { // initialize the array for the prepared datasources $ds = array(); // prepare the datasources foreach ($datasourceFiles as $datasourceFile) { // explode the directoriy names from the app base path $contextPath = explode(DIRECTORY_SEPARATOR, ltrim(str_replace(sprintf('%s', $this->getAppBase()), '', $datasourceFile), DIRECTORY_SEPARATOR)); // the first element IS the context name $contextName = reset($contextPath); // create the path to the web application $webappPath = $this->getDatasourceService()->getWebappsDir($this->getContainer()->getContainerNode(), $contextName); // append it to the array with the prepared datasources $ds[] = array($datasourceFile, $webappPath, $contextName); } // return the array with the prepared datasources return $ds; }
php
protected function prepareDatasourceFiles(array $datasourceFiles) { // initialize the array for the prepared datasources $ds = array(); // prepare the datasources foreach ($datasourceFiles as $datasourceFile) { // explode the directoriy names from the app base path $contextPath = explode(DIRECTORY_SEPARATOR, ltrim(str_replace(sprintf('%s', $this->getAppBase()), '', $datasourceFile), DIRECTORY_SEPARATOR)); // the first element IS the context name $contextName = reset($contextPath); // create the path to the web application $webappPath = $this->getDatasourceService()->getWebappsDir($this->getContainer()->getContainerNode(), $contextName); // append it to the array with the prepared datasources $ds[] = array($datasourceFile, $webappPath, $contextName); } // return the array with the prepared datasources return $ds; }
[ "protected", "function", "prepareDatasourceFiles", "(", "array", "$", "datasourceFiles", ")", "{", "// initialize the array for the prepared datasources", "$", "ds", "=", "array", "(", ")", ";", "// prepare the datasources", "foreach", "(", "$", "datasourceFiles", "as", ...
Prepares the datasource files by adding the found context name and the webapp path, if available. @param array $datasourceFiles The array with the datasource files to prepare @return array The prepared array
[ "Prepares", "the", "datasource", "files", "by", "adding", "the", "found", "context", "name", "and", "the", "webapp", "path", "if", "available", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/GenericDeployment.php#L83-L103
appserver-io/appserver
src/AppserverIo/Appserver/Core/GenericDeployment.php
GenericDeployment.deployDatasources
protected function deployDatasources() { // load the container $container = $this->getContainer(); // load the container and check if we actually have datasource files to work with if ($datasourceFiles = $this->getDatasourceFiles()) { // load the naming directory instance $namingDirectory = $container->getNamingDirectory(); // create a subdirectory for the container's datasoruces $namingDirectory->createSubdirectory(sprintf('php:env/%s/ds', $this->getContainer()->getName())); // iterate through all provisioning files (*-ds.xml), validate them and attach them to the configuration /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getConfigurationService(); foreach ($datasourceFiles as $datasourceFile) { try { // explode the filename, context name and webapp path list ($filename, $webappPath, $contextName) = $datasourceFile; // validate the file, but skip it if validation fails $configurationService->validateFile($filename); // load the system properties $systemProperties = $this->getDatasourceService()->getSystemProperties($container->getContainerNode()); // append the application specific properties $systemProperties->add(SystemPropertyKeys::WEBAPP, $webappPath); $systemProperties->add(SystemPropertyKeys::WEBAPP_NAME, $contextName); // load the datasources from the file and replace the properties $datasourcesNode = new DatasourcesNode(); $datasourcesNode->initFromFile($filename); $datasourcesNode->replaceProperties($systemProperties); // store the datasource in the system configuration /** @var \AppserverIo\Description\Api\Node\DatasourceNode $datasourceNode */ foreach ($datasourcesNode->getDatasources() as $datasourceNode) { // add the datasource to the system configuration $this->getDatasourceService()->persist($datasourceNode); // bind the datasource to the naming directory $namingDirectory->bind(sprintf('php:env/%s/ds/%s', $container->getName(), $datasourceNode->getName()), $datasourceNode); // log a message that the datasource has been deployed $this->getInitialContext()->getSystemLogger()->debug( sprintf('Successfully deployed datasource %s', $datasourceNode->getName()) ); } // log a message and continue with the next datasource node } catch (\Exception $e) { // load the logger and log the XML validation errors $systemLogger = $this->getInitialContext()->getSystemLogger(); $systemLogger->error($e->__toString()); // additionally log a message that DS will be missing $systemLogger->critical( sprintf('Will skip reading configuration in %s, datasources might be missing.', $filename) ); } } } }
php
protected function deployDatasources() { // load the container $container = $this->getContainer(); // load the container and check if we actually have datasource files to work with if ($datasourceFiles = $this->getDatasourceFiles()) { // load the naming directory instance $namingDirectory = $container->getNamingDirectory(); // create a subdirectory for the container's datasoruces $namingDirectory->createSubdirectory(sprintf('php:env/%s/ds', $this->getContainer()->getName())); // iterate through all provisioning files (*-ds.xml), validate them and attach them to the configuration /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getConfigurationService(); foreach ($datasourceFiles as $datasourceFile) { try { // explode the filename, context name and webapp path list ($filename, $webappPath, $contextName) = $datasourceFile; // validate the file, but skip it if validation fails $configurationService->validateFile($filename); // load the system properties $systemProperties = $this->getDatasourceService()->getSystemProperties($container->getContainerNode()); // append the application specific properties $systemProperties->add(SystemPropertyKeys::WEBAPP, $webappPath); $systemProperties->add(SystemPropertyKeys::WEBAPP_NAME, $contextName); // load the datasources from the file and replace the properties $datasourcesNode = new DatasourcesNode(); $datasourcesNode->initFromFile($filename); $datasourcesNode->replaceProperties($systemProperties); // store the datasource in the system configuration /** @var \AppserverIo\Description\Api\Node\DatasourceNode $datasourceNode */ foreach ($datasourcesNode->getDatasources() as $datasourceNode) { // add the datasource to the system configuration $this->getDatasourceService()->persist($datasourceNode); // bind the datasource to the naming directory $namingDirectory->bind(sprintf('php:env/%s/ds/%s', $container->getName(), $datasourceNode->getName()), $datasourceNode); // log a message that the datasource has been deployed $this->getInitialContext()->getSystemLogger()->debug( sprintf('Successfully deployed datasource %s', $datasourceNode->getName()) ); } // log a message and continue with the next datasource node } catch (\Exception $e) { // load the logger and log the XML validation errors $systemLogger = $this->getInitialContext()->getSystemLogger(); $systemLogger->error($e->__toString()); // additionally log a message that DS will be missing $systemLogger->critical( sprintf('Will skip reading configuration in %s, datasources might be missing.', $filename) ); } } } }
[ "protected", "function", "deployDatasources", "(", ")", "{", "// load the container", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "// load the container and check if we actually have datasource files to work with", "if", "(", "$", "datasourceFil...
Deploys the available root directory datasources. @return void
[ "Deploys", "the", "available", "root", "directory", "datasources", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/GenericDeployment.php#L142-L207
appserver-io/appserver
src/AppserverIo/Appserver/Core/GenericDeployment.php
GenericDeployment.deployApplications
protected function deployApplications() { // load the container and initial context instance $container = $this->getContainer(); // load the context instances for this container $contextInstances = $this->loadContextInstances(); // gather all the deployed web applications foreach ($contextInstances as $context) { // try to load the application factory if ($applicationFactory = $context->getFactory()) { // use the factory if available $applicationFactory::visit($container, $context); } else { // if not, try to instantiate the application directly $applicationType = $context->getType(); $container->addApplication(new $applicationType($context)); } // log a message that the application has been initialized and started $this->getInitialContext()->getSystemLogger()->debug( sprintf('Successfully initialized and started application %s', $context->getName()) ); } }
php
protected function deployApplications() { // load the container and initial context instance $container = $this->getContainer(); // load the context instances for this container $contextInstances = $this->loadContextInstances(); // gather all the deployed web applications foreach ($contextInstances as $context) { // try to load the application factory if ($applicationFactory = $context->getFactory()) { // use the factory if available $applicationFactory::visit($container, $context); } else { // if not, try to instantiate the application directly $applicationType = $context->getType(); $container->addApplication(new $applicationType($context)); } // log a message that the application has been initialized and started $this->getInitialContext()->getSystemLogger()->debug( sprintf('Successfully initialized and started application %s', $context->getName()) ); } }
[ "protected", "function", "deployApplications", "(", ")", "{", "// load the container and initial context instance", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "// load the context instances for this container", "$", "contextInstances", "=", "$"...
Deploys the available applications. @return void
[ "Deploys", "the", "available", "applications", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/GenericDeployment.php#L214-L240
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Session/ApcSessionHandler.php
ApcSessionHandler.load
public function load($id) { try { return $this->unpersist($id); } catch (SessionDataNotReadableException $sdnre) { $this->delete($id); } }
php
public function load($id) { try { return $this->unpersist($id); } catch (SessionDataNotReadableException $sdnre) { $this->delete($id); } }
[ "public", "function", "load", "(", "$", "id", ")", "{", "try", "{", "return", "$", "this", "->", "unpersist", "(", "$", "id", ")", ";", "}", "catch", "(", "SessionDataNotReadableException", "$", "sdnre", ")", "{", "$", "this", "->", "delete", "(", "$...
Loads the session with the passed ID from the persistence layer and returns it. @param string $id The ID of the session we want to unpersist @return \AppserverIo\Psr\Servlet\ServletSessionInterface The unpersisted session
[ "Loads", "the", "session", "with", "the", "passed", "ID", "from", "the", "persistence", "layer", "and", "returns", "it", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Session/ApcSessionHandler.php#L56-L64
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Session/ApcSessionHandler.php
ApcSessionHandler.save
public function save(ServletSessionInterface $session) { // don't save the session if it has been destroyed if ($session->getId() == null) { return; } // update the checksum and the file that stores the session data if (apc_store($session->getId(), $this->marshall($session)) === false) { throw new SessionCanNotBeSavedException( sprintf('Session with ID %s can\'t be saved') ); } }
php
public function save(ServletSessionInterface $session) { // don't save the session if it has been destroyed if ($session->getId() == null) { return; } // update the checksum and the file that stores the session data if (apc_store($session->getId(), $this->marshall($session)) === false) { throw new SessionCanNotBeSavedException( sprintf('Session with ID %s can\'t be saved') ); } }
[ "public", "function", "save", "(", "ServletSessionInterface", "$", "session", ")", "{", "// don't save the session if it has been destroyed", "if", "(", "$", "session", "->", "getId", "(", ")", "==", "null", ")", "{", "return", ";", "}", "// update the checksum and ...
Saves the passed session to the persistence layer. @param \AppserverIo\Psr\Servlet\ServletSessionInterface $session The session to save @return void @throws \AppserverIo\Appserver\ServletEngine\SessionCanNotBeSavedException Is thrown if the session can't be saved
[ "Saves", "the", "passed", "session", "to", "the", "persistence", "layer", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Session/ApcSessionHandler.php#L91-L105
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Session/ApcSessionHandler.php
ApcSessionHandler.collectGarbage
public function collectGarbage() { // counter to store the number of removed sessions $sessionRemovalCount = 0; // iterate over the found session items foreach (new \ApcIterator(ApcSessionHandler::APCU_CACHE_TYPE_USER) as $item) { // initialize the key $key = null; // explode the APC item extract($item); // unpersist the session $session = $this->unpersist($key); // query whether or not the session has been expired if ($this->sessionTimedOut($session)) { // if yes, delete the file + raise the session removal count $this->delete($key); $sessionRemovalCount++; } } // return the number of removed sessions return $sessionRemovalCount; }
php
public function collectGarbage() { // counter to store the number of removed sessions $sessionRemovalCount = 0; // iterate over the found session items foreach (new \ApcIterator(ApcSessionHandler::APCU_CACHE_TYPE_USER) as $item) { // initialize the key $key = null; // explode the APC item extract($item); // unpersist the session $session = $this->unpersist($key); // query whether or not the session has been expired if ($this->sessionTimedOut($session)) { // if yes, delete the file + raise the session removal count $this->delete($key); $sessionRemovalCount++; } } // return the number of removed sessions return $sessionRemovalCount; }
[ "public", "function", "collectGarbage", "(", ")", "{", "// counter to store the number of removed sessions", "$", "sessionRemovalCount", "=", "0", ";", "// iterate over the found session items", "foreach", "(", "new", "\\", "ApcIterator", "(", "ApcSessionHandler", "::", "AP...
Collects the garbage by deleting expired sessions. @return integer The number of removed sessions
[ "Collects", "the", "garbage", "by", "deleting", "expired", "sessions", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Session/ApcSessionHandler.php#L112-L137
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Session/ApcSessionHandler.php
ApcSessionHandler.unpersist
protected function unpersist($id) { // the requested session file is not a valid file if (apc_exists($id) === false) { return; } // decode the session from the filesystem if (($marshalled = apc_fetch($id)) === false) { throw new SessionDataNotReadableException(sprintf('Can\'t load session with ID %s', $id)); } // create a new session instance from the marshaled object representation return $this->unmarshall($marshalled); }
php
protected function unpersist($id) { // the requested session file is not a valid file if (apc_exists($id) === false) { return; } // decode the session from the filesystem if (($marshalled = apc_fetch($id)) === false) { throw new SessionDataNotReadableException(sprintf('Can\'t load session with ID %s', $id)); } // create a new session instance from the marshaled object representation return $this->unmarshall($marshalled); }
[ "protected", "function", "unpersist", "(", "$", "id", ")", "{", "// the requested session file is not a valid file", "if", "(", "apc_exists", "(", "$", "id", ")", "===", "false", ")", "{", "return", ";", "}", "// decode the session from the filesystem", "if", "(", ...
Tries to load the session data with the passed ID. @param string $id The ID of the session to load @return \AppserverIo\Psr\Servlet\Http\HttpSessionInterface The unmarshalled session @throws \AppserverIo\Appserver\ServletEngine\SessionDataNotReadableException Is thrown if the file containing the session data is not readable
[ "Tries", "to", "load", "the", "session", "data", "with", "the", "passed", "ID", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Session/ApcSessionHandler.php#L147-L162
appserver-io/appserver
src/AppserverIo/Appserver/Core/Commands/Helper/Arguments.php
Arguments.split
public static function split($command) { // whitespace characters count as argument separators static $ws = array( ' ', "\r", "\n", "\t", "\v", ); $i = 0; $args = array(); while (true) { // skip all whitespace characters for (; isset($command[$i]) && in_array($command[$i], $ws); ++$i) { } // command string ended if (!isset($command[$i])) { break; } $inQuote = null; $quotePosition = 0; $argument = ''; $part = ''; // read a single argument for (; isset($command[$i]); ++$i) { $c = $command[$i]; if ($inQuote === "'") { // we're within a 'single quoted' string if ($c === '\\' && isset($command[$i + 1]) && ($command[$i + 1] === "'" || $command[$i + 1] === '\\')) { // escaped single quote or backslash ends up as char in argument $part .= $command[++$i]; continue; } elseif ($c === "'") { // single quote ends $inQuote = null; $argument .= $part; $part = ''; continue; } } else { // we're not within any quotes or within a "double quoted" string if ($c === '\\' && isset($command[$i + 1])) { if ($command[$i + 1] === 'u') { // this looks like a unicode escape sequence // use JSON parser to interpret this $c = json_decode('"' . substr($command, $i, 6) . '"'); if ($c !== null) { // on success => use interpreted and skip sequence $argument .= stripcslashes($part) . $c; $part = ''; $i += 5; continue; } } // escaped characters will be interpreted when part is complete $part .= $command[$i] . $command[$i + 1]; ++$i; continue; } elseif ($inQuote === '"' && $c === '"') { // double quote ends $inQuote = null; // previous double quoted part should be interpreted $argument .= stripcslashes($part); $part = ''; continue; } elseif ($inQuote === null && ($c === '"' || $c === "'")) { // start of quotes found $inQuote = $c; $quotePosition = $i; // previous unquoted part should be interpreted $argument .= stripcslashes($part); $part = ''; continue; } elseif ($inQuote === null && in_array($c, $ws)) { // whitespace character terminates unquoted argument break; } } $part .= $c; } // end of argument reached. Still in quotes is a parse error. if ($inQuote !== null) { throw new UnclosedQuotesException($inQuote, $quotePosition); } // add remaining part to current argument if ($part !== '') { $argument .= stripcslashes($part); } $args []= $argument; } return $args; }
php
public static function split($command) { // whitespace characters count as argument separators static $ws = array( ' ', "\r", "\n", "\t", "\v", ); $i = 0; $args = array(); while (true) { // skip all whitespace characters for (; isset($command[$i]) && in_array($command[$i], $ws); ++$i) { } // command string ended if (!isset($command[$i])) { break; } $inQuote = null; $quotePosition = 0; $argument = ''; $part = ''; // read a single argument for (; isset($command[$i]); ++$i) { $c = $command[$i]; if ($inQuote === "'") { // we're within a 'single quoted' string if ($c === '\\' && isset($command[$i + 1]) && ($command[$i + 1] === "'" || $command[$i + 1] === '\\')) { // escaped single quote or backslash ends up as char in argument $part .= $command[++$i]; continue; } elseif ($c === "'") { // single quote ends $inQuote = null; $argument .= $part; $part = ''; continue; } } else { // we're not within any quotes or within a "double quoted" string if ($c === '\\' && isset($command[$i + 1])) { if ($command[$i + 1] === 'u') { // this looks like a unicode escape sequence // use JSON parser to interpret this $c = json_decode('"' . substr($command, $i, 6) . '"'); if ($c !== null) { // on success => use interpreted and skip sequence $argument .= stripcslashes($part) . $c; $part = ''; $i += 5; continue; } } // escaped characters will be interpreted when part is complete $part .= $command[$i] . $command[$i + 1]; ++$i; continue; } elseif ($inQuote === '"' && $c === '"') { // double quote ends $inQuote = null; // previous double quoted part should be interpreted $argument .= stripcslashes($part); $part = ''; continue; } elseif ($inQuote === null && ($c === '"' || $c === "'")) { // start of quotes found $inQuote = $c; $quotePosition = $i; // previous unquoted part should be interpreted $argument .= stripcslashes($part); $part = ''; continue; } elseif ($inQuote === null && in_array($c, $ws)) { // whitespace character terminates unquoted argument break; } } $part .= $c; } // end of argument reached. Still in quotes is a parse error. if ($inQuote !== null) { throw new UnclosedQuotesException($inQuote, $quotePosition); } // add remaining part to current argument if ($part !== '') { $argument .= stripcslashes($part); } $args []= $argument; } return $args; }
[ "public", "static", "function", "split", "(", "$", "command", ")", "{", "// whitespace characters count as argument separators", "static", "$", "ws", "=", "array", "(", "' '", ",", "\"\\r\"", ",", "\"\\n\"", ",", "\"\\t\"", ",", "\"\\v\"", ",", ")", ";", "$", ...
Splits the given command line string into an array of command arguments. @param string $command The command line string @return array Array of command line argument strings @throws \RuntimeException Is thrown, if the arguments has not been quoted as expected
[ "Splits", "the", "given", "command", "line", "string", "into", "an", "array", "of", "command", "arguments", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Commands/Helper/Arguments.php#L45-L152
appserver-io/appserver
src/AppserverIo/Appserver/Console/ConsoleManager.php
ConsoleManager.execute
public function execute(ConnectionInterface $connection, array $argv) { // initialize input/output instances $input = new ArgvInput($argv); $output = new BufferedOutput(); // initialize the execution context $executionContext = new ExecutionContext(); $executionContext->injectInput($input); $executionContext->injectOutput($output); $executionContext->injectApplication($this->getApplication()); // start the execution context $executionContext->start(); $executionContext->join(); // write the result back to the connection $executionContext->write($connection); }
php
public function execute(ConnectionInterface $connection, array $argv) { // initialize input/output instances $input = new ArgvInput($argv); $output = new BufferedOutput(); // initialize the execution context $executionContext = new ExecutionContext(); $executionContext->injectInput($input); $executionContext->injectOutput($output); $executionContext->injectApplication($this->getApplication()); // start the execution context $executionContext->start(); $executionContext->join(); // write the result back to the connection $executionContext->write($connection); }
[ "public", "function", "execute", "(", "ConnectionInterface", "$", "connection", ",", "array", "$", "argv", ")", "{", "// initialize input/output instances", "$", "input", "=", "new", "ArgvInput", "(", "$", "argv", ")", ";", "$", "output", "=", "new", "Buffered...
Executes the command with defined by the passed input. @param \React\Socket\ConnectionInterface $connection The socket connection @param array $argv The arguments from the console @return void
[ "Executes", "the", "command", "with", "defined", "by", "the", "passed", "input", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Console/ConsoleManager.php#L63-L82
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.postStartup
public function postStartup(ApplicationInterface $application) { // load the object manager /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $application->search(ObjectManagerInterface::IDENTIFIER); // register the beans found by annotations and the XML configuration /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ foreach ($objectManager->getObjectDescriptors() as $descriptor) { // if we found a singleton session bean with a startup callback instanciate it if ($descriptor instanceof SingletonSessionBeanDescriptorInterface && $descriptor->isInitOnStartup()) { $this->startupBeanTasks[] = new StartupBeanTask($application, $descriptor); } } }
php
public function postStartup(ApplicationInterface $application) { // load the object manager /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $application->search(ObjectManagerInterface::IDENTIFIER); // register the beans found by annotations and the XML configuration /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ foreach ($objectManager->getObjectDescriptors() as $descriptor) { // if we found a singleton session bean with a startup callback instanciate it if ($descriptor instanceof SingletonSessionBeanDescriptorInterface && $descriptor->isInitOnStartup()) { $this->startupBeanTasks[] = new StartupBeanTask($application, $descriptor); } } }
[ "public", "function", "postStartup", "(", "ApplicationInterface", "$", "application", ")", "{", "// load the object manager", "/** @var \\AppserverIo\\Psr\\Di\\ObjectManagerInterface $objectManager */", "$", "objectManager", "=", "$", "application", "->", "search", "(", "Object...
Lifecycle callback that'll be invoked after the application has been started. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance @return void @see \AppserverIo\Psr\Application\ManagerInterface::postStartup()
[ "Lifecycle", "callback", "that", "ll", "be", "invoked", "after", "the", "application", "has", "been", "started", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L206-L221
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.initialize
public function initialize(ApplicationInterface $application) { // add the application instance to the environment Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application); // create s simulated request/session ID whereas session equals request ID Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString()); Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId); // finally register the beans $this->registerBeans($application); }
php
public function initialize(ApplicationInterface $application) { // add the application instance to the environment Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application); // create s simulated request/session ID whereas session equals request ID Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString()); Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId); // finally register the beans $this->registerBeans($application); }
[ "public", "function", "initialize", "(", "ApplicationInterface", "$", "application", ")", "{", "// add the application instance to the environment", "Environment", "::", "singleton", "(", ")", "->", "setAttribute", "(", "EnvironmentKeys", "::", "APPLICATION", ",", "$", ...
Has been automatically invoked by the container after the application instance has been created. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance @return void @see \AppserverIo\Psr\Application\ManagerInterface::initialize()
[ "Has", "been", "automatically", "invoked", "by", "the", "container", "after", "the", "application", "instance", "has", "been", "created", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L232-L244
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.registerBeans
public function registerBeans(ApplicationInterface $application) { // parse the object descriptors $this->parseObjectDescriptors(); // load the object manager /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // register the beans found by annotations and the XML configuration /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ foreach ($objectManager->getObjectDescriptors() as $descriptor) { // check if we've found a bean descriptor and register the bean if ($descriptor instanceof BeanDescriptorInterface) { $this->registerBean($descriptor); } } }
php
public function registerBeans(ApplicationInterface $application) { // parse the object descriptors $this->parseObjectDescriptors(); // load the object manager /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // register the beans found by annotations and the XML configuration /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ foreach ($objectManager->getObjectDescriptors() as $descriptor) { // check if we've found a bean descriptor and register the bean if ($descriptor instanceof BeanDescriptorInterface) { $this->registerBean($descriptor); } } }
[ "public", "function", "registerBeans", "(", "ApplicationInterface", "$", "application", ")", "{", "// parse the object descriptors", "$", "this", "->", "parseObjectDescriptors", "(", ")", ";", "// load the object manager", "/** @var \\AppserverIo\\Psr\\Di\\ObjectManagerInterface ...
Registers the message beans at startup. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance @return void
[ "Registers", "the", "message", "beans", "at", "startup", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L253-L271
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.registerBean
public function registerBean(BeanDescriptorInterface $descriptor) { try { // load the application instance $application = $this->getApplication(); // register the bean with the default name/short class name $application->getNamingDirectory() ->bind( sprintf('php:global/%s/%s', $application->getUniqueName(), $descriptor->getName()), array(&$this, 'lookup'), array($descriptor->getName()) ); // register's the bean's references $this->registerReferences($descriptor); // generate the remote proxy and register it in the naming directory $this->getRemoteProxyGenerator()->generate($descriptor); } catch (\Exception $e) { // log the exception $this->getApplication()->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
php
public function registerBean(BeanDescriptorInterface $descriptor) { try { // load the application instance $application = $this->getApplication(); // register the bean with the default name/short class name $application->getNamingDirectory() ->bind( sprintf('php:global/%s/%s', $application->getUniqueName(), $descriptor->getName()), array(&$this, 'lookup'), array($descriptor->getName()) ); // register's the bean's references $this->registerReferences($descriptor); // generate the remote proxy and register it in the naming directory $this->getRemoteProxyGenerator()->generate($descriptor); } catch (\Exception $e) { // log the exception $this->getApplication()->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
[ "public", "function", "registerBean", "(", "BeanDescriptorInterface", "$", "descriptor", ")", "{", "try", "{", "// load the application instance", "$", "application", "=", "$", "this", "->", "getApplication", "(", ")", ";", "// register the bean with the default name/shor...
Register the bean described by the passed descriptor. @param \AppserverIo\Psr\EnterpriseBeans\Description\BeanDescriptorInterface $descriptor The bean descriptor @return void
[ "Register", "the", "bean", "described", "by", "the", "passed", "descriptor", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L280-L305
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.lookupStatefulSessionBean
public function lookupStatefulSessionBean($sessionId, $className) { // create a unique SFSB identifier $identifier = SessionBeanUtil::createIdentifier($sessionId, $className); // load the map with the SFSBs $sessionBeans = $this->getStatefulSessionBeans(); // if the SFSB exists, return it if ($sessionBeans->exists($identifier)) { return $sessionBeans->get($identifier); } }
php
public function lookupStatefulSessionBean($sessionId, $className) { // create a unique SFSB identifier $identifier = SessionBeanUtil::createIdentifier($sessionId, $className); // load the map with the SFSBs $sessionBeans = $this->getStatefulSessionBeans(); // if the SFSB exists, return it if ($sessionBeans->exists($identifier)) { return $sessionBeans->get($identifier); } }
[ "public", "function", "lookupStatefulSessionBean", "(", "$", "sessionId", ",", "$", "className", ")", "{", "// create a unique SFSB identifier", "$", "identifier", "=", "SessionBeanUtil", "::", "createIdentifier", "(", "$", "sessionId", ",", "$", "className", ")", "...
Retrieves the requested stateful session bean. @param string $sessionId The session-ID of the stateful session bean to retrieve @param string $className The class name of the session bean to retrieve @return object|null The stateful session bean if available
[ "Retrieves", "the", "requested", "stateful", "session", "bean", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L434-L447
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.removeStatefulSessionBean
public function removeStatefulSessionBean($sessionId, $className) { // create a unique SFSB identifier $identifier = SessionBeanUtil::createIdentifier($sessionId, $className); // load the map with the SFSBs $sessionBeans = $this->getStatefulSessionBeans(); // query whether the SFSB with the passed identifier exists if ($sessionBeans->exists($identifier)) { $sessionBeans->remove($identifier, array($this, 'destroyBeanInstance')); } }
php
public function removeStatefulSessionBean($sessionId, $className) { // create a unique SFSB identifier $identifier = SessionBeanUtil::createIdentifier($sessionId, $className); // load the map with the SFSBs $sessionBeans = $this->getStatefulSessionBeans(); // query whether the SFSB with the passed identifier exists if ($sessionBeans->exists($identifier)) { $sessionBeans->remove($identifier, array($this, 'destroyBeanInstance')); } }
[ "public", "function", "removeStatefulSessionBean", "(", "$", "sessionId", ",", "$", "className", ")", "{", "// create a unique SFSB identifier", "$", "identifier", "=", "SessionBeanUtil", "::", "createIdentifier", "(", "$", "sessionId", ",", "$", "className", ")", "...
Removes the stateful session bean with the passed session-ID and class name from the bean manager. @param string $sessionId The session-ID of the stateful session bean to retrieve @param string $className The class name of the session bean to retrieve @return void
[ "Removes", "the", "stateful", "session", "bean", "with", "the", "passed", "session", "-", "ID", "and", "class", "name", "from", "the", "bean", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L458-L471
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.lookupSingletonSessionBean
public function lookupSingletonSessionBean($className) { if ($this->getSingletonSessionBeans()->has($className) === true) { return $this->getSingletonSessionBeans()->get($className); } }
php
public function lookupSingletonSessionBean($className) { if ($this->getSingletonSessionBeans()->has($className) === true) { return $this->getSingletonSessionBeans()->get($className); } }
[ "public", "function", "lookupSingletonSessionBean", "(", "$", "className", ")", "{", "if", "(", "$", "this", "->", "getSingletonSessionBeans", "(", ")", "->", "has", "(", "$", "className", ")", "===", "true", ")", "{", "return", "$", "this", "->", "getSing...
Retrieves the requested singleton session bean. @param string $className The class name of the session bean to retrieve @return object|null The singleton session bean if available
[ "Retrieves", "the", "requested", "singleton", "session", "bean", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L493-L498
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.destroyBeanInstance
public function destroyBeanInstance($instance) { // load the object manager $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // load the bean descriptor $descriptor = $objectManager->getObjectDescriptors()->get(get_class($instance)); // invoke the pre-destroy callbacks if we've a session bean if ($descriptor instanceof SessionBeanDescriptorInterface) { foreach ($descriptor->getPreDestroyCallbacks() as $preDestroyCallback) { $instance->$preDestroyCallback(); } } }
php
public function destroyBeanInstance($instance) { // load the object manager $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // load the bean descriptor $descriptor = $objectManager->getObjectDescriptors()->get(get_class($instance)); // invoke the pre-destroy callbacks if we've a session bean if ($descriptor instanceof SessionBeanDescriptorInterface) { foreach ($descriptor->getPreDestroyCallbacks() as $preDestroyCallback) { $instance->$preDestroyCallback(); } } }
[ "public", "function", "destroyBeanInstance", "(", "$", "instance", ")", "{", "// load the object manager", "$", "objectManager", "=", "$", "this", "->", "getApplication", "(", ")", "->", "search", "(", "ObjectManagerInterface", "::", "IDENTIFIER", ")", ";", "// lo...
Invokes the bean method with a pre-destroy callback. @param object $instance The instance to invoke the method @return void
[ "Invokes", "the", "bean", "method", "with", "a", "pre", "-", "destroy", "callback", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L507-L522
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.invoke
public function invoke(RemoteMethodInterface $remoteMethod, CollectionInterface $sessions) { // prepare method name and parameters and invoke method $className = $remoteMethod->getClassName(); $methodName = $remoteMethod->getMethodName(); $parameters = $remoteMethod->getParameters(); // load the session ID from the environment $sessionId = Environment::singleton()->getAttribute(EnvironmentKeys::SESSION_ID); // load the application instance $application = $this->getApplication(); // load a fresh bean instance and add it to the session container $instance = $this->lookup($className); // invoke the remote method call on the local instance $response = call_user_func_array(array($instance, $methodName), $parameters); // load the object manager $objectManager = $application->search(ObjectManagerInterface::IDENTIFIER); // load the bean descriptor $objectDescriptor = $objectManager->getObjectDescriptor($className); // initialize the flag to mark the instance to be re-attached $attach = true; // query if we've SFSB if ($objectDescriptor instanceof StatefulSessionBeanDescriptorInterface) { // remove the SFSB instance if a remove method has been called if ($objectDescriptor->isRemoveMethod($methodName)) { $this->removeStatefulSessionBean($sessionId, $objectDescriptor->getClassName()); $attach = false; } } // re-attach the bean instance if necessary if ($attach === true) { $this->attach($objectDescriptor, $instance); } // return the remote method call result return $response; }
php
public function invoke(RemoteMethodInterface $remoteMethod, CollectionInterface $sessions) { // prepare method name and parameters and invoke method $className = $remoteMethod->getClassName(); $methodName = $remoteMethod->getMethodName(); $parameters = $remoteMethod->getParameters(); // load the session ID from the environment $sessionId = Environment::singleton()->getAttribute(EnvironmentKeys::SESSION_ID); // load the application instance $application = $this->getApplication(); // load a fresh bean instance and add it to the session container $instance = $this->lookup($className); // invoke the remote method call on the local instance $response = call_user_func_array(array($instance, $methodName), $parameters); // load the object manager $objectManager = $application->search(ObjectManagerInterface::IDENTIFIER); // load the bean descriptor $objectDescriptor = $objectManager->getObjectDescriptor($className); // initialize the flag to mark the instance to be re-attached $attach = true; // query if we've SFSB if ($objectDescriptor instanceof StatefulSessionBeanDescriptorInterface) { // remove the SFSB instance if a remove method has been called if ($objectDescriptor->isRemoveMethod($methodName)) { $this->removeStatefulSessionBean($sessionId, $objectDescriptor->getClassName()); $attach = false; } } // re-attach the bean instance if necessary if ($attach === true) { $this->attach($objectDescriptor, $instance); } // return the remote method call result return $response; }
[ "public", "function", "invoke", "(", "RemoteMethodInterface", "$", "remoteMethod", ",", "CollectionInterface", "$", "sessions", ")", "{", "// prepare method name and parameters and invoke method", "$", "className", "=", "$", "remoteMethod", "->", "getClassName", "(", ")",...
Invoke the passed remote method on the described session bean and return the result. @param \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface $remoteMethod The remote method description @param \AppserverIo\Collections\CollectionInterface $sessions The collection with the sessions @return mixed The result of the remote method invocation
[ "Invoke", "the", "passed", "remote", "method", "on", "the", "described", "session", "bean", "and", "return", "the", "result", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L532-L577
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.attach
public function attach(DescriptorInterface $objectDescriptor, $instance) { // load the session ID from the environment $sessionId = Environment::singleton()->getAttribute(EnvironmentKeys::SESSION_ID); // query if we've stateful session bean if ($objectDescriptor instanceof StatefulSessionBeanDescriptorInterface) { // check if we've a session-ID available if ($sessionId == null) { throw new \Exception('Can\'t find a session-ID to attach stateful session bean'); } // load the lifetime from the session bean settings $lifetime = $this->getManagerSettings()->getLifetime(); // we've to check for pre-attach callbacks foreach ($objectDescriptor->getPreAttachCallbacks() as $preAttachCallback) { $instance->$preAttachCallback(); } // create a unique SFSB identifier $identifier = SessionBeanUtil::createIdentifier($sessionId, $objectDescriptor->getName()); // load the map with the SFSBs $sessionBeans = $this->getStatefulSessionBeans(); // add the stateful session bean to the map $sessionBeans->add($identifier, $instance, $lifetime); // stop processing here return; } // query if we've stateless session or message bean if ($objectDescriptor instanceof StatelessSessionBeanDescriptorInterface || $objectDescriptor instanceof MessageDrivenBeanDescriptorInterface) { // simply destroy the instance $this->destroyBeanInstance($instance); // stop processing here return; } // query if we've singleton session bean if ($objectDescriptor instanceof SingletonSessionBeanDescriptorInterface) { // we've to check for pre-attach callbacks foreach ($objectDescriptor->getPreAttachCallbacks() as $preAttachCallback) { $instance->$preAttachCallback(); } // stop processing here return; } // we've an unknown bean type => throw an exception throw new InvalidBeanTypeException('Tried to attach invalid bean type'); }
php
public function attach(DescriptorInterface $objectDescriptor, $instance) { // load the session ID from the environment $sessionId = Environment::singleton()->getAttribute(EnvironmentKeys::SESSION_ID); // query if we've stateful session bean if ($objectDescriptor instanceof StatefulSessionBeanDescriptorInterface) { // check if we've a session-ID available if ($sessionId == null) { throw new \Exception('Can\'t find a session-ID to attach stateful session bean'); } // load the lifetime from the session bean settings $lifetime = $this->getManagerSettings()->getLifetime(); // we've to check for pre-attach callbacks foreach ($objectDescriptor->getPreAttachCallbacks() as $preAttachCallback) { $instance->$preAttachCallback(); } // create a unique SFSB identifier $identifier = SessionBeanUtil::createIdentifier($sessionId, $objectDescriptor->getName()); // load the map with the SFSBs $sessionBeans = $this->getStatefulSessionBeans(); // add the stateful session bean to the map $sessionBeans->add($identifier, $instance, $lifetime); // stop processing here return; } // query if we've stateless session or message bean if ($objectDescriptor instanceof StatelessSessionBeanDescriptorInterface || $objectDescriptor instanceof MessageDrivenBeanDescriptorInterface) { // simply destroy the instance $this->destroyBeanInstance($instance); // stop processing here return; } // query if we've singleton session bean if ($objectDescriptor instanceof SingletonSessionBeanDescriptorInterface) { // we've to check for pre-attach callbacks foreach ($objectDescriptor->getPreAttachCallbacks() as $preAttachCallback) { $instance->$preAttachCallback(); } // stop processing here return; } // we've an unknown bean type => throw an exception throw new InvalidBeanTypeException('Tried to attach invalid bean type'); }
[ "public", "function", "attach", "(", "DescriptorInterface", "$", "objectDescriptor", ",", "$", "instance", ")", "{", "// load the session ID from the environment", "$", "sessionId", "=", "Environment", "::", "singleton", "(", ")", "->", "getAttribute", "(", "Environme...
Attaches the passed bean, depending on it's type to the container. @param \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor The object descriptor for the passed instance @param object $instance The bean instance to attach @return void @throws \AppserverIo\Psr\EnterpriseBeans\InvalidBeanTypeException Is thrown if a invalid bean type has been detected
[ "Attaches", "the", "passed", "bean", "depending", "on", "it", "s", "type", "to", "the", "container", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L588-L645
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php
BeanManager.stop
public function stop() { $this->getGarbageCollector()->stop(); $this->getStartupBeanTaskGarbageCollector()->stop(); $this->getObjectFactory()->stop(); }
php
public function stop() { $this->getGarbageCollector()->stop(); $this->getStartupBeanTaskGarbageCollector()->stop(); $this->getObjectFactory()->stop(); }
[ "public", "function", "stop", "(", ")", "{", "$", "this", "->", "getGarbageCollector", "(", ")", "->", "stop", "(", ")", ";", "$", "this", "->", "getStartupBeanTaskGarbageCollector", "(", ")", "->", "stop", "(", ")", ";", "$", "this", "->", "getObjectFac...
Shutdown the session manager instance. @return void \AppserverIo\Psr\Application\ManagerInterface::stop()
[ "Shutdown", "the", "session", "manager", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManager.php#L664-L669
appserver-io/appserver
src/AppserverIo/Appserver/AspectContainer/AspectManager.php
AspectManager.initialize
public function initialize(ApplicationInterface $application) { /** @var \AppserverIo\Appserver\Core\DgClassLoader $dgClassLoader */ $dgClassLoader = $application->search('DgClassLoader'); // if we did not get the correct class loader our efforts are for naught if (!$dgClassLoader instanceof DgClassLoader) { $application->getInitialContext()->getSystemLogger()->warning( sprintf( 'Application %s uses the aspect manager but does not have access to the required Doppelgaenger class loader, AOP functionality will be omitted.', $application->getName() ) ); return; } // register the aspects and tell the class loader it can fill the cache $this->registerAspects($application); // inject the filled aspect register and create the cache based on it $dgClassLoader->injectAspectRegister($this->getAspectRegister()); $dgClassLoader->createCache(); }
php
public function initialize(ApplicationInterface $application) { /** @var \AppserverIo\Appserver\Core\DgClassLoader $dgClassLoader */ $dgClassLoader = $application->search('DgClassLoader'); // if we did not get the correct class loader our efforts are for naught if (!$dgClassLoader instanceof DgClassLoader) { $application->getInitialContext()->getSystemLogger()->warning( sprintf( 'Application %s uses the aspect manager but does not have access to the required Doppelgaenger class loader, AOP functionality will be omitted.', $application->getName() ) ); return; } // register the aspects and tell the class loader it can fill the cache $this->registerAspects($application); // inject the filled aspect register and create the cache based on it $dgClassLoader->injectAspectRegister($this->getAspectRegister()); $dgClassLoader->createCache(); }
[ "public", "function", "initialize", "(", "ApplicationInterface", "$", "application", ")", "{", "/** @var \\AppserverIo\\Appserver\\Core\\DgClassLoader $dgClassLoader */", "$", "dgClassLoader", "=", "$", "application", "->", "search", "(", "'DgClassLoader'", ")", ";", "// if...
Has been automatically invoked by the container after the application instance has been created. @param \AppserverIo\Psr\Application\ApplicationInterface|\AppserverIo\Psr\Naming\NamingDirectoryInterface $application The application instance @return void
[ "Has", "been", "automatically", "invoked", "by", "the", "container", "after", "the", "application", "instance", "has", "been", "created", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/AspectContainer/AspectManager.php#L135-L158
appserver-io/appserver
src/AppserverIo/Appserver/AspectContainer/AspectManager.php
AspectManager.registerAspectClasses
protected function registerAspectClasses(ApplicationInterface $application) { // check directory for PHP files with classes we want to register /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */ $service = $application->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); // iterate over the directories and try to find aspects $aspectDirectories = $service->globDir($this->getWebappPath() . DIRECTORY_SEPARATOR . '{WEB-INF,META-INF,common}' . DIRECTORY_SEPARATOR . 'classes', GLOB_BRACE); foreach ($aspectDirectories as $aspectDirectory) { // iterate all PHP files found in the directory foreach ($service->globDir($aspectDirectory . DIRECTORY_SEPARATOR . '*.php') as $phpFile) { try { // cut off the META-INF directory and replace OS specific directory separators $relativePathToPhpFile = str_replace(DIRECTORY_SEPARATOR, '\\', str_replace($aspectDirectory, '', $phpFile)); // now cut off the .php extension $className = substr($relativePathToPhpFile, 0, -4); // we need a reflection class to read the annotations $reflectionClass = $this->getReflectionClass($className); // if we found an aspect we have to register it using our aspect register class if ($reflectionClass->hasAnnotation(AspectAnnotation::ANNOTATION)) { $parser = new AspectParser($phpFile, new Config()); $this->aspectRegister->register( $parser->getDefinition($reflectionClass->getShortName(), false) ); } // if class can not be reflected continue with next class } catch (\Exception $e) { // log an error message $application->getInitialContext()->getSystemLogger()->error($e->__toString()); // proceed with the next class continue; } } } }
php
protected function registerAspectClasses(ApplicationInterface $application) { // check directory for PHP files with classes we want to register /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */ $service = $application->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); // iterate over the directories and try to find aspects $aspectDirectories = $service->globDir($this->getWebappPath() . DIRECTORY_SEPARATOR . '{WEB-INF,META-INF,common}' . DIRECTORY_SEPARATOR . 'classes', GLOB_BRACE); foreach ($aspectDirectories as $aspectDirectory) { // iterate all PHP files found in the directory foreach ($service->globDir($aspectDirectory . DIRECTORY_SEPARATOR . '*.php') as $phpFile) { try { // cut off the META-INF directory and replace OS specific directory separators $relativePathToPhpFile = str_replace(DIRECTORY_SEPARATOR, '\\', str_replace($aspectDirectory, '', $phpFile)); // now cut off the .php extension $className = substr($relativePathToPhpFile, 0, -4); // we need a reflection class to read the annotations $reflectionClass = $this->getReflectionClass($className); // if we found an aspect we have to register it using our aspect register class if ($reflectionClass->hasAnnotation(AspectAnnotation::ANNOTATION)) { $parser = new AspectParser($phpFile, new Config()); $this->aspectRegister->register( $parser->getDefinition($reflectionClass->getShortName(), false) ); } // if class can not be reflected continue with next class } catch (\Exception $e) { // log an error message $application->getInitialContext()->getSystemLogger()->error($e->__toString()); // proceed with the next class continue; } } } }
[ "protected", "function", "registerAspectClasses", "(", "ApplicationInterface", "$", "application", ")", "{", "// check directory for PHP files with classes we want to register", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\DeploymentService $service */", "$", "service", "=", "$", "ap...
Registers aspects written within source files which we might encounter @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance @return void
[ "Registers", "aspects", "written", "within", "source", "files", "which", "we", "might", "encounter" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/AspectContainer/AspectManager.php#L219-L260
appserver-io/appserver
src/AppserverIo/Appserver/AspectContainer/AspectManager.php
AspectManager.registerAspectXml
public function registerAspectXml(ApplicationInterface $application) { /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $application->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); // check if we even have a XMl file to read from $xmlPaths = $configurationService->globDir( AppEnvironmentHelper::getEnvironmentAwareGlobPattern($this->getWebappPath(), '{WEB-INF,META-INF,common}' . DIRECTORY_SEPARATOR . self::CONFIG_FILE_GLOB, GLOB_BRACE), GLOB_BRACE ); foreach ($xmlPaths as $xmlPath) { // iterate all XML configuration files we found if (is_readable($xmlPath)) { // validate the file here, if it is not valid we can skip further steps try { $configurationService->validateFile($xmlPath, null, true); } catch (InvalidConfigurationException $e) { /** @var \Psr\Log\LoggerInterface $systemLogger */ $systemLogger = $this->getApplication()->getInitialContext()->getSystemLogger(); $systemLogger->error($e->getMessage()); $systemLogger->critical( sprintf( 'Pointcuts configuration file %s is invalid, AOP functionality might not work as expected.', $xmlPath ) ); continue; } // load the aop config $config = new \SimpleXMLElement(file_get_contents($xmlPath)); $config->registerXPathNamespace('a', 'http://www.appserver.io/appserver'); // create us an aspect // name of the aspect will be the application name $aspect = new Aspect(); $aspect->setName($xmlPath); // check if we got some pointcuts foreach ($config->xpath('/a:pointcuts/a:pointcut') as $pointcutConfiguration) { // build up the pointcut and add it to the collection $pointcut = new Pointcut(); $pointcut->setAspectName($aspect->getName()); $pointcut->setName((string)$pointcutConfiguration->{'pointcut-name'}); $pointcut->setPointcutExpression( new PointcutExpression((string)$pointcutConfiguration->{'pointcut-pattern'}) ); $aspect->getPointcuts()->add($pointcut); } // check if we got some advices foreach ($config->xpath('/a:pointcuts/a:advice') as $adviceConfiguration) { // build up the advice and add it to the aspect $advice = new Advice(); $advice->setAspectName((string)$adviceConfiguration->{'advice-aspect'}); $advice->setName($advice->getAspectName() . '->' . (string)$adviceConfiguration->{'advice-name'}); $advice->setCodeHook((string)$adviceConfiguration->{'advice-type'}); $pointcutPointcut = $this->generatePointcutPointcut((array) $adviceConfiguration->{'advice-pointcuts'}->{'pointcut-name'}, $aspect); $advice->getPointcuts()->add($pointcutPointcut); // finally add the advice to our aspect (we will also add it without pointcuts of its own) $aspect->getAdvices()->add($advice); } // if the aspect contains pointcuts or advices it can be used if ($aspect->getPointcuts()->count() > 0 || $aspect->getAdvices()->count() > 0) { $this->getAspectRegister()->set($aspect->getName(), $aspect); } } } }
php
public function registerAspectXml(ApplicationInterface $application) { /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $application->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); // check if we even have a XMl file to read from $xmlPaths = $configurationService->globDir( AppEnvironmentHelper::getEnvironmentAwareGlobPattern($this->getWebappPath(), '{WEB-INF,META-INF,common}' . DIRECTORY_SEPARATOR . self::CONFIG_FILE_GLOB, GLOB_BRACE), GLOB_BRACE ); foreach ($xmlPaths as $xmlPath) { // iterate all XML configuration files we found if (is_readable($xmlPath)) { // validate the file here, if it is not valid we can skip further steps try { $configurationService->validateFile($xmlPath, null, true); } catch (InvalidConfigurationException $e) { /** @var \Psr\Log\LoggerInterface $systemLogger */ $systemLogger = $this->getApplication()->getInitialContext()->getSystemLogger(); $systemLogger->error($e->getMessage()); $systemLogger->critical( sprintf( 'Pointcuts configuration file %s is invalid, AOP functionality might not work as expected.', $xmlPath ) ); continue; } // load the aop config $config = new \SimpleXMLElement(file_get_contents($xmlPath)); $config->registerXPathNamespace('a', 'http://www.appserver.io/appserver'); // create us an aspect // name of the aspect will be the application name $aspect = new Aspect(); $aspect->setName($xmlPath); // check if we got some pointcuts foreach ($config->xpath('/a:pointcuts/a:pointcut') as $pointcutConfiguration) { // build up the pointcut and add it to the collection $pointcut = new Pointcut(); $pointcut->setAspectName($aspect->getName()); $pointcut->setName((string)$pointcutConfiguration->{'pointcut-name'}); $pointcut->setPointcutExpression( new PointcutExpression((string)$pointcutConfiguration->{'pointcut-pattern'}) ); $aspect->getPointcuts()->add($pointcut); } // check if we got some advices foreach ($config->xpath('/a:pointcuts/a:advice') as $adviceConfiguration) { // build up the advice and add it to the aspect $advice = new Advice(); $advice->setAspectName((string)$adviceConfiguration->{'advice-aspect'}); $advice->setName($advice->getAspectName() . '->' . (string)$adviceConfiguration->{'advice-name'}); $advice->setCodeHook((string)$adviceConfiguration->{'advice-type'}); $pointcutPointcut = $this->generatePointcutPointcut((array) $adviceConfiguration->{'advice-pointcuts'}->{'pointcut-name'}, $aspect); $advice->getPointcuts()->add($pointcutPointcut); // finally add the advice to our aspect (we will also add it without pointcuts of its own) $aspect->getAdvices()->add($advice); } // if the aspect contains pointcuts or advices it can be used if ($aspect->getPointcuts()->count() > 0 || $aspect->getAdvices()->count() > 0) { $this->getAspectRegister()->set($aspect->getName(), $aspect); } } } }
[ "public", "function", "registerAspectXml", "(", "ApplicationInterface", "$", "application", ")", "{", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\ConfigurationService $configurationService */", "$", "configurationService", "=", "$", "application", "->", "newService", "(", "'Ap...
Registers aspects written within source files which we might encounter @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance @return void
[ "Registers", "aspects", "written", "within", "source", "files", "which", "we", "might", "encounter" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/AspectContainer/AspectManager.php#L269-L341
appserver-io/appserver
src/AppserverIo/Appserver/AspectContainer/AspectManager.php
AspectManager.generatePointcutPointcut
protected function generatePointcutPointcut(array $pointcutNames, Aspect $aspect) { // there might be several pointcuts // we have to look them up within the pointcuts we got here and the ones we already have in our register $pointcutFactory = new PointcutFactory(); $referencedPointcuts = array(); $pointcutExpression = array(); foreach ($pointcutNames as $pointcutName) { $pointcutName = (string) $pointcutName; $referenceCount = count($referencedPointcuts); // check if we recently parsed the referenced pointcut if ($pointcut = $aspect->getPointcuts()->get($pointcutName)) { $referencedPointcuts[] = $pointcut; } else { // or did we already know of it? $referencedPointcuts = array_merge($referencedPointcuts, $this->getAspectRegister()->lookupPointcuts($pointcutName)); } // build up the expression string for the PointcutPointcut instance if ($referenceCount < count($referencedPointcuts)) { $pointcutExpression[] = $pointcutName; } } /** @var \AppserverIo\Doppelgaenger\Entities\Pointcuts\PointcutPointcut $pointcutPointcut */ $pointcutPointcut = $pointcutFactory->getInstance( PointcutPointcut::TYPE . '(' . implode(PointcutPointcut::EXPRESSION_CONNECTOR, $pointcutExpression) . ')' ); $pointcutPointcut->setReferencedPointcuts($referencedPointcuts); return $pointcutPointcut; }
php
protected function generatePointcutPointcut(array $pointcutNames, Aspect $aspect) { // there might be several pointcuts // we have to look them up within the pointcuts we got here and the ones we already have in our register $pointcutFactory = new PointcutFactory(); $referencedPointcuts = array(); $pointcutExpression = array(); foreach ($pointcutNames as $pointcutName) { $pointcutName = (string) $pointcutName; $referenceCount = count($referencedPointcuts); // check if we recently parsed the referenced pointcut if ($pointcut = $aspect->getPointcuts()->get($pointcutName)) { $referencedPointcuts[] = $pointcut; } else { // or did we already know of it? $referencedPointcuts = array_merge($referencedPointcuts, $this->getAspectRegister()->lookupPointcuts($pointcutName)); } // build up the expression string for the PointcutPointcut instance if ($referenceCount < count($referencedPointcuts)) { $pointcutExpression[] = $pointcutName; } } /** @var \AppserverIo\Doppelgaenger\Entities\Pointcuts\PointcutPointcut $pointcutPointcut */ $pointcutPointcut = $pointcutFactory->getInstance( PointcutPointcut::TYPE . '(' . implode(PointcutPointcut::EXPRESSION_CONNECTOR, $pointcutExpression) . ')' ); $pointcutPointcut->setReferencedPointcuts($referencedPointcuts); return $pointcutPointcut; }
[ "protected", "function", "generatePointcutPointcut", "(", "array", "$", "pointcutNames", ",", "Aspect", "$", "aspect", ")", "{", "// there might be several pointcuts", "// we have to look them up within the pointcuts we got here and the ones we already have in our register", "$", "po...
Will create a PointcutPointcut instance referencing all concrete pointcuts configured for a certain advice. Needs a list of these pointcuts @param array $pointcutNames List of names of referenced pointcuts @param \AppserverIo\Doppelgaenger\Entities\Definitions\Aspect $aspect The aspect to which the advice belongs @return \AppserverIo\Doppelgaenger\Entities\Pointcuts\PointcutPointcut
[ "Will", "create", "a", "PointcutPointcut", "instance", "referencing", "all", "concrete", "pointcuts", "configured", "for", "a", "certain", "advice", ".", "Needs", "a", "list", "of", "these", "pointcuts" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/AspectContainer/AspectManager.php#L352-L384
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php
LogrotateScanner.main
public function main() { // load the interval we want to scan the directory $interval = $this->getInterval(); // load the configured directory $directory = $this->getDirectory(); // prepare the extensions of the file we want to watch $extensionsToWatch = sprintf('{%s}', implode(',', $this->getExtensionsToWatch())); // log the configured deployment directory $this->getSystemLogger()->info( sprintf('Start scanning directory %s for files to be rotated (interval %d)', $directory, $interval) ); // watch the configured directory while (true) { // clear the filesystem cache clearstatcache(); // iterate over the files to be watched foreach (glob($directory . '/*.' . $extensionsToWatch, GLOB_BRACE) as $fileToRotate) { // log that we're rotate the file $this->getSystemLogger()->debug( sprintf('Query wheter it is necessary to rotate %s', $fileToRotate) ); // handle file rotation $this->handle($fileToRotate); // cleanup files $this->cleanup($fileToRotate); } // sleep a while sleep($interval); } }
php
public function main() { // load the interval we want to scan the directory $interval = $this->getInterval(); // load the configured directory $directory = $this->getDirectory(); // prepare the extensions of the file we want to watch $extensionsToWatch = sprintf('{%s}', implode(',', $this->getExtensionsToWatch())); // log the configured deployment directory $this->getSystemLogger()->info( sprintf('Start scanning directory %s for files to be rotated (interval %d)', $directory, $interval) ); // watch the configured directory while (true) { // clear the filesystem cache clearstatcache(); // iterate over the files to be watched foreach (glob($directory . '/*.' . $extensionsToWatch, GLOB_BRACE) as $fileToRotate) { // log that we're rotate the file $this->getSystemLogger()->debug( sprintf('Query wheter it is necessary to rotate %s', $fileToRotate) ); // handle file rotation $this->handle($fileToRotate); // cleanup files $this->cleanup($fileToRotate); } // sleep a while sleep($interval); } }
[ "public", "function", "main", "(", ")", "{", "// load the interval we want to scan the directory", "$", "interval", "=", "$", "this", "->", "getInterval", "(", ")", ";", "// load the configured directory", "$", "directory", "=", "$", "this", "->", "getDirectory", "(...
Start the logrotate scanner that queries whether the configured log files has to be rotated or not. @return void @see \AppserverIo\Appserver\Core\AbstractThread::main()
[ "Start", "the", "logrotate", "scanner", "that", "queries", "whether", "the", "configured", "log", "files", "has", "to", "be", "rotated", "or", "not", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php#L251-L290
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php
LogrotateScanner.getGlobPattern
protected function getGlobPattern($fileToRotate, $fileExtension = '') { // load the file information $dirname = pathinfo($fileToRotate, PATHINFO_DIRNAME); $filename = pathinfo($fileToRotate, PATHINFO_FILENAME); // create a glob expression to find all log files $glob = str_replace( array(LogrotateScanner::FILENAME_FORMAT_PLACEHOLDER, LogrotateScanner::SIZE_FORMAT_PLACEHOLDER), array($filename, '[0-9]'), $dirname . '/' . $this->getFilenameFormat() ); // append the file extension if available if (empty($fileExtension) === false) { $glob .= '.' . $fileExtension; } // return the glob expression return $glob; }
php
protected function getGlobPattern($fileToRotate, $fileExtension = '') { // load the file information $dirname = pathinfo($fileToRotate, PATHINFO_DIRNAME); $filename = pathinfo($fileToRotate, PATHINFO_FILENAME); // create a glob expression to find all log files $glob = str_replace( array(LogrotateScanner::FILENAME_FORMAT_PLACEHOLDER, LogrotateScanner::SIZE_FORMAT_PLACEHOLDER), array($filename, '[0-9]'), $dirname . '/' . $this->getFilenameFormat() ); // append the file extension if available if (empty($fileExtension) === false) { $glob .= '.' . $fileExtension; } // return the glob expression return $glob; }
[ "protected", "function", "getGlobPattern", "(", "$", "fileToRotate", ",", "$", "fileExtension", "=", "''", ")", "{", "// load the file information", "$", "dirname", "=", "pathinfo", "(", "$", "fileToRotate", ",", "PATHINFO_DIRNAME", ")", ";", "$", "filename", "=...
Will return a glob pattern with which log files belonging to the currently rotated file can be found. @param string $fileToRotate The file to be rotated @param string $fileExtension The file extension @return string
[ "Will", "return", "a", "glob", "pattern", "with", "which", "log", "files", "belonging", "to", "the", "currently", "rotated", "file", "can", "be", "found", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php#L301-L322
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php
LogrotateScanner.handle
protected function handle($fileToRotate) { // next rotation date is tomorrow $today = new \DateTime(); // do we have to rotate based on the current date or the file's size? if ($this->getNextRotationDate() < $today->getTimestamp()) { $this->rotate($fileToRotate); } elseif (file_exists($fileToRotate) && filesize($fileToRotate) >= $this->getMaxSize()) { $this->rotate($fileToRotate); } }
php
protected function handle($fileToRotate) { // next rotation date is tomorrow $today = new \DateTime(); // do we have to rotate based on the current date or the file's size? if ($this->getNextRotationDate() < $today->getTimestamp()) { $this->rotate($fileToRotate); } elseif (file_exists($fileToRotate) && filesize($fileToRotate) >= $this->getMaxSize()) { $this->rotate($fileToRotate); } }
[ "protected", "function", "handle", "(", "$", "fileToRotate", ")", "{", "// next rotation date is tomorrow", "$", "today", "=", "new", "\\", "DateTime", "(", ")", ";", "// do we have to rotate based on the current date or the file's size?", "if", "(", "$", "this", "->", ...
Handles the log message. @param string $fileToRotate The file to be rotated @return void
[ "Handles", "the", "log", "message", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php#L331-L343
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php
LogrotateScanner.rotate
protected function rotate($fileToRotate) { // clear the filesystem cache clearstatcache(); // query whether the file is NOT available anymore or we dont have access to it if (file_exists($fileToRotate) === false || is_writable($fileToRotate) === false) { return; } // query whether the file has any content, because we don't want to rotate empty files if (filesize($fileToRotate) === 0) { return; } // load the existing log files $logFiles = glob($this->getGlobPattern($fileToRotate, 'gz')); // sorting the files by name to remove the older ones usort( $logFiles, function ($a, $b) { return strcmp($b, $a); } ); // load the information about the found file $dirname = pathinfo($fileToRotate, PATHINFO_DIRNAME); $filename = pathinfo($fileToRotate, PATHINFO_FILENAME); // raise the counter of the rotated files foreach ($logFiles as $fileToRename) { // load the information about the found file $extension = pathinfo($fileToRename, PATHINFO_EXTENSION); $basename = pathinfo($fileToRename, PATHINFO_BASENAME); // prepare the regex to grep the counter with $regex = sprintf('/^%s\.([0-9]{1,})\.%s/', $filename, $extension); // initialize the counter for the regex result $counter = array(); // check the counter if (preg_match($regex, $basename, $counter)) { // load and raise the counter by one $raised = ((integer) end($counter)) + 1; // prepare the new filename $newFilename = sprintf('%s/%s.%d.%s', $dirname, $filename, $raised, $extension); // rename the file rename($fileToRename, $newFilename); } } // rotate the file rename($fileToRotate, $newFilename = sprintf('%s/%s.0', $dirname, $filename)); // compress the log file file_put_contents("compress.zlib://$newFilename.gz", file_get_contents($newFilename)); // delete the old file unlink($newFilename); // next rotation date is tomorrow $tomorrow = new \DateTime('tomorrow'); $this->setNextRotationDate($tomorrow->getTimestamp()); }
php
protected function rotate($fileToRotate) { // clear the filesystem cache clearstatcache(); // query whether the file is NOT available anymore or we dont have access to it if (file_exists($fileToRotate) === false || is_writable($fileToRotate) === false) { return; } // query whether the file has any content, because we don't want to rotate empty files if (filesize($fileToRotate) === 0) { return; } // load the existing log files $logFiles = glob($this->getGlobPattern($fileToRotate, 'gz')); // sorting the files by name to remove the older ones usort( $logFiles, function ($a, $b) { return strcmp($b, $a); } ); // load the information about the found file $dirname = pathinfo($fileToRotate, PATHINFO_DIRNAME); $filename = pathinfo($fileToRotate, PATHINFO_FILENAME); // raise the counter of the rotated files foreach ($logFiles as $fileToRename) { // load the information about the found file $extension = pathinfo($fileToRename, PATHINFO_EXTENSION); $basename = pathinfo($fileToRename, PATHINFO_BASENAME); // prepare the regex to grep the counter with $regex = sprintf('/^%s\.([0-9]{1,})\.%s/', $filename, $extension); // initialize the counter for the regex result $counter = array(); // check the counter if (preg_match($regex, $basename, $counter)) { // load and raise the counter by one $raised = ((integer) end($counter)) + 1; // prepare the new filename $newFilename = sprintf('%s/%s.%d.%s', $dirname, $filename, $raised, $extension); // rename the file rename($fileToRename, $newFilename); } } // rotate the file rename($fileToRotate, $newFilename = sprintf('%s/%s.0', $dirname, $filename)); // compress the log file file_put_contents("compress.zlib://$newFilename.gz", file_get_contents($newFilename)); // delete the old file unlink($newFilename); // next rotation date is tomorrow $tomorrow = new \DateTime('tomorrow'); $this->setNextRotationDate($tomorrow->getTimestamp()); }
[ "protected", "function", "rotate", "(", "$", "fileToRotate", ")", "{", "// clear the filesystem cache", "clearstatcache", "(", ")", ";", "// query whether the file is NOT available anymore or we dont have access to it", "if", "(", "file_exists", "(", "$", "fileToRotate", ")",...
Does the rotation of the log file which includes updating the currently used filename as well as cleaning up the log directory. @param string $fileToRotate The file to be rotated @return void
[ "Does", "the", "rotation", "of", "the", "log", "file", "which", "includes", "updating", "the", "currently", "used", "filename", "as", "well", "as", "cleaning", "up", "the", "log", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php#L353-L422
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php
LogrotateScanner.cleanup
protected function cleanup($fileToRotate) { // load the maximum number of files to keep $maxFiles = $this->getMaxFiles(); // skip GC of old logs if files are unlimited if (0 === $maxFiles) { return; } // load the rotated log files $logFiles = glob($this->getGlobPattern($fileToRotate, 'gz')); // query whether we've the maximum number of files reached if ($maxFiles >= count($logFiles)) { return; } // iterate over the files we want to clean-up foreach (array_slice($logFiles, $maxFiles) as $fileToDelete) { unlink($fileToDelete); } }
php
protected function cleanup($fileToRotate) { // load the maximum number of files to keep $maxFiles = $this->getMaxFiles(); // skip GC of old logs if files are unlimited if (0 === $maxFiles) { return; } // load the rotated log files $logFiles = glob($this->getGlobPattern($fileToRotate, 'gz')); // query whether we've the maximum number of files reached if ($maxFiles >= count($logFiles)) { return; } // iterate over the files we want to clean-up foreach (array_slice($logFiles, $maxFiles) as $fileToDelete) { unlink($fileToDelete); } }
[ "protected", "function", "cleanup", "(", "$", "fileToRotate", ")", "{", "// load the maximum number of files to keep", "$", "maxFiles", "=", "$", "this", "->", "getMaxFiles", "(", ")", ";", "// skip GC of old logs if files are unlimited", "if", "(", "0", "===", "$", ...
Will cleanup log files based on the value set for their maximal number @param string $fileToRotate The file to be rotated @return void
[ "Will", "cleanup", "log", "files", "based", "on", "the", "value", "set", "for", "their", "maximal", "number" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/LogrotateScanner.php#L431-L454