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/Utils/ErrorUtil.php
ErrorUtil.handleErrors
public function handleErrors( RequestHandler $requestHandler, HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse ) { // return immediately if we don't have any errors if (sizeof($errors = $requestHandler->getErrors()) === 0) { return; } // iterate over the errors to process each of them foreach ($errors as $error) { // prepare the error message $message = $this->prepareMessage($error); // query whether or not we have to log the error if (Boolean::valueOf(new String(ini_get('log_errors')))->booleanValue()) { LoggerUtils::log(ErrorUtil::mapLogLevel($error), $message); } // we prepend the errors to the body stream if display_errors is on if (Boolean::valueOf(new String(ini_get('display_errors')))->booleanValue()) { $bodyContent = $servletResponse->getBodyContent(); $servletResponse->resetBodyStream(); $servletResponse->appendBodyStream(sprintf('%s<br/>%s', $message, $bodyContent)); } // query whether or not, the error has an status code if ($statusCode = $error->getStatusCode()) { $servletResponse->setStatusCode($statusCode); } } // query whether or not we've a client or an server error if ($servletResponse->getStatusCode() > 399) { try { // create a local copy of the application $application = $servletRequest->getContext(); // inject the application and servlet response $servletRequest->injectResponse($servletResponse); $servletRequest->injectContext($application); // load the servlet context instance $servletManager = $application->search(ServletContextInterface::IDENTIFIER); // initialize the request URI for the error page to be rendered $requestUri = null; // iterate over the configured error pages to find a matching one foreach ($servletManager->getErrorPages() as $errorCodePattern => $errorPage) { // query whether or not we found an error page configured for the actual status code if (fnmatch($errorCodePattern, $servletResponse->getStatusCode())) { $requestUri = $errorPage; break; } } // query whether or not we've an found a configured error page if ($requestUri == null) { throw new ServletException( sprintf( 'Please configure an error page for status code %s', $servletResponse->getStatusCode() ) ); } // initialize the request URI $servletRequest->setRequestUri($requestUri); // prepare the request with the new data $servletRequest->prepare(); // reset the body stream to remove content, that has already been appended $servletResponse->resetBodyStream(); // we add the filtered errors (status code > 399) to the servlet request $servletRequest->setAttribute( RequestHandlerKeys::ERROR_MESSAGES, array_filter($errors, function ($message) { return $message->getStatusCode() > 399; }) ); // load the servlet path and session-ID $servletPath = $servletRequest->getServletPath(); $sessionId = $servletRequest->getProposedSessionId(); // load and process the servlet $servlet = $servletManager->lookup($servletPath, $sessionId); $servlet->service($servletRequest, $servletResponse); } catch (\Exception $e) { // finally log the exception $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); // append the exception message to the body stream $servletResponse->appendBodyStream($e->__toString()); } } }
php
public function handleErrors( RequestHandler $requestHandler, HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse ) { // return immediately if we don't have any errors if (sizeof($errors = $requestHandler->getErrors()) === 0) { return; } // iterate over the errors to process each of them foreach ($errors as $error) { // prepare the error message $message = $this->prepareMessage($error); // query whether or not we have to log the error if (Boolean::valueOf(new String(ini_get('log_errors')))->booleanValue()) { LoggerUtils::log(ErrorUtil::mapLogLevel($error), $message); } // we prepend the errors to the body stream if display_errors is on if (Boolean::valueOf(new String(ini_get('display_errors')))->booleanValue()) { $bodyContent = $servletResponse->getBodyContent(); $servletResponse->resetBodyStream(); $servletResponse->appendBodyStream(sprintf('%s<br/>%s', $message, $bodyContent)); } // query whether or not, the error has an status code if ($statusCode = $error->getStatusCode()) { $servletResponse->setStatusCode($statusCode); } } // query whether or not we've a client or an server error if ($servletResponse->getStatusCode() > 399) { try { // create a local copy of the application $application = $servletRequest->getContext(); // inject the application and servlet response $servletRequest->injectResponse($servletResponse); $servletRequest->injectContext($application); // load the servlet context instance $servletManager = $application->search(ServletContextInterface::IDENTIFIER); // initialize the request URI for the error page to be rendered $requestUri = null; // iterate over the configured error pages to find a matching one foreach ($servletManager->getErrorPages() as $errorCodePattern => $errorPage) { // query whether or not we found an error page configured for the actual status code if (fnmatch($errorCodePattern, $servletResponse->getStatusCode())) { $requestUri = $errorPage; break; } } // query whether or not we've an found a configured error page if ($requestUri == null) { throw new ServletException( sprintf( 'Please configure an error page for status code %s', $servletResponse->getStatusCode() ) ); } // initialize the request URI $servletRequest->setRequestUri($requestUri); // prepare the request with the new data $servletRequest->prepare(); // reset the body stream to remove content, that has already been appended $servletResponse->resetBodyStream(); // we add the filtered errors (status code > 399) to the servlet request $servletRequest->setAttribute( RequestHandlerKeys::ERROR_MESSAGES, array_filter($errors, function ($message) { return $message->getStatusCode() > 399; }) ); // load the servlet path and session-ID $servletPath = $servletRequest->getServletPath(); $sessionId = $servletRequest->getProposedSessionId(); // load and process the servlet $servlet = $servletManager->lookup($servletPath, $sessionId); $servlet->service($servletRequest, $servletResponse); } catch (\Exception $e) { // finally log the exception $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); // append the exception message to the body stream $servletResponse->appendBodyStream($e->__toString()); } } }
[ "public", "function", "handleErrors", "(", "RequestHandler", "$", "requestHandler", ",", "HttpServletRequestInterface", "$", "servletRequest", ",", "HttpServletResponseInterface", "$", "servletResponse", ")", "{", "// return immediately if we don't have any errors", "if", "(", ...
This method finally handles all PHP and user errors as well as the exceptions that have been thrown through the servlet processing. @param \AppserverIo\Appserver\ServletEngine\RequestHandler $requestHandler The request handler instance @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The actual request instance @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The actual request instance @return void
[ "This", "method", "finally", "handles", "all", "PHP", "and", "user", "errors", "as", "well", "as", "the", "exceptions", "that", "have", "been", "thrown", "through", "the", "servlet", "processing", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Utils/ErrorUtil.php#L84-L180
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/MessageQueue.php
MessageQueue.attach
public function attach(MessageInterface $message) { // force handling the timer tasks now $this->synchronized(function (MessageQueue $self, MessageInterface $m) { // create a unique identifier for the priority $priority = $this->uniqueWorkerName($m->getPriority()); // load the worker for the message's priority if (isset($self->workers[$priority])) { // attach the message $self->messages[$m->getMessageId()] = $m; // store the job-ID and the PK of the message => necessary to load the message later $jobWrapper = new \stdClass(); $jobWrapper->jobId = $m->getMessageId(); $jobWrapper->messageId = $m->getMessageId(); // attach the job to the worker $self->workers[$priority]->attach($jobWrapper); } }, $this, $message); }
php
public function attach(MessageInterface $message) { // force handling the timer tasks now $this->synchronized(function (MessageQueue $self, MessageInterface $m) { // create a unique identifier for the priority $priority = $this->uniqueWorkerName($m->getPriority()); // load the worker for the message's priority if (isset($self->workers[$priority])) { // attach the message $self->messages[$m->getMessageId()] = $m; // store the job-ID and the PK of the message => necessary to load the message later $jobWrapper = new \stdClass(); $jobWrapper->jobId = $m->getMessageId(); $jobWrapper->messageId = $m->getMessageId(); // attach the job to the worker $self->workers[$priority]->attach($jobWrapper); } }, $this, $message); }
[ "public", "function", "attach", "(", "MessageInterface", "$", "message", ")", "{", "// force handling the timer tasks now", "$", "this", "->", "synchronized", "(", "function", "(", "MessageQueue", "$", "self", ",", "MessageInterface", "$", "m", ")", "{", "// creat...
Attach a new message to the queue. @param \AppserverIo\Psr\Pms\MessageInterface $message The messsage to be attached to the queue @return void
[ "Attach", "a", "new", "message", "to", "the", "queue", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/MessageQueue/MessageQueue.php#L190-L213
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/MessageQueue.php
MessageQueue.bootstrap
public function bootstrap() { // 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(); // create a reference to the workers/messages $workers = $this->workers; $messages = $this->messages; $managerSettings = $this->managerSettings; // try to load the profile logger if ($this->profileLogger = $application->getInitialContext()->getLogger(LoggerUtils::PROFILE)) { $this->profileLogger->appendThreadContext(sprintf('message-queue-%s', $this->getName())); } // prepare the storages $jobsToExceute = array(); // initialize the counter for the storages $counter = 0; // create a separate queue for each priority foreach (PriorityKeys::getAll() as $priorityKey) { // create the containers for the worker $jobsToExceute[$counter] = new GenericStackable(); // initialize and start the queue worker $queueWorker = new QueueWorker(); $queueWorker->injectMessages($messages); $queueWorker->injectApplication($application); $queueWorker->injectPriorityKey($priorityKey); $queueWorker->injectManagerSettings($managerSettings); // attach the storages $queueWorker->injectJobsToExecute($jobsToExceute[$counter]); // start the worker instance $queueWorker->start(); // add the queue instance to the module $workers[$this->uniqueWorkerName($priorityKey)] = $queueWorker; // raise the counter $counter++; } }
php
public function bootstrap() { // 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(); // create a reference to the workers/messages $workers = $this->workers; $messages = $this->messages; $managerSettings = $this->managerSettings; // try to load the profile logger if ($this->profileLogger = $application->getInitialContext()->getLogger(LoggerUtils::PROFILE)) { $this->profileLogger->appendThreadContext(sprintf('message-queue-%s', $this->getName())); } // prepare the storages $jobsToExceute = array(); // initialize the counter for the storages $counter = 0; // create a separate queue for each priority foreach (PriorityKeys::getAll() as $priorityKey) { // create the containers for the worker $jobsToExceute[$counter] = new GenericStackable(); // initialize and start the queue worker $queueWorker = new QueueWorker(); $queueWorker->injectMessages($messages); $queueWorker->injectApplication($application); $queueWorker->injectPriorityKey($priorityKey); $queueWorker->injectManagerSettings($managerSettings); // attach the storages $queueWorker->injectJobsToExecute($jobsToExceute[$counter]); // start the worker instance $queueWorker->start(); // add the queue instance to the module $workers[$this->uniqueWorkerName($priorityKey)] = $queueWorker; // raise the counter $counter++; } }
[ "public", "function", "bootstrap", "(", ")", "{", "// register the default autoloader", "require", "SERVER_AUTOLOADER", ";", "// synchronize the application instance and register the class loaders", "$", "application", "=", "$", "this", "->", "application", ";", "$", "applica...
This method will be invoked before the while() loop starts and can be used to implement some bootstrap functionality. @return void
[ "This", "method", "will", "be", "invoked", "before", "the", "while", "()", "loop", "starts", "and", "can", "be", "used", "to", "implement", "some", "bootstrap", "functionality", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/MessageQueue/MessageQueue.php#L247-L300
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/MessageQueue.php
MessageQueue.cleanUp
public function cleanUp() { // create a separate queue for each priority foreach (PriorityKeys::getAll() as $priorityKey) { $this->workers[$this->uniqueWorkerName($priorityKey)]->stop(); } }
php
public function cleanUp() { // create a separate queue for each priority foreach (PriorityKeys::getAll() as $priorityKey) { $this->workers[$this->uniqueWorkerName($priorityKey)]->stop(); } }
[ "public", "function", "cleanUp", "(", ")", "{", "// create a separate queue for each priority", "foreach", "(", "PriorityKeys", "::", "getAll", "(", ")", "as", "$", "priorityKey", ")", "{", "$", "this", "->", "workers", "[", "$", "this", "->", "uniqueWorkerName"...
This method will be invoked, after the while() loop has been finished and can be used to implement clean up functionality. @return void
[ "This", "method", "will", "be", "invoked", "after", "the", "while", "()", "loop", "has", "been", "finished", "and", "can", "be", "used", "to", "implement", "clean", "up", "functionality", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/MessageQueue/MessageQueue.php#L308-L314
appserver-io/appserver
src/AppserverIo/Appserver/Core/ComposerClassLoader.php
ComposerClassLoader.register
public function register($throw = true, $prepend = false) { // register the class loader instance parent::register($prepend); // require the files registered with composer (e. g. Swift Mailer) foreach ($this->directories as $directory) { if (file_exists($directory . '/composer/autoload_files.php')) { $includeFiles = require $directory . '/composer/autoload_files.php'; foreach ($includeFiles as $file) { require_once $file; } } } }
php
public function register($throw = true, $prepend = false) { // register the class loader instance parent::register($prepend); // require the files registered with composer (e. g. Swift Mailer) foreach ($this->directories as $directory) { if (file_exists($directory . '/composer/autoload_files.php')) { $includeFiles = require $directory . '/composer/autoload_files.php'; foreach ($includeFiles as $file) { require_once $file; } } } }
[ "public", "function", "register", "(", "$", "throw", "=", "true", ",", "$", "prepend", "=", "false", ")", "{", "// register the class loader instance", "parent", "::", "register", "(", "$", "prepend", ")", ";", "// require the files registered with composer (e. g. Swi...
Installs this class loader on the SPL autoload stack. @param bool $throw If register should throw an exception or not @param bool $prepend If register should prepend @return void
[ "Installs", "this", "class", "loader", "on", "the", "SPL", "autoload", "stack", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/ComposerClassLoader.php#L70-L85
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/AuthConstraintNode.php
AuthConstraintNode.getRoleNamesAsArray
public function getRoleNamesAsArray() { // initialize the array for the role names $roleNames = array(); // prepare the role names /** @var AppserverIo\Appserver\Core\Api\Node\RoleNameNode $roleName */ foreach ($this->getRoleNames() as $roleName) { $roleNames[] = $roleName->__toString(); } // return the array with the role names return $roleNames; }
php
public function getRoleNamesAsArray() { // initialize the array for the role names $roleNames = array(); // prepare the role names /** @var AppserverIo\Appserver\Core\Api\Node\RoleNameNode $roleName */ foreach ($this->getRoleNames() as $roleName) { $roleNames[] = $roleName->__toString(); } // return the array with the role names return $roleNames; }
[ "public", "function", "getRoleNamesAsArray", "(", ")", "{", "// initialize the array for the role names", "$", "roleNames", "=", "array", "(", ")", ";", "// prepare the role names", "/** @var AppserverIo\\Appserver\\Core\\Api\\Node\\RoleNameNode $roleName */", "foreach", "(", "$"...
Return's the role names as array. @return array The role names as array
[ "Return", "s", "the", "role", "names", "as", "array", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/AuthConstraintNode.php#L94-L108
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/GarbageCollectors/StartupBeanTaskGarbageCollector.php
StartupBeanTaskGarbageCollector.bootstrap
public function bootstrap() { // setup autoloader require SERVER_AUTOLOADER; // enable garbage collection gc_enable(); // synchronize the application instance and register the class loaders $application = $this->getApplication(); $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // try to load the profile logger if ($this->profileLogger = $this->getApplication()->getInitialContext()->getLogger(LoggerUtils::PROFILE)) { $this->profileLogger->appendThreadContext('startup-bean-task-garbage-collector'); } }
php
public function bootstrap() { // setup autoloader require SERVER_AUTOLOADER; // enable garbage collection gc_enable(); // synchronize the application instance and register the class loaders $application = $this->getApplication(); $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // try to load the profile logger if ($this->profileLogger = $this->getApplication()->getInitialContext()->getLogger(LoggerUtils::PROFILE)) { $this->profileLogger->appendThreadContext('startup-bean-task-garbage-collector'); } }
[ "public", "function", "bootstrap", "(", ")", "{", "// setup autoloader", "require", "SERVER_AUTOLOADER", ";", "// enable garbage collection", "gc_enable", "(", ")", ";", "// synchronize the application instance and register the class loaders", "$", "application", "=", "$", "t...
This method will be invoked before the while() loop starts and can be used to implement some bootstrap functionality. @return void
[ "This", "method", "will", "be", "invoked", "before", "the", "while", "()", "loop", "starts", "and", "can", "be", "used", "to", "implement", "some", "bootstrap", "functionality", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/GarbageCollectors/StartupBeanTaskGarbageCollector.php#L69-L89
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/GarbageCollectors/StartupBeanTaskGarbageCollector.php
StartupBeanTaskGarbageCollector.collectGarbage
public function collectGarbage() { // we need the bean manager that handles all the beans /** @var \AppserverIo\Psr\EnterpriseBeans\BeanContextInterface $beanManager */ $beanManager = $this->getApplication()->search(BeanContextInterface::IDENTIFIER); // load the map with the startup bean tasks /** @var \AppserverIo\Storage\GenericStackable $statefulSessionBeans */ $startupBeanTasks = $beanManager->getStartupBeanTasks(); // write a log message with size of startup bean tasks to be garbage collected $this->log(LogLevel::DEBUG, sprintf('Found "%d" startup been tasks to be garbage collected', sizeof($startupBeanTasks))); // iterate over the applications sessions with stateful session beans /** @var \Thread $startupBeanTask */ foreach ($startupBeanTasks as $identifier => $startupBeanTask) { // check the lifetime of the stateful session beans if ($startupBeanTask->isRunning()) { // write a log message $this->log(LogLevel::DEBUG, sprintf('Startup bean task "%s" is still running', $identifier)); } else { // remove the startup been task if it has been finished unset($startupBeanTasks[$identifier]); // write a log message $this->log(LogLevel::DEBUG, sprintf('Successfully removed startup bean task "%s"', $identifier)); // reduce CPU load usleep(1000); } } // profile the size of the sessions /** @var \Psr\Log\LoggerInterface $this->profileLogger */ if ($this->profileLogger) { $this->profileLogger->debug( sprintf('Processed startup been task garbage collector, handling "%d" startup bean tasks', sizeof($startupBeanTasks)) ); } }
php
public function collectGarbage() { // we need the bean manager that handles all the beans /** @var \AppserverIo\Psr\EnterpriseBeans\BeanContextInterface $beanManager */ $beanManager = $this->getApplication()->search(BeanContextInterface::IDENTIFIER); // load the map with the startup bean tasks /** @var \AppserverIo\Storage\GenericStackable $statefulSessionBeans */ $startupBeanTasks = $beanManager->getStartupBeanTasks(); // write a log message with size of startup bean tasks to be garbage collected $this->log(LogLevel::DEBUG, sprintf('Found "%d" startup been tasks to be garbage collected', sizeof($startupBeanTasks))); // iterate over the applications sessions with stateful session beans /** @var \Thread $startupBeanTask */ foreach ($startupBeanTasks as $identifier => $startupBeanTask) { // check the lifetime of the stateful session beans if ($startupBeanTask->isRunning()) { // write a log message $this->log(LogLevel::DEBUG, sprintf('Startup bean task "%s" is still running', $identifier)); } else { // remove the startup been task if it has been finished unset($startupBeanTasks[$identifier]); // write a log message $this->log(LogLevel::DEBUG, sprintf('Successfully removed startup bean task "%s"', $identifier)); // reduce CPU load usleep(1000); } } // profile the size of the sessions /** @var \Psr\Log\LoggerInterface $this->profileLogger */ if ($this->profileLogger) { $this->profileLogger->debug( sprintf('Processed startup been task garbage collector, handling "%d" startup bean tasks', sizeof($startupBeanTasks)) ); } }
[ "public", "function", "collectGarbage", "(", ")", "{", "// we need the bean manager that handles all the beans", "/** @var \\AppserverIo\\Psr\\EnterpriseBeans\\BeanContextInterface $beanManager */", "$", "beanManager", "=", "$", "this", "->", "getApplication", "(", ")", "->", "se...
Collects the SFSBs that has been timed out @return void
[ "Collects", "the", "SFSBs", "that", "has", "been", "timed", "out" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/GarbageCollectors/StartupBeanTaskGarbageCollector.php#L113-L151
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/ConnectionHandlersNodeTrait.php
ConnectionHandlersNodeTrait.getConnectionHandlersAsArray
public function getConnectionHandlersAsArray() { // initialize the array for the connection handlers $connectionHandlers = array(); // iterate over the connection handler nodes and sort them into an array /** @var \AppserverIo\Appserver\Core\Api\Node\ConnectionHandlerNode $connectionHandler */ foreach ($this->getConnectionHandlers() as $connectionHandler) { $connectionHandlers[$connectionHandler->getUuid()] = $connectionHandler->getType(); } // return the array return $connectionHandlers; }
php
public function getConnectionHandlersAsArray() { // initialize the array for the connection handlers $connectionHandlers = array(); // iterate over the connection handler nodes and sort them into an array /** @var \AppserverIo\Appserver\Core\Api\Node\ConnectionHandlerNode $connectionHandler */ foreach ($this->getConnectionHandlers() as $connectionHandler) { $connectionHandlers[$connectionHandler->getUuid()] = $connectionHandler->getType(); } // return the array return $connectionHandlers; }
[ "public", "function", "getConnectionHandlersAsArray", "(", ")", "{", "// initialize the array for the connection handlers", "$", "connectionHandlers", "=", "array", "(", ")", ";", "// iterate over the connection handler nodes and sort them into an array", "/** @var \\AppserverIo\\Appse...
Returns the connection handlers as an associative array @return array The array with the sorted connection handlers
[ "Returns", "the", "connection", "handlers", "as", "an", "associative", "array" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/ConnectionHandlersNodeTrait.php#L60-L74
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/ContainerNode.php
ContainerNode.getServersAsArray
public function getServersAsArray() { // initialize the array for the servers $servers = array(); // iterate over all found servers and assemble the array /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $server */ foreach ($this->getServers() as $server) { $servers[$server->getName()] = $server; } // return the array with the servers return $servers; }
php
public function getServersAsArray() { // initialize the array for the servers $servers = array(); // iterate over all found servers and assemble the array /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $server */ foreach ($this->getServers() as $server) { $servers[$server->getName()] = $server; } // return the array with the servers return $servers; }
[ "public", "function", "getServersAsArray", "(", ")", "{", "// initialize the array for the servers", "$", "servers", "=", "array", "(", ")", ";", "// iterate over all found servers and assemble the array", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\ServerNodeInterface $server...
Returns the servers as array with the server name as key. @return array The array with the servers
[ "Returns", "the", "servers", "as", "array", "with", "the", "server", "name", "as", "key", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/ContainerNode.php#L231-L245
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/ContainerNode.php
ContainerNode.getServer
public function getServer($name) { // try to match one of the server names with the passed name /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $server */ foreach ($this->getServers() as $server) { if ($name === $server->getName()) { return $server; } } }
php
public function getServer($name) { // try to match one of the server names with the passed name /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $server */ foreach ($this->getServers() as $server) { if ($name === $server->getName()) { return $server; } } }
[ "public", "function", "getServer", "(", "$", "name", ")", "{", "// try to match one of the server names with the passed name", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\ServerNodeInterface $server */", "foreach", "(", "$", "this", "->", "getServers", "(", ")", "as", ...
Returns the server with the passed name. @param string $name The name of the server to return @return \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface The server node matching the passed name
[ "Returns", "the", "server", "with", "the", "passed", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/ContainerNode.php#L254-L264
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/ContainerNode.php
ContainerNode.merge
public function merge(ContainerConfigurationInterface $containerNode) { // iterate over this container server nodes /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $serverNode */ foreach ($this->getServers() as $serverNode) { // try to match with the server names of the passed container /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $serverNodeToMerge */ foreach ($containerNode->getServers() as $serverNodeToMerge) { if (fnmatch($serverNodeToMerge->getName(), $serverNode->getName())) { $serverNode->merge($serverNodeToMerge); } else { $this->attachServer($serverNode); } } } }
php
public function merge(ContainerConfigurationInterface $containerNode) { // iterate over this container server nodes /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $serverNode */ foreach ($this->getServers() as $serverNode) { // try to match with the server names of the passed container /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $serverNodeToMerge */ foreach ($containerNode->getServers() as $serverNodeToMerge) { if (fnmatch($serverNodeToMerge->getName(), $serverNode->getName())) { $serverNode->merge($serverNodeToMerge); } else { $this->attachServer($serverNode); } } } }
[ "public", "function", "merge", "(", "ContainerConfigurationInterface", "$", "containerNode", ")", "{", "// iterate over this container server nodes", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\ServerNodeInterface $serverNode */", "foreach", "(", "$", "this", "->", "getServe...
This method merges the passed container node into this one. @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container node to merge @return void
[ "This", "method", "merges", "the", "passed", "container", "node", "into", "this", "one", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/ContainerNode.php#L295-L310
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/LocationsNodeTrait.php
LocationsNodeTrait.getLocation
public function getLocation($condition) { // iterate over all locations /** @var \AppserverIo\Appserver\Core\Api\Node\LocationNode $location */ foreach ($this->getLocations() as $location) { // if we found one with a matching condition we will return it if ($location->getCondition() === $condition) { return $location; } } // Still here? Seems we did not find anything return false; }
php
public function getLocation($condition) { // iterate over all locations /** @var \AppserverIo\Appserver\Core\Api\Node\LocationNode $location */ foreach ($this->getLocations() as $location) { // if we found one with a matching condition we will return it if ($location->getCondition() === $condition) { return $location; } } // Still here? Seems we did not find anything return false; }
[ "public", "function", "getLocation", "(", "$", "condition", ")", "{", "// iterate over all locations", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\LocationNode $location */", "foreach", "(", "$", "this", "->", "getLocations", "(", ")", "as", "$", "location", ")", ...
Will return the location node with the specified condition and if nothing could be found we will return false. @param string $condition The condition of the location in question @return \AppserverIo\Appserver\Core\Api\Node\LocationNode|boolean The requested location node
[ "Will", "return", "the", "location", "node", "with", "the", "specified", "condition", "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/LocationsNodeTrait.php#L63-L76
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/LocationsNodeTrait.php
LocationsNodeTrait.getLocationsAsArray
public function getLocationsAsArray() { // iterate over the location nodes and sort them into an array $locations = array(); /** @var \AppserverIo\Appserver\Core\Api\Node\LocationNode $locationNode */ foreach ($this->getLocations() as $locationNode) { // restructure to an array $locations[$locationNode->getCondition()] = array( 'condition' => $locationNode->getCondition(), 'params' => $locationNode->getParamsAsArray(), 'handlers' => $locationNode->getFileHandlersAsArray(), 'headers' => $locationNode->getHeadersAsArray() ); } // return what we got return $locations; }
php
public function getLocationsAsArray() { // iterate over the location nodes and sort them into an array $locations = array(); /** @var \AppserverIo\Appserver\Core\Api\Node\LocationNode $locationNode */ foreach ($this->getLocations() as $locationNode) { // restructure to an array $locations[$locationNode->getCondition()] = array( 'condition' => $locationNode->getCondition(), 'params' => $locationNode->getParamsAsArray(), 'handlers' => $locationNode->getFileHandlersAsArray(), 'headers' => $locationNode->getHeadersAsArray() ); } // return what we got return $locations; }
[ "public", "function", "getLocationsAsArray", "(", ")", "{", "// iterate over the location nodes and sort them into an array", "$", "locations", "=", "array", "(", ")", ";", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\LocationNode $locationNode */", "foreach", "(", "$", "...
Returns the locations as an associative array. @return array The array with the sorted locations
[ "Returns", "the", "locations", "as", "an", "associative", "array", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/LocationsNodeTrait.php#L83-L100
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/DatabasePDOLoginModule.php
DatabasePDOLoginModule.initialize
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // call the parent method parent::initialize($subject, $callbackHandler, $sharedState, $params); // load the parameters from the map $this->lookupName = new String($params->get(ParamKeys::LOOKUP_NAME)); $this->rolesQuery = new String($params->get(ParamKeys::ROLES_QUERY)); $this->principalsQuery = new String($params->get(ParamKeys::PRINCIPALS_QUERY)); }
php
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // call the parent method parent::initialize($subject, $callbackHandler, $sharedState, $params); // load the parameters from the map $this->lookupName = new String($params->get(ParamKeys::LOOKUP_NAME)); $this->rolesQuery = new String($params->get(ParamKeys::ROLES_QUERY)); $this->principalsQuery = new String($params->get(ParamKeys::PRINCIPALS_QUERY)); }
[ "public", "function", "initialize", "(", "Subject", "$", "subject", ",", "CallbackHandlerInterface", "$", "callbackHandler", ",", "MapInterface", "$", "sharedState", ",", "MapInterface", "$", "params", ")", "{", "// call the parent method", "parent", "::", "initialize...
Initialize the login module. This stores the subject, callbackHandler and sharedState and options for the login session. Subclasses should override if they need to process their own options. A call to parent::initialize() must be made in the case of an override. The following parameters can by default be passed from the configuration. lookupName: The datasource name used to lookup in the naming directory rolesQuery: The database query used to load the user's roles principalsQuery: The database query used to load the user @param \AppserverIo\Psr\Security\Auth\Subject $subject The Subject to update after a successful login @param \AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface $callbackHandler The callback handler that will be used to obtain the user identity and credentials @param \AppserverIo\Collections\MapInterface $sharedState A map shared between all configured login module instances @param \AppserverIo\Collections\MapInterface $params The parameters passed to the login module @return void
[ "Initialize", "the", "login", "module", ".", "This", "stores", "the", "subject", "callbackHandler", "and", "sharedState", "and", "options", "for", "the", "login", "session", ".", "Subclasses", "should", "override", "if", "they", "need", "to", "process", "their",...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/DatabasePDOLoginModule.php#L86-L96
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/DatabasePDOLoginModule.php
DatabasePDOLoginModule.getUsersPassword
protected function getUsersPassword() { // load the application context $application = RequestHandler::getApplicationContext(); /** @var \AppserverIo\Appserver\Core\Api\Node\DatabaseNode $databaseNode */ $databaseNode = $application->getNamingDirectory()->search($this->lookupName)->getDatabase(); // prepare the connection parameters and create the DBAL connection $connection = DriverManager::getConnection(ConnectionUtil::get($application)->fromDatabaseNode($databaseNode)); // try to load the principal's credential from the database $statement = $connection->prepare($this->principalsQuery); $statement->bindParam(1, $this->getUsername()); $statement->execute(); // close the PDO connection if ($connection != null) { try { $connection->close(); } catch (\Exception $e) { $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error($e->__toString()); } } // query whether or not we've a password found or not if ($row = $statement->fetch(\PDO::FETCH_NUM)) { return new String($row[0]); } else { throw new LoginException('No matching username found in principals'); } }
php
protected function getUsersPassword() { // load the application context $application = RequestHandler::getApplicationContext(); /** @var \AppserverIo\Appserver\Core\Api\Node\DatabaseNode $databaseNode */ $databaseNode = $application->getNamingDirectory()->search($this->lookupName)->getDatabase(); // prepare the connection parameters and create the DBAL connection $connection = DriverManager::getConnection(ConnectionUtil::get($application)->fromDatabaseNode($databaseNode)); // try to load the principal's credential from the database $statement = $connection->prepare($this->principalsQuery); $statement->bindParam(1, $this->getUsername()); $statement->execute(); // close the PDO connection if ($connection != null) { try { $connection->close(); } catch (\Exception $e) { $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error($e->__toString()); } } // query whether or not we've a password found or not if ($row = $statement->fetch(\PDO::FETCH_NUM)) { return new String($row[0]); } else { throw new LoginException('No matching username found in principals'); } }
[ "protected", "function", "getUsersPassword", "(", ")", "{", "// load the application context", "$", "application", "=", "RequestHandler", "::", "getApplicationContext", "(", ")", ";", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\DatabaseNode $databaseNode */", "$", "datab...
Returns the password for the user from the sharedMap data. @return \AppserverIo\Lang\String The user's password @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if password can't be loaded
[ "Returns", "the", "password", "for", "the", "user", "from", "the", "sharedMap", "data", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/DatabasePDOLoginModule.php#L104-L139
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/DatabasePDOLoginModule.php
DatabasePDOLoginModule.getRoleSets
protected function getRoleSets() { return Util::getRoleSets($this->getUsername(), new String($this->lookupName), new String($this->rolesQuery), $this); }
php
protected function getRoleSets() { return Util::getRoleSets($this->getUsername(), new String($this->lookupName), new String($this->rolesQuery), $this); }
[ "protected", "function", "getRoleSets", "(", ")", "{", "return", "Util", "::", "getRoleSets", "(", "$", "this", "->", "getUsername", "(", ")", ",", "new", "String", "(", "$", "this", "->", "lookupName", ")", ",", "new", "String", "(", "$", "this", "->"...
Execute the rolesQuery against the lookupName to obtain the roles for the authenticated user. @return array Array containing the sets of roles @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if password can't be loaded
[ "Execute", "the", "rolesQuery", "against", "the", "lookupName", "to", "obtain", "the", "roles", "for", "the", "authenticated", "user", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/DatabasePDOLoginModule.php#L147-L150
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Doctrine/DoctrineEntityManagerProxy.php
DoctrineEntityManagerProxy.find
public function find($entityName, $id, $lockMode = null, $lockVersion = null) { return $this->__call('find', array($entityName, $id, $lockMode, $lockVersion)); }
php
public function find($entityName, $id, $lockMode = null, $lockVersion = null) { return $this->__call('find', array($entityName, $id, $lockMode, $lockVersion)); }
[ "public", "function", "find", "(", "$", "entityName", ",", "$", "id", ",", "$", "lockMode", "=", "null", ",", "$", "lockVersion", "=", "null", ")", "{", "return", "$", "this", "->", "__call", "(", "'find'", ",", "array", "(", "$", "entityName", ",", ...
Finds an Entity by its identifier. @param string $entityName The class name of the entity to find. @param mixed $id The identity of the entity to find. @param integer|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants or NULL if no specific lock mode should be used during the search. @param integer|null $lockVersion The version of the entity to find when using optimistic locking. @return object|null The entity instance or NULL if the entity can not be found. @throws \Doctrine\ORM\OptimisticLockException @throws \Doctrine\ORM\ORMInvalidArgumentException @throws \Doctrine\ORM\TransactionRequiredException @throws \Doctrine\ORM\ORMException
[ "Finds", "an", "Entity", "by", "its", "identifier", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Doctrine/DoctrineEntityManagerProxy.php#L383-L386
appserver-io/appserver
src/AppserverIo/Appserver/DependencyInjectionContainer/AbstractDeploymentDescriptorParser.php
AbstractDeploymentDescriptorParser.loadDeploymentDescriptors
protected function loadDeploymentDescriptors() { // load the web application base directory $webappPath = $this->getApplication()->getWebappPath(); // load the deployment service /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $deploymentService */ $deploymentService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); // prepare the array with the deployment descriptor with the fallback deployment descriptor $deploymentDescriptors = array($deploymentService->getConfdDir(sprintf('%s.xml', $descriptorName = $this->getConfiguration()->getDescriptorName()))); // try to locate deployment descriptors in the configured directories foreach ($this->getDirectories() as $directory) { // make sure we've a path, relative to the webapp directory $strippedDirectory = ltrim(str_replace($webappPath, '', $directory), DIRECTORY_SEPARATOR); // add the environment aware deployment descriptor to the array array_push( $deploymentDescriptors, AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, $strippedDirectory . DIRECTORY_SEPARATOR . $descriptorName) ); } // return the loaded deployment descriptors return $deploymentDescriptors; }
php
protected function loadDeploymentDescriptors() { // load the web application base directory $webappPath = $this->getApplication()->getWebappPath(); // load the deployment service /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $deploymentService */ $deploymentService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); // prepare the array with the deployment descriptor with the fallback deployment descriptor $deploymentDescriptors = array($deploymentService->getConfdDir(sprintf('%s.xml', $descriptorName = $this->getConfiguration()->getDescriptorName()))); // try to locate deployment descriptors in the configured directories foreach ($this->getDirectories() as $directory) { // make sure we've a path, relative to the webapp directory $strippedDirectory = ltrim(str_replace($webappPath, '', $directory), DIRECTORY_SEPARATOR); // add the environment aware deployment descriptor to the array array_push( $deploymentDescriptors, AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, $strippedDirectory . DIRECTORY_SEPARATOR . $descriptorName) ); } // return the loaded deployment descriptors return $deploymentDescriptors; }
[ "protected", "function", "loadDeploymentDescriptors", "(", ")", "{", "// load the web application base directory", "$", "webappPath", "=", "$", "this", "->", "getApplication", "(", ")", "->", "getWebappPath", "(", ")", ";", "// load the deployment service", "/** @var \\Ap...
Loads the environment aware deployment descriptors for the given manager. @return string[] The array with the deployment descriptors
[ "Loads", "the", "environment", "aware", "deployment", "descriptors", "for", "the", "given", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/DependencyInjectionContainer/AbstractDeploymentDescriptorParser.php#L42-L70
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/BeanManagerFactory.php
BeanManagerFactory.visit
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the bean locator $beanLocator = new BeanLocator(); // initialize the proxy generator $remoteProxyGenerator = new RemoteProxyGenerator(); $remoteProxyGenerator->injectApplication($application); // initialize the request context $requestContext = array(); // initialize the stackable for the data, the stateful + singleton session beans and the naming directory $data = new StackableStorage(); $instances = new GenericStackable(); $startupBeanTasks = new GenericStackable(); $singletonSessionBeans = new StackableStorage(); $statefulSessionBeans = new StatefulSessionBeanMap(); // initialize the default settings for the stateful session beans $beanManagerSettings = new BeanManagerSettings(); $beanManagerSettings->mergeWithParams($managerConfiguration->getParamsAsArray()); // create an instance of the object factory $objectFactory = new GenericObjectFactory(); $objectFactory->injectInstances($instances); $objectFactory->injectApplication($application); $objectFactory->start(); // add a garbage collector and timer service workers for each application $garbageCollector = new StandardGarbageCollector(); $garbageCollector->injectApplication($application); $garbageCollector->start(); // add a garbage collector for the startup bean tasks $startupBeanTaskGarbageCollector = new StartupBeanTaskGarbageCollector(); $startupBeanTaskGarbageCollector->injectApplication($application); $startupBeanTaskGarbageCollector->start(); // initialize the bean manager $beanManager = new BeanManager(); $beanManager->injectData($data); $beanManager->injectApplication($application); $beanManager->injectResourceLocator($beanLocator); $beanManager->injectObjectFactory($objectFactory); $beanManager->injectRequestContext($requestContext); $beanManager->injectStartupBeanTasks($startupBeanTasks); $beanManager->injectGarbageCollector($garbageCollector); $beanManager->injectManagerSettings($beanManagerSettings); $beanManager->injectRemoteProxyGenerator($remoteProxyGenerator); $beanManager->injectStatefulSessionBeans($statefulSessionBeans); $beanManager->injectManagerConfiguration($managerConfiguration); $beanManager->injectSingletonSessionBeans($singletonSessionBeans); $beanManager->injectStartupBeanTaskGarbageCollector($startupBeanTaskGarbageCollector); // create the naming context and add it the manager $contextFactory = $managerConfiguration->getContextFactory(); $contextFactory::visit($beanManager); // attach the instance $application->addManager($beanManager, $managerConfiguration); }
php
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the bean locator $beanLocator = new BeanLocator(); // initialize the proxy generator $remoteProxyGenerator = new RemoteProxyGenerator(); $remoteProxyGenerator->injectApplication($application); // initialize the request context $requestContext = array(); // initialize the stackable for the data, the stateful + singleton session beans and the naming directory $data = new StackableStorage(); $instances = new GenericStackable(); $startupBeanTasks = new GenericStackable(); $singletonSessionBeans = new StackableStorage(); $statefulSessionBeans = new StatefulSessionBeanMap(); // initialize the default settings for the stateful session beans $beanManagerSettings = new BeanManagerSettings(); $beanManagerSettings->mergeWithParams($managerConfiguration->getParamsAsArray()); // create an instance of the object factory $objectFactory = new GenericObjectFactory(); $objectFactory->injectInstances($instances); $objectFactory->injectApplication($application); $objectFactory->start(); // add a garbage collector and timer service workers for each application $garbageCollector = new StandardGarbageCollector(); $garbageCollector->injectApplication($application); $garbageCollector->start(); // add a garbage collector for the startup bean tasks $startupBeanTaskGarbageCollector = new StartupBeanTaskGarbageCollector(); $startupBeanTaskGarbageCollector->injectApplication($application); $startupBeanTaskGarbageCollector->start(); // initialize the bean manager $beanManager = new BeanManager(); $beanManager->injectData($data); $beanManager->injectApplication($application); $beanManager->injectResourceLocator($beanLocator); $beanManager->injectObjectFactory($objectFactory); $beanManager->injectRequestContext($requestContext); $beanManager->injectStartupBeanTasks($startupBeanTasks); $beanManager->injectGarbageCollector($garbageCollector); $beanManager->injectManagerSettings($beanManagerSettings); $beanManager->injectRemoteProxyGenerator($remoteProxyGenerator); $beanManager->injectStatefulSessionBeans($statefulSessionBeans); $beanManager->injectManagerConfiguration($managerConfiguration); $beanManager->injectSingletonSessionBeans($singletonSessionBeans); $beanManager->injectStartupBeanTaskGarbageCollector($startupBeanTaskGarbageCollector); // create the naming context and add it the manager $contextFactory = $managerConfiguration->getContextFactory(); $contextFactory::visit($beanManager); // attach the instance $application->addManager($beanManager, $managerConfiguration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ManagerNodeInterface", "$", "managerConfiguration", ")", "{", "// initialize the bean locator", "$", "beanLocator", "=", "new", "BeanLocator", "(", ")", ";", "// initialize t...
The main method that creates new instances in a separate context. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration The manager configuration @return void
[ "The", "main", "method", "that", "creates", "new", "instances", "in", "a", "separate", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/BeanManagerFactory.php#L54-L116
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php
LdapLoginmodule.initialize
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // call the parent method parent::initialize($subject, $callbackHandler, $sharedState, $params); // initialize the hash encoding to use if ($params->exists(ParamKeys::URL)) { $this->ldapUrl = $params->get(ParamKeys::URL); } // initialize the port of the LDAP server if ($params->exists(ParamKeys::PORT)) { $this->ldapPort = $params->get(ParamKeys::PORT); } // initialize the DN for th users if ($params->exists(ParamKeys::BASE_DN)) { $this->baseDN = $params->get(ParamKeys::BASE_DN); } // initialize the bind DN if ($params->exists(ParamKeys::BIND_DN)) { $this->bindDN= $params->get(ParamKeys::BIND_DN); } // initialize the credentials for the LDAP bind if ($params->exists(ParamKeys::BIND_CREDENTIAL)) { $this->bindCredential = $params->get(ParamKeys::BIND_CREDENTIAL); } // initialize the filter for the users if ($params->exists(ParamKeys::BASE_FILTER)) { $this->baseFilter = $params->get(ParamKeys::BASE_FILTER); } // initialize the DN for the roles if ($params->exists(ParamKeys::ROLES_DN)) { $this->rolesDN = $params->get(ParamKeys::ROLES_DN); } // initialize the filter for the roles if ($params->exists(ParamKeys::ROLE_FILTER)) { $this->roleFilter = $params->get(ParamKeys::ROLE_FILTER); } // initialize the flag to use START TLS or not if ($params->exists(ParamKeys::START_TLS)) { $this->ldapStartTls = Boolean::valueOf( new String($params->get(ParamKeys::START_TLS)) )->booleanValue(); } // initialize the flag to allow empty passwords or not if ($params->exists(ParamKeys::ALLOW_EMPTY_PASSWORDS)) { $this->allowEmptyPasswords = Boolean::valueOf( new String($params->get(ParamKeys::ALLOW_EMPTY_PASSWORDS)) )->booleanValue(); } // initialialize the hash map for the roles $this->setsMap = new HashMap(); }
php
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // call the parent method parent::initialize($subject, $callbackHandler, $sharedState, $params); // initialize the hash encoding to use if ($params->exists(ParamKeys::URL)) { $this->ldapUrl = $params->get(ParamKeys::URL); } // initialize the port of the LDAP server if ($params->exists(ParamKeys::PORT)) { $this->ldapPort = $params->get(ParamKeys::PORT); } // initialize the DN for th users if ($params->exists(ParamKeys::BASE_DN)) { $this->baseDN = $params->get(ParamKeys::BASE_DN); } // initialize the bind DN if ($params->exists(ParamKeys::BIND_DN)) { $this->bindDN= $params->get(ParamKeys::BIND_DN); } // initialize the credentials for the LDAP bind if ($params->exists(ParamKeys::BIND_CREDENTIAL)) { $this->bindCredential = $params->get(ParamKeys::BIND_CREDENTIAL); } // initialize the filter for the users if ($params->exists(ParamKeys::BASE_FILTER)) { $this->baseFilter = $params->get(ParamKeys::BASE_FILTER); } // initialize the DN for the roles if ($params->exists(ParamKeys::ROLES_DN)) { $this->rolesDN = $params->get(ParamKeys::ROLES_DN); } // initialize the filter for the roles if ($params->exists(ParamKeys::ROLE_FILTER)) { $this->roleFilter = $params->get(ParamKeys::ROLE_FILTER); } // initialize the flag to use START TLS or not if ($params->exists(ParamKeys::START_TLS)) { $this->ldapStartTls = Boolean::valueOf( new String($params->get(ParamKeys::START_TLS)) )->booleanValue(); } // initialize the flag to allow empty passwords or not if ($params->exists(ParamKeys::ALLOW_EMPTY_PASSWORDS)) { $this->allowEmptyPasswords = Boolean::valueOf( new String($params->get(ParamKeys::ALLOW_EMPTY_PASSWORDS)) )->booleanValue(); } // initialialize the hash map for the roles $this->setsMap = new HashMap(); }
[ "public", "function", "initialize", "(", "Subject", "$", "subject", ",", "CallbackHandlerInterface", "$", "callbackHandler", ",", "MapInterface", "$", "sharedState", ",", "MapInterface", "$", "params", ")", "{", "// call the parent method", "parent", "::", "initialize...
Initialize the login module. This stores the subject, callbackHandler and sharedState and options for the login session. Subclasses should override if they need to process their own options. A call to parent::initialize() must be made in the case of an override. The following parameters can by default be passed from the configuration. ldapUrl: The LDAP server to connect ldapPort: The port which the LDAP server is running on baseDN: The LDAP servers base distinguished name bindDN: The administrator user DN with the permissions to search the LDAP directory. bindCredential: The credential of the administrator user baseFilter: A search filter used to locate the context of the user to authenticate rolesDN: The fixed DN of the context to search for user roles. rolFilter: A search filter used to locate the roles associated with the authenticated user. ldapStartTls: The LDAP start tls flag. Enables/disables tls requests to the LDAP server allowEmptyPasswords: Allow/disallow anonymous Logins to OpenLDAP @param \AppserverIo\Psr\Security\Auth\Subject $subject The Subject to update after a successful login @param \AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface $callbackHandler The callback handler that will be used to obtain the user identity and credentials @param \AppserverIo\Collections\MapInterface $sharedState A map shared between all configured login module instances @param \AppserverIo\Collections\MapInterface $params The parameters passed to the login module @return void
[ "Initialize", "the", "login", "module", ".", "This", "stores", "the", "subject", "callbackHandler", "and", "sharedState", "and", "options", "for", "the", "login", "session", ".", "Subclasses", "should", "override", "if", "they", "need", "to", "process", "their",...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php#L182-L244
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php
LdapLoginmodule.login
public function login() { // initialize the flag for the successfull login $this->loginOk = false; // array containing the username and password from the user's input list ($this->username, $password) = $this->getUsernameAndPassword(); // query whether or not password AND username are set if ($this->username === null && $password === null) { $this->identity = $this->unauthenticatedIdentity; } // try to create a identity based on the given username if ($this->identity === null) { try { $this->identity = $this->createIdentity($this->username); } catch (\Exception $e) { throw new LoginException( sprintf('Failed to create principal: %s', $e->getMessage()) ); } } // connect to the LDAP server $ldapConnection = $this->ldapConnect(); // replace the placeholder with the actual username of the user $this->baseFilter = preg_replace('/\{0\}/', "$this->username", $this->baseFilter); // try to load the user from the LDAP server $search = ldap_search($ldapConnection, $this->baseDN, $this->baseFilter); $entry = ldap_first_entry($ldapConnection, $search); $this->userDN = ldap_get_dn($ldapConnection, $entry); // query whether or not the user is available if (!isset($this->userDN)) { throw new LoginException('User not found in LDAP directory'); } // bind the authenticating user to the LDAP directory if ((ldap_bind($ldapConnection, $this->userDN, $password)) === false) { throw new LoginException('Username or password wrong'); } // query whether or not password stacking has been activated if ($this->getUseFirstPass()) { // add the username and password to the shared state map $this->sharedState->add(SharedStateKeys::LOGIN_NAME, $this->username); $this->sharedState->add(SharedStateKeys::LOGIN_PASSWORD, $this->credential); } // set the login flag to TRUE and return return $this->loginOk = true; }
php
public function login() { // initialize the flag for the successfull login $this->loginOk = false; // array containing the username and password from the user's input list ($this->username, $password) = $this->getUsernameAndPassword(); // query whether or not password AND username are set if ($this->username === null && $password === null) { $this->identity = $this->unauthenticatedIdentity; } // try to create a identity based on the given username if ($this->identity === null) { try { $this->identity = $this->createIdentity($this->username); } catch (\Exception $e) { throw new LoginException( sprintf('Failed to create principal: %s', $e->getMessage()) ); } } // connect to the LDAP server $ldapConnection = $this->ldapConnect(); // replace the placeholder with the actual username of the user $this->baseFilter = preg_replace('/\{0\}/', "$this->username", $this->baseFilter); // try to load the user from the LDAP server $search = ldap_search($ldapConnection, $this->baseDN, $this->baseFilter); $entry = ldap_first_entry($ldapConnection, $search); $this->userDN = ldap_get_dn($ldapConnection, $entry); // query whether or not the user is available if (!isset($this->userDN)) { throw new LoginException('User not found in LDAP directory'); } // bind the authenticating user to the LDAP directory if ((ldap_bind($ldapConnection, $this->userDN, $password)) === false) { throw new LoginException('Username or password wrong'); } // query whether or not password stacking has been activated if ($this->getUseFirstPass()) { // add the username and password to the shared state map $this->sharedState->add(SharedStateKeys::LOGIN_NAME, $this->username); $this->sharedState->add(SharedStateKeys::LOGIN_PASSWORD, $this->credential); } // set the login flag to TRUE and return return $this->loginOk = true; }
[ "public", "function", "login", "(", ")", "{", "// initialize the flag for the successfull login", "$", "this", "->", "loginOk", "=", "false", ";", "// array containing the username and password from the user's input", "list", "(", "$", "this", "->", "username", ",", "$", ...
Perform the authentication of username and password through LDAP. @return boolean TRUE when login has been successfull, else FALSE @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if an error during login occured
[ "Perform", "the", "authentication", "of", "username", "and", "password", "through", "LDAP", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php#L252-L307
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php
LdapLoginmodule.getRoleSets
protected function getRoleSets() { // search and add the roles of the current user $this->rolesSearch($this->username, $this->userDN); return $this->setsMap->toArray(); }
php
protected function getRoleSets() { // search and add the roles of the current user $this->rolesSearch($this->username, $this->userDN); return $this->setsMap->toArray(); }
[ "protected", "function", "getRoleSets", "(", ")", "{", "// search and add the roles of the current user", "$", "this", "->", "rolesSearch", "(", "$", "this", "->", "username", ",", "$", "this", "->", "userDN", ")", ";", "return", "$", "this", "->", "setsMap", ...
Overridden by subclasses to return the Groups that correspond to the to the role sets assigned to the user. Subclasses should create at least a Group named "Roles" that contains the roles assigned to the user. @return array Array containing the sets of roles @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if password can't be loaded
[ "Overridden", "by", "subclasses", "to", "return", "the", "Groups", "that", "correspond", "to", "the", "to", "the", "role", "sets", "assigned", "to", "the", "user", ".", "Subclasses", "should", "create", "at", "least", "a", "Group", "named", "Roles", "that", ...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php#L327-L332
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php
LdapLoginmodule.addRole
protected function addRole($groupName, $name) { // load the application $application = RequestHandler::getApplicationContext(); // query whether or not, the group already exists if ($this->setsMap->exists($groupName) === false) { $group = new SimpleGroup(new String($groupName)); $this->setsMap->add($groupName, $group); } else { $group = $this->setsMap->get($groupName); } try { // finally add the identity to the group $group->addMember($this->createIdentity(new String($name))); } catch (\Exception $e) { $application->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error($e->__toString()); } }
php
protected function addRole($groupName, $name) { // load the application $application = RequestHandler::getApplicationContext(); // query whether or not, the group already exists if ($this->setsMap->exists($groupName) === false) { $group = new SimpleGroup(new String($groupName)); $this->setsMap->add($groupName, $group); } else { $group = $this->setsMap->get($groupName); } try { // finally add the identity to the group $group->addMember($this->createIdentity(new String($name))); } catch (\Exception $e) { $application->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error($e->__toString()); } }
[ "protected", "function", "addRole", "(", "$", "groupName", ",", "$", "name", ")", "{", "// load the application", "$", "application", "=", "RequestHandler", "::", "getApplicationContext", "(", ")", ";", "// query whether or not, the group already exists", "if", "(", "...
Adds a role to the hash map with the roles. @param string $groupName The name of the group @param string $name The name of the role to be added to the group @return void
[ "Adds", "a", "role", "to", "the", "hash", "map", "with", "the", "roles", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php#L342-L365
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php
LdapLoginmodule.extractCNFromDN
protected function extractCNFromDN($dn) { // explode the DN $splitArray = explode(',', $dn); $keyValue = array(); // iterate over all elements foreach ($splitArray as $value) { $tempArray = explode('=', $value); $keyValue[$tempArray[0]] = array(); $keyValue[$tempArray[0]][] = $tempArray[1]; } // return the CN return $keyValue[LdapLoginmodule::CN]; }
php
protected function extractCNFromDN($dn) { // explode the DN $splitArray = explode(',', $dn); $keyValue = array(); // iterate over all elements foreach ($splitArray as $value) { $tempArray = explode('=', $value); $keyValue[$tempArray[0]] = array(); $keyValue[$tempArray[0]][] = $tempArray[1]; } // return the CN return $keyValue[LdapLoginmodule::CN]; }
[ "protected", "function", "extractCNFromDN", "(", "$", "dn", ")", "{", "// explode the DN", "$", "splitArray", "=", "explode", "(", "','", ",", "$", "dn", ")", ";", "$", "keyValue", "=", "array", "(", ")", ";", "// iterate over all elements", "foreach", "(", ...
Extracts the common name from a distinguished name. @param string $dn The distinguished name of the authenticating user @return array
[ "Extracts", "the", "common", "name", "from", "a", "distinguished", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php#L374-L390
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php
LdapLoginmodule.ldapConnect
protected function ldapConnect() { // try to connect to the LDAP server if ($ldapConnection = ldap_connect($this->ldapUrl, $this->ldapPort)) { // query whether or no we want to use START TLS if ($this->ldapStartTls) { ldap_start_tls($ldapConnection); } // set the LDAP protocol version ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); // query whether or not we want a anonymous login if ($this->allowEmptyPasswords) { $bind = ldap_bind($ldapConnection); } else { $bind = ldap_bind($ldapConnection, $this->bindDN, $this->bindCredential); } // query whether or not the bind succeeded if ($bind) { return $ldapConnection; } // throw an exception if we can't bind using the DN throw new LoginException( sprintf( 'Can\'t bind %s on LDAP server %s:%d', $this->bindDN, $this->ldapUrl, $this->ldapPort ) ); } // throw an exception if we can't connect throw new LoginException( sprintf( 'Can\'t connect to the LDAP server %s:%d', $this->ldapUrl, $this->ldapPort ) ); }
php
protected function ldapConnect() { // try to connect to the LDAP server if ($ldapConnection = ldap_connect($this->ldapUrl, $this->ldapPort)) { // query whether or no we want to use START TLS if ($this->ldapStartTls) { ldap_start_tls($ldapConnection); } // set the LDAP protocol version ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); // query whether or not we want a anonymous login if ($this->allowEmptyPasswords) { $bind = ldap_bind($ldapConnection); } else { $bind = ldap_bind($ldapConnection, $this->bindDN, $this->bindCredential); } // query whether or not the bind succeeded if ($bind) { return $ldapConnection; } // throw an exception if we can't bind using the DN throw new LoginException( sprintf( 'Can\'t bind %s on LDAP server %s:%d', $this->bindDN, $this->ldapUrl, $this->ldapPort ) ); } // throw an exception if we can't connect throw new LoginException( sprintf( 'Can\'t connect to the LDAP server %s:%d', $this->ldapUrl, $this->ldapPort ) ); }
[ "protected", "function", "ldapConnect", "(", ")", "{", "// try to connect to the LDAP server", "if", "(", "$", "ldapConnection", "=", "ldap_connect", "(", "$", "this", "->", "ldapUrl", ",", "$", "this", "->", "ldapPort", ")", ")", "{", "// query whether or no we w...
Creates a new connection to the ldap server, binds to the LDAP server and returns the connection @return resource The LDAP connection @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if the connection or the bind to the LDAP server failed
[ "Creates", "a", "new", "connection", "to", "the", "ldap", "server", "binds", "to", "the", "LDAP", "server", "and", "returns", "the", "connection" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php#L408-L452
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php
LdapLoginmodule.rolesSearch
protected function rolesSearch($user, $userDN) { // query whether or not roles DN or filter has been set if ($this->rolesDN === null || $this->roleFilter === null) { return; } // load the default group name and the LDAP connection $groupName = Util::DEFAULT_GROUP_NAME; $ldapConnection = $this->ldapConnect(); // replace the {0} placeholder with the username of the user $this->roleFilter = preg_replace("/\{0\}/", "$user", $this->roleFilter); // replace the {1} placeholder with the distiniguished name of the user $this->roleFilter = preg_replace("/\{1\}/", "$userDN", $this->roleFilter); // search for the roles using the roleFilter and get the first entry $search = ldap_search($ldapConnection, $this->rolesDN, $this->roleFilter); $entry = ldap_first_entry($ldapConnection, $search); do { // get the distinguished name of the entry and extract the common names out of it $dn = ldap_get_dn($ldapConnection, $entry); $roleArray = $this->extractCNFromDN($dn); // add every returned CN to the roles foreach ($roleArray as $role) { $this->addRole($groupName, $role); } // continue as long as there are entries still left from the search } while ($entry = ldap_next_entry($ldapConnection, $entry)); }
php
protected function rolesSearch($user, $userDN) { // query whether or not roles DN or filter has been set if ($this->rolesDN === null || $this->roleFilter === null) { return; } // load the default group name and the LDAP connection $groupName = Util::DEFAULT_GROUP_NAME; $ldapConnection = $this->ldapConnect(); // replace the {0} placeholder with the username of the user $this->roleFilter = preg_replace("/\{0\}/", "$user", $this->roleFilter); // replace the {1} placeholder with the distiniguished name of the user $this->roleFilter = preg_replace("/\{1\}/", "$userDN", $this->roleFilter); // search for the roles using the roleFilter and get the first entry $search = ldap_search($ldapConnection, $this->rolesDN, $this->roleFilter); $entry = ldap_first_entry($ldapConnection, $search); do { // get the distinguished name of the entry and extract the common names out of it $dn = ldap_get_dn($ldapConnection, $entry); $roleArray = $this->extractCNFromDN($dn); // add every returned CN to the roles foreach ($roleArray as $role) { $this->addRole($groupName, $role); } // continue as long as there are entries still left from the search } while ($entry = ldap_next_entry($ldapConnection, $entry)); }
[ "protected", "function", "rolesSearch", "(", "$", "user", ",", "$", "userDN", ")", "{", "// query whether or not roles DN or filter has been set", "if", "(", "$", "this", "->", "rolesDN", "===", "null", "||", "$", "this", "->", "roleFilter", "===", "null", ")", ...
Search the authenticated user for his user groups/roles and add their roles to the hash map with the roles. @param string $user the authenticated user @param string $userDN the DN of the authenticated user @return void
[ "Search", "the", "authenticated", "user", "for", "his", "user", "groups", "/", "roles", "and", "add", "their", "roles", "to", "the", "hash", "map", "with", "the", "roles", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/LdapLoginModule.php#L463-L497
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/DefaultSessionSettings.php
DefaultSessionSettings.mergeServletContext
public function mergeServletContext(ServletContextInterface $context) { // check if the context has his own session parameters if ($context->hasSessionParameters() === true) { if (($garbageCollectionProbability = $context->getSessionParameter(ServletSessionInterface::GARBAGE_COLLECTION_PROBABILITY)) !== null) { $this->setGarbageCollectionProbability((float) $garbageCollectionProbability); } if (($sessionName = $context->getSessionParameter(ServletSessionInterface::SESSION_NAME)) !== null) { $this->setSessionName($sessionName); } if (($sessionFilePrefix = $context->getSessionParameter(ServletSessionInterface::SESSION_FILE_PREFIX)) !== null) { $this->setSessionFilePrefix($sessionFilePrefix); } if (($sessionSavePath = $context->getSessionParameter(ServletSessionInterface::SESSION_SAVE_PATH)) !== null) { $this->setSessionSavePath($sessionSavePath); } if (($sessionMaximumAge = $context->getSessionParameter(ServletSessionInterface::SESSION_MAXIMUM_AGE)) !== null) { $this->setSessionMaximumAge((integer) $sessionMaximumAge); } if (($sessionInactivityTimeout = $context->getSessionParameter(ServletSessionInterface::SESSION_INACTIVITY_TIMEOUT)) !== null) { $this->setInactivityTimeout((integer) $sessionInactivityTimeout); } if (($sessionCookieLifetime = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_LIFETIME)) !== null) { $this->setSessionCookieLifetime((integer) $sessionCookieLifetime); } if (($sessionCookieDomain = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_DOMAIN)) !== null) { $this->setSessionCookieDomain($sessionCookieDomain); } if (($sessionCookiePath = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_PATH)) !== null) { $this->setSessionCookiePath($sessionCookiePath); } if (($sessionCookieSecure = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_SECURE)) !== null) { $this->setSessionCookieSecure((boolean) $sessionCookieSecure); } if (($sessionCookieHttpOnly = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_HTTP_ONLY)) !== null) { $this->setSessionCookieHttpOnly((boolean) $sessionCookieHttpOnly); } } }
php
public function mergeServletContext(ServletContextInterface $context) { // check if the context has his own session parameters if ($context->hasSessionParameters() === true) { if (($garbageCollectionProbability = $context->getSessionParameter(ServletSessionInterface::GARBAGE_COLLECTION_PROBABILITY)) !== null) { $this->setGarbageCollectionProbability((float) $garbageCollectionProbability); } if (($sessionName = $context->getSessionParameter(ServletSessionInterface::SESSION_NAME)) !== null) { $this->setSessionName($sessionName); } if (($sessionFilePrefix = $context->getSessionParameter(ServletSessionInterface::SESSION_FILE_PREFIX)) !== null) { $this->setSessionFilePrefix($sessionFilePrefix); } if (($sessionSavePath = $context->getSessionParameter(ServletSessionInterface::SESSION_SAVE_PATH)) !== null) { $this->setSessionSavePath($sessionSavePath); } if (($sessionMaximumAge = $context->getSessionParameter(ServletSessionInterface::SESSION_MAXIMUM_AGE)) !== null) { $this->setSessionMaximumAge((integer) $sessionMaximumAge); } if (($sessionInactivityTimeout = $context->getSessionParameter(ServletSessionInterface::SESSION_INACTIVITY_TIMEOUT)) !== null) { $this->setInactivityTimeout((integer) $sessionInactivityTimeout); } if (($sessionCookieLifetime = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_LIFETIME)) !== null) { $this->setSessionCookieLifetime((integer) $sessionCookieLifetime); } if (($sessionCookieDomain = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_DOMAIN)) !== null) { $this->setSessionCookieDomain($sessionCookieDomain); } if (($sessionCookiePath = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_PATH)) !== null) { $this->setSessionCookiePath($sessionCookiePath); } if (($sessionCookieSecure = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_SECURE)) !== null) { $this->setSessionCookieSecure((boolean) $sessionCookieSecure); } if (($sessionCookieHttpOnly = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_HTTP_ONLY)) !== null) { $this->setSessionCookieHttpOnly((boolean) $sessionCookieHttpOnly); } } }
[ "public", "function", "mergeServletContext", "(", "ServletContextInterface", "$", "context", ")", "{", "// check if the context has his own session parameters", "if", "(", "$", "context", "->", "hasSessionParameters", "(", ")", "===", "true", ")", "{", "if", "(", "(",...
Merges the values of the passed settings into this instance and overwrites the one of this instance. @param \AppserverIo\Psr\Servlet\ServletContextInterface $context The context we want to merge the session settings from @return void
[ "Merges", "the", "values", "of", "the", "passed", "settings", "into", "this", "instance", "and", "overwrites", "the", "one", "of", "this", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/DefaultSessionSettings.php#L356-L405
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletEngine.php
ServletEngine.init
public function init(ServerContextInterface $serverContext) { try { // set the servlet context $this->serverContext = $serverContext; // initialize the servlet engine $this->initValves(); $this->initHandlers(); $this->initApplications(); } catch (\Exception $e) { throw new ModuleException($e); } }
php
public function init(ServerContextInterface $serverContext) { try { // set the servlet context $this->serverContext = $serverContext; // initialize the servlet engine $this->initValves(); $this->initHandlers(); $this->initApplications(); } catch (\Exception $e) { throw new ModuleException($e); } }
[ "public", "function", "init", "(", "ServerContextInterface", "$", "serverContext", ")", "{", "try", "{", "// set the servlet context", "$", "this", "->", "serverContext", "=", "$", "serverContext", ";", "// initialize the servlet engine", "$", "this", "->", "initValve...
Initializes the module. @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The servers context instance @return void @throws \AppserverIo\Server\Exceptions\ModuleException
[ "Initializes", "the", "module", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletEngine.php#L81-L95
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletEngine.php
ServletEngine.process
public function process( RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook ) { // if false hook is coming do nothing if (ModuleHooks::REQUEST_POST !== $hook) { return; } // check if we are the handler that has to process this request if ($requestContext->getServerVar(ServerVars::SERVER_HANDLER) !== $this->getModuleName()) { return; } // load the application associated with this request $application = $this->findRequestedApplication($requestContext); // check if the application has already been connected if ($application->isConnected() === false) { throw new \Exception(sprintf('Application %s has not connected yet', $application->getName()), 503); } // create a copy of the valve instances $valves = $this->valves; $handlers = $this->handlers; // create a new request instance from the HTTP request $servletRequest = new Request(); $servletRequest->injectHandlers($handlers); $servletRequest->injectHttpRequest($request); $servletRequest->injectServerVars($requestContext->getServerVars()); $servletRequest->init(); // initialize servlet response $servletResponse = new Response(); $servletResponse->init(); // initialize the request handler instance $requestHandler = new RequestHandler(); $requestHandler->injectValves($valves); $requestHandler->injectApplication($application); $requestHandler->injectRequest($servletRequest); $requestHandler->injectResponse($servletResponse); $requestHandler->start(PTHREADS_INHERIT_NONE|PTHREADS_INHERIT_CONSTANTS); $requestHandler->join(); // copy values to the HTTP response $requestHandler->copyToHttpResponse($response); // append the servlet engine's signature $response->addHeader(Protocol::HEADER_X_POWERED_BY, get_class($this), true); // set response state to be dispatched after this without calling other modules process $response->setState(HttpResponseStates::DISPATCH); }
php
public function process( RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook ) { // if false hook is coming do nothing if (ModuleHooks::REQUEST_POST !== $hook) { return; } // check if we are the handler that has to process this request if ($requestContext->getServerVar(ServerVars::SERVER_HANDLER) !== $this->getModuleName()) { return; } // load the application associated with this request $application = $this->findRequestedApplication($requestContext); // check if the application has already been connected if ($application->isConnected() === false) { throw new \Exception(sprintf('Application %s has not connected yet', $application->getName()), 503); } // create a copy of the valve instances $valves = $this->valves; $handlers = $this->handlers; // create a new request instance from the HTTP request $servletRequest = new Request(); $servletRequest->injectHandlers($handlers); $servletRequest->injectHttpRequest($request); $servletRequest->injectServerVars($requestContext->getServerVars()); $servletRequest->init(); // initialize servlet response $servletResponse = new Response(); $servletResponse->init(); // initialize the request handler instance $requestHandler = new RequestHandler(); $requestHandler->injectValves($valves); $requestHandler->injectApplication($application); $requestHandler->injectRequest($servletRequest); $requestHandler->injectResponse($servletResponse); $requestHandler->start(PTHREADS_INHERIT_NONE|PTHREADS_INHERIT_CONSTANTS); $requestHandler->join(); // copy values to the HTTP response $requestHandler->copyToHttpResponse($response); // append the servlet engine's signature $response->addHeader(Protocol::HEADER_X_POWERED_BY, get_class($this), true); // set response state to be dispatched after this without calling other modules process $response->setState(HttpResponseStates::DISPATCH); }
[ "public", "function", "process", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "RequestContextInterface", "$", "requestContext", ",", "$", "hook", ")", "{", "// if false hook is coming do nothing", "if", "(", "ModuleHooks", "...
Process servlet request. @param \AppserverIo\Psr\HttpMessage\RequestInterface $request A request object @param \AppserverIo\Psr\HttpMessage\ResponseInterface $response A response object @param \AppserverIo\Server\Interfaces\RequestContextInterface $requestContext A requests context instance @param integer $hook The current hook to process logic for @return boolean @throws \AppserverIo\Server\Exceptions\ModuleException
[ "Process", "servlet", "request", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletEngine.php#L109-L166
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/AppEnvironmentHelper.php
AppEnvironmentHelper.getEnvironmentModifier
public static function getEnvironmentModifier($appBase) { // check if we got the properties cached already, if not load them anew $properties = null; if (!is_null(self::$cachedProperties)) { $properties = self::$cachedProperties; } else { // load the properties from file $propertiesFile = DirectoryKeys::realpath( sprintf('%s/%s', $appBase, self::CONFIGURATION_FILE) ); // load the properties from the configuration file if (file_exists($propertiesFile)) { $properties = Properties::create()->load($propertiesFile); } } // load the properties from the configuration file $result = ''; // get the actual property if it exists if (!is_null($properties) && $properties->exists(ConfigurationKeys::APP_ENVIRONMENT)) { $result = $properties->get(ConfigurationKeys::APP_ENVIRONMENT); } // ENV variable always wins if (defined(ConfigurationKeys::APP_ENVIRONMENT)) { $result = getenv(ConfigurationKeys::APP_ENVIRONMENT); } return $result; }
php
public static function getEnvironmentModifier($appBase) { // check if we got the properties cached already, if not load them anew $properties = null; if (!is_null(self::$cachedProperties)) { $properties = self::$cachedProperties; } else { // load the properties from file $propertiesFile = DirectoryKeys::realpath( sprintf('%s/%s', $appBase, self::CONFIGURATION_FILE) ); // load the properties from the configuration file if (file_exists($propertiesFile)) { $properties = Properties::create()->load($propertiesFile); } } // load the properties from the configuration file $result = ''; // get the actual property if it exists if (!is_null($properties) && $properties->exists(ConfigurationKeys::APP_ENVIRONMENT)) { $result = $properties->get(ConfigurationKeys::APP_ENVIRONMENT); } // ENV variable always wins if (defined(ConfigurationKeys::APP_ENVIRONMENT)) { $result = getenv(ConfigurationKeys::APP_ENVIRONMENT); } return $result; }
[ "public", "static", "function", "getEnvironmentModifier", "(", "$", "appBase", ")", "{", "// check if we got the properties cached already, if not load them anew", "$", "properties", "=", "null", ";", "if", "(", "!", "is_null", "(", "self", "::", "$", "cachedProperties"...
Get the environment modifier (if any) which helps to switch the configuration environment @param string $appBase The base of the application we are dealing with @return string @throws \AppserverIo\Properties\PropertyFileNotFoundException @throws \AppserverIo\Properties\PropertyFileParseException
[ "Get", "the", "environment", "modifier", "(", "if", "any", ")", "which", "helps", "to", "switch", "the", "configuration", "environment" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/AppEnvironmentHelper.php#L63-L94
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/AppEnvironmentHelper.php
AppEnvironmentHelper.getEnvironmentAwareGlobPattern
public static function getEnvironmentAwareGlobPattern($appBase, $fileGlob, $flags = 0, $fileExtension = 'xml') { // get the file path modifier $modifier = static::getEnvironmentModifier($appBase); // as we default to a not modified path we have to be careful about the "two dots" schema .$modifier.$extension $defaultFilePath = $appBase . DIRECTORY_SEPARATOR . $fileGlob . '.' . $fileExtension; if (empty($modifier)) { // if we do not have a modifier we do not need to act upon anything, so we return the default return $defaultFilePath; } else { // we got a modifier we have to check if there is something reachable under the modified path, if not we will also return the default $modifiedPath = $appBase . DIRECTORY_SEPARATOR . $fileGlob . '.' . $modifier . '.' . $fileExtension; $potentialFiles = static::globDir($modifiedPath, $flags); if (!empty($potentialFiles)) { return $modifiedPath; } return $defaultFilePath; } }
php
public static function getEnvironmentAwareGlobPattern($appBase, $fileGlob, $flags = 0, $fileExtension = 'xml') { // get the file path modifier $modifier = static::getEnvironmentModifier($appBase); // as we default to a not modified path we have to be careful about the "two dots" schema .$modifier.$extension $defaultFilePath = $appBase . DIRECTORY_SEPARATOR . $fileGlob . '.' . $fileExtension; if (empty($modifier)) { // if we do not have a modifier we do not need to act upon anything, so we return the default return $defaultFilePath; } else { // we got a modifier we have to check if there is something reachable under the modified path, if not we will also return the default $modifiedPath = $appBase . DIRECTORY_SEPARATOR . $fileGlob . '.' . $modifier . '.' . $fileExtension; $potentialFiles = static::globDir($modifiedPath, $flags); if (!empty($potentialFiles)) { return $modifiedPath; } return $defaultFilePath; } }
[ "public", "static", "function", "getEnvironmentAwareGlobPattern", "(", "$", "appBase", ",", "$", "fileGlob", ",", "$", "flags", "=", "0", ",", "$", "fileExtension", "=", "'xml'", ")", "{", "// get the file path modifier", "$", "modifier", "=", "static", "::", ...
Will take a segmented path to a file (which might contain glob type wildcards) and return it fixed to the currently active environment modifier. E.g. AppEnvironmentHelper::getEnvironmentAwareFilePath('webapps/example', 'META-INF/*-ds') => 'webapps/example/META-INF/*-ds.dev.xml' @param string $appBase The base file path to the application @param string $fileGlob The intermediate path (or glob pattern) from app base path to file extension @param integer $flags The flags passed to the glob function @param string $fileExtension The extension of the file, will default to 'xml' @return string
[ "Will", "take", "a", "segmented", "path", "to", "a", "file", "(", "which", "might", "contain", "glob", "type", "wildcards", ")", "and", "return", "it", "fixed", "to", "the", "currently", "active", "environment", "modifier", ".", "E", ".", "g", ".", "AppE...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/AppEnvironmentHelper.php#L108-L127
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/FileHandlersNodeTrait.php
FileHandlersNodeTrait.getFileHandlersAsArray
public function getFileHandlersAsArray() { // initialize the array for the file handlers $fileHandlers = array(); // iterate over the file handlers nodes and sort them into an array /** @var \AppserverIo\Appserver\Core\Api\Node\FileHandlerNode $fileHandler */ foreach ($this->getFileHandlers() as $fileHandler) { $fileHandlers[$fileHandler->getExtension()] = array( 'name' => $fileHandler->getName(), 'params' => $fileHandler->getParamsAsArray() ); } // return what we got return $fileHandlers; }
php
public function getFileHandlersAsArray() { // initialize the array for the file handlers $fileHandlers = array(); // iterate over the file handlers nodes and sort them into an array /** @var \AppserverIo\Appserver\Core\Api\Node\FileHandlerNode $fileHandler */ foreach ($this->getFileHandlers() as $fileHandler) { $fileHandlers[$fileHandler->getExtension()] = array( 'name' => $fileHandler->getName(), 'params' => $fileHandler->getParamsAsArray() ); } // return what we got return $fileHandlers; }
[ "public", "function", "getFileHandlersAsArray", "(", ")", "{", "// initialize the array for the file handlers", "$", "fileHandlers", "=", "array", "(", ")", ";", "// iterate over the file handlers nodes and sort them into an array", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\...
Returns the file handlers as an associative array. @return array The array with the sorted file handlers
[ "Returns", "the", "file", "handlers", "as", "an", "associative", "array", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/FileHandlersNodeTrait.php#L60-L77
appserver-io/appserver
src/AppserverIo/Appserver/Core/Listeners/StartScannersListener.php
StartScannersListener.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(); // write a log message that the event has been invoked $applicationServer->getSystemLogger()->info($event->getName()); // add the configured extractors to the internal array /** @var \AppserverIo\Appserver\Core\Api\Node\ScannerNodeInterface $scannerNode */ foreach ($applicationServer->getSystemConfiguration()->getScanners() as $scannerNode) { // load the factory class name $factoryClass = $scannerNode->getFactory(); // invoke the visit method of the factory class /** @var \AppserverIo\Appserver\Core\Scanner\ScannerFactoryInterface $factory */ $factoryClass::visit($applicationServer, $scannerNode); } } catch (\Exception $e) { $applicationServer->getSystemLogger()->error($e->__toString()); } }
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(); // write a log message that the event has been invoked $applicationServer->getSystemLogger()->info($event->getName()); // add the configured extractors to the internal array /** @var \AppserverIo\Appserver\Core\Api\Node\ScannerNodeInterface $scannerNode */ foreach ($applicationServer->getSystemConfiguration()->getScanners() as $scannerNode) { // load the factory class name $factoryClass = $scannerNode->getFactory(); // invoke the visit method of the factory class /** @var \AppserverIo\Appserver\Core\Scanner\ScannerFactoryInterface $factory */ $factoryClass::visit($applicationServer, $scannerNode); } } catch (\Exception $e) { $applicationServer->getSystemLogger()->error($e->__toString()); } }
[ "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/StartScannersListener.php#L45-L70
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/QueueManager.php
QueueManager.registerMessageQueues
public function registerMessageQueues(ApplicationInterface $application) { // initialize the array for the creating the subdirectories $this->directories = new GenericStackable(); $this->directories[] = $application->getNamingDirectory(); // check META-INF + subdirectories for XML files with MQ definitions /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */ $service = $application->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); $xmlFiles = $service->globDir(AppEnvironmentHelper::getEnvironmentAwareGlobPattern($this->getWebappPath(), 'META-INF' . DIRECTORY_SEPARATOR . 'message-queues')); // load the configuration service instance /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $application->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); // load the container node to initialize the system properties /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ $containerNode = $application->getContainer()->getContainerNode(); // gather all the deployed web applications foreach ($xmlFiles as $file) { try { // validate the file here, but skip if the validation fails $configurationService->validateFile($file, null, true); // load the system properties $properties = $service->getSystemProperties($containerNode); // append the application specific properties $properties->add(SystemPropertyKeys::WEBAPP, $webappPath = $application->getWebappPath()); $properties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath)); $properties->add(SystemPropertyKeys::WEBAPP_DATA, $application->getDataDir()); $properties->add(SystemPropertyKeys::WEBAPP_CACHE, $application->getCacheDir()); $properties->add(SystemPropertyKeys::WEBAPP_SESSION, $application->getSessionDir()); // create a new message queue node instance and replace the properties $messageQueuesNode = new MessageQueuesNode(); $messageQueuesNode->initFromFile($file); $messageQueuesNode->replaceProperties($properties); // register the entity managers found in the configuration foreach ($messageQueuesNode->getMessageQueues() as $messageQueueNode) { $this->registeMessageQueue($messageQueueNode); } } catch (InvalidConfigurationException $e) { // try to load the system logger instance /** @var \Psr\Log\LoggerInterface $systemLogger */ if ($systemLogger = $this->getApplication()->getInitialContext()->getSystemLogger()) { $systemLogger->error($e->getMessage()); $systemLogger->critical(sprintf('Persistence configuration file %s is invalid, needed queues might be missing.', $file)); } } catch (\Exception $e) { // try to load the system logger instance /** @var \Psr\Log\LoggerInterface $systemLogger */ if ($systemLogger = $this->getApplication()->getInitialContext()->getSystemLogger()) { $systemLogger->error($e->__toString()); } } } }
php
public function registerMessageQueues(ApplicationInterface $application) { // initialize the array for the creating the subdirectories $this->directories = new GenericStackable(); $this->directories[] = $application->getNamingDirectory(); // check META-INF + subdirectories for XML files with MQ definitions /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */ $service = $application->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); $xmlFiles = $service->globDir(AppEnvironmentHelper::getEnvironmentAwareGlobPattern($this->getWebappPath(), 'META-INF' . DIRECTORY_SEPARATOR . 'message-queues')); // load the configuration service instance /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $application->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); // load the container node to initialize the system properties /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ $containerNode = $application->getContainer()->getContainerNode(); // gather all the deployed web applications foreach ($xmlFiles as $file) { try { // validate the file here, but skip if the validation fails $configurationService->validateFile($file, null, true); // load the system properties $properties = $service->getSystemProperties($containerNode); // append the application specific properties $properties->add(SystemPropertyKeys::WEBAPP, $webappPath = $application->getWebappPath()); $properties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath)); $properties->add(SystemPropertyKeys::WEBAPP_DATA, $application->getDataDir()); $properties->add(SystemPropertyKeys::WEBAPP_CACHE, $application->getCacheDir()); $properties->add(SystemPropertyKeys::WEBAPP_SESSION, $application->getSessionDir()); // create a new message queue node instance and replace the properties $messageQueuesNode = new MessageQueuesNode(); $messageQueuesNode->initFromFile($file); $messageQueuesNode->replaceProperties($properties); // register the entity managers found in the configuration foreach ($messageQueuesNode->getMessageQueues() as $messageQueueNode) { $this->registeMessageQueue($messageQueueNode); } } catch (InvalidConfigurationException $e) { // try to load the system logger instance /** @var \Psr\Log\LoggerInterface $systemLogger */ if ($systemLogger = $this->getApplication()->getInitialContext()->getSystemLogger()) { $systemLogger->error($e->getMessage()); $systemLogger->critical(sprintf('Persistence configuration file %s is invalid, needed queues might be missing.', $file)); } } catch (\Exception $e) { // try to load the system logger instance /** @var \Psr\Log\LoggerInterface $systemLogger */ if ($systemLogger = $this->getApplication()->getInitialContext()->getSystemLogger()) { $systemLogger->error($e->__toString()); } } } }
[ "public", "function", "registerMessageQueues", "(", "ApplicationInterface", "$", "application", ")", "{", "// initialize the array for the creating the subdirectories", "$", "this", "->", "directories", "=", "new", "GenericStackable", "(", ")", ";", "$", "this", "->", "...
Deploys the message queues. @param \AppserverIo\Psr\Application\ApplicationInterface|\AppserverIo\Psr\Naming\NamingDirectoryInterface $application The application instance @return void
[ "Deploys", "the", "message", "queues", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/MessageQueue/QueueManager.php#L156-L218
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/QueueManager.php
QueueManager.registeMessageQueue
public function registeMessageQueue(MessageQueueNodeInterface $messageQueueNode) { // load destination queue and receiver type $type = $messageQueueNode->getType(); $destination = $messageQueueNode->getDestination()->__toString(); // initialize the message queue $messageQueue = new MessageQueue(); $messageQueue->injectType($type); $messageQueue->injectName($destination); $messageQueue->injectWorkers($this->workers); $messageQueue->injectMessages($this->messages); $messageQueue->injectApplication($this->application); $messageQueue->injectManagerSettings($this->managerSettings); $messageQueue->start(); // initialize the queues storage for the priorities $this->queues[$messageQueue->getName()] = $messageQueue; // bind the callback for creating a new MQ sender instance to the naming directory => necessary for DI provider $this->getApplication()->getNamingDirectory()->bindCallback(sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), $destination), array(&$this, 'createSenderForQueue'), array($destination)); }
php
public function registeMessageQueue(MessageQueueNodeInterface $messageQueueNode) { // load destination queue and receiver type $type = $messageQueueNode->getType(); $destination = $messageQueueNode->getDestination()->__toString(); // initialize the message queue $messageQueue = new MessageQueue(); $messageQueue->injectType($type); $messageQueue->injectName($destination); $messageQueue->injectWorkers($this->workers); $messageQueue->injectMessages($this->messages); $messageQueue->injectApplication($this->application); $messageQueue->injectManagerSettings($this->managerSettings); $messageQueue->start(); // initialize the queues storage for the priorities $this->queues[$messageQueue->getName()] = $messageQueue; // bind the callback for creating a new MQ sender instance to the naming directory => necessary for DI provider $this->getApplication()->getNamingDirectory()->bindCallback(sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), $destination), array(&$this, 'createSenderForQueue'), array($destination)); }
[ "public", "function", "registeMessageQueue", "(", "MessageQueueNodeInterface", "$", "messageQueueNode", ")", "{", "// load destination queue and receiver type", "$", "type", "=", "$", "messageQueueNode", "->", "getType", "(", ")", ";", "$", "destination", "=", "$", "m...
Deploys the message queue described by the passed node. @param \AppserverIo\Appserver\Core\Api\Node\MessageQueueNodeInterface $messageQueueNode The node that describes the message queue @return void
[ "Deploys", "the", "message", "queue", "described", "by", "the", "passed", "node", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/MessageQueue/QueueManager.php#L227-L249
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/QueueManager.php
QueueManager.lookup
public function lookup($lookupName, $sessionId = null, array $args = array()) { return $this->getResourceLocator()->lookup($this, $lookupName, $sessionId, $args); }
php
public function lookup($lookupName, $sessionId = null, array $args = array()) { return $this->getResourceLocator()->lookup($this, $lookupName, $sessionId, $args); }
[ "public", "function", "lookup", "(", "$", "lookupName", ",", "$", "sessionId", "=", "null", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "getResourceLocator", "(", ")", "->", "lookup", "(", "$", "this", ",...
Runs a lookup for the message queue with the passed lookup name and session ID. @param string $lookupName The queue lookup name @param string $sessionId The session ID @param array $args The arguments passed to the queue @return \AppserverIo\Psr\Pms\QueueInterface The requested queue instance @todo Still to implement
[ "Runs", "a", "lookup", "for", "the", "message", "queue", "with", "the", "passed", "lookup", "name", "and", "session", "ID", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/MessageQueue/QueueManager.php#L319-L322
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/QueueManager.php
QueueManager.createSenderForQueue
public function createSenderForQueue($lookupName, $sessionId = null) { // load the application name $application = $this->getApplication(); $applicationName = $application->getName(); $webappPath = $application->getWebappPath(); // initialize the variable for the properties $properties = null; // load the configuration base directory if ($baseDirectory = $this->getManagerSettings()->getBaseDirectory()) { // look for naming context properties in the manager's base directory $propertiesFile = DirectoryKeys::realpath( sprintf('%s/%s/%s', $webappPath, $baseDirectory, QueueManagerSettingsInterface::CONFIGURATION_FILE) ); // load the properties from the configuration file if (file_exists($propertiesFile)) { $properties = Properties::create()->load($propertiesFile); } } // initialize and return the sender $queue = \AppserverIo\Messaging\MessageQueue::createQueue($lookupName); $connection = \AppserverIo\Messaging\QueueConnectionFactory::createQueueConnection($applicationName, $properties); $session = $connection->createQueueSession(); return $session->createSender($queue); }
php
public function createSenderForQueue($lookupName, $sessionId = null) { // load the application name $application = $this->getApplication(); $applicationName = $application->getName(); $webappPath = $application->getWebappPath(); // initialize the variable for the properties $properties = null; // load the configuration base directory if ($baseDirectory = $this->getManagerSettings()->getBaseDirectory()) { // look for naming context properties in the manager's base directory $propertiesFile = DirectoryKeys::realpath( sprintf('%s/%s/%s', $webappPath, $baseDirectory, QueueManagerSettingsInterface::CONFIGURATION_FILE) ); // load the properties from the configuration file if (file_exists($propertiesFile)) { $properties = Properties::create()->load($propertiesFile); } } // initialize and return the sender $queue = \AppserverIo\Messaging\MessageQueue::createQueue($lookupName); $connection = \AppserverIo\Messaging\QueueConnectionFactory::createQueueConnection($applicationName, $properties); $session = $connection->createQueueSession(); return $session->createSender($queue); }
[ "public", "function", "createSenderForQueue", "(", "$", "lookupName", ",", "$", "sessionId", "=", "null", ")", "{", "// load the application name", "$", "application", "=", "$", "this", "->", "getApplication", "(", ")", ";", "$", "applicationName", "=", "$", "...
Return a new sender for the message queue with the passed lookup name. @param string $lookupName The lookup name of the queue to return a sender for @param string $sessionId The session-ID to be passed to the queue session @return \AppserverIo\Messaging\QueueSender The sender instance
[ "Return", "a", "new", "sender", "for", "the", "message", "queue", "with", "the", "passed", "lookup", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/MessageQueue/QueueManager.php#L332-L361
appserver-io/appserver
src/AppserverIo/Appserver/MessageQueue/QueueManager.php
QueueManager.stop
public function stop() { // load the queue keys $queues = get_object_vars($this->getQueues()); // iterate over the queues and shut them down /** @var AppserverIo\Psr\Pms\QueueInterface $queue */ foreach ($queues as $queue) { $queue->stop(); } }
php
public function stop() { // load the queue keys $queues = get_object_vars($this->getQueues()); // iterate over the queues and shut them down /** @var AppserverIo\Psr\Pms\QueueInterface $queue */ foreach ($queues as $queue) { $queue->stop(); } }
[ "public", "function", "stop", "(", ")", "{", "// load the queue keys", "$", "queues", "=", "get_object_vars", "(", "$", "this", "->", "getQueues", "(", ")", ")", ";", "// iterate over the queues and shut them down", "/** @var AppserverIo\\Psr\\Pms\\QueueInterface $queue */"...
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/MessageQueue/QueueManager.php#L392-L403
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/ContainerStateKeys.php
ContainerStateKeys.getContainerStates
public static function getContainerStates() { return array( ContainerStateKeys::HALT, ContainerStateKeys::WAITING_FOR_INITIALIZATION, ContainerStateKeys::INITIALIZATION_SUCCESSFUL, ContainerStateKeys::DEPLOYMENT_SUCCESSFUL, ContainerStateKeys::SERVERS_STARTED_SUCCESSFUL, ContainerStateKeys::SHUTDOWN ); }
php
public static function getContainerStates() { return array( ContainerStateKeys::HALT, ContainerStateKeys::WAITING_FOR_INITIALIZATION, ContainerStateKeys::INITIALIZATION_SUCCESSFUL, ContainerStateKeys::DEPLOYMENT_SUCCESSFUL, ContainerStateKeys::SERVERS_STARTED_SUCCESSFUL, ContainerStateKeys::SHUTDOWN ); }
[ "public", "static", "function", "getContainerStates", "(", ")", "{", "return", "array", "(", "ContainerStateKeys", "::", "HALT", ",", "ContainerStateKeys", "::", "WAITING_FOR_INITIALIZATION", ",", "ContainerStateKeys", "::", "INITIALIZATION_SUCCESSFUL", ",", "ContainerSta...
Returns the container states. @return array The container states
[ "Returns", "the", "container", "states", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/ContainerStateKeys.php#L130-L140
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/ContainerStateKeys.php
ContainerStateKeys.get
public static function get($containerState) { // check if the requested container state is available and create a new instance if (in_array($containerState, ContainerStateKeys::getContainerStates())) { return new ContainerStateKeys($containerState); } // throw a exception if the requested runlevel is not available throw new InvalidContainerStateException( sprintf( 'Requested container state %s is not available (choose on of: %s)', $containerState, implode(',', ContainerStateKeys::getContainerStates()) ) ); }
php
public static function get($containerState) { // check if the requested container state is available and create a new instance if (in_array($containerState, ContainerStateKeys::getContainerStates())) { return new ContainerStateKeys($containerState); } // throw a exception if the requested runlevel is not available throw new InvalidContainerStateException( sprintf( 'Requested container state %s is not available (choose on of: %s)', $containerState, implode(',', ContainerStateKeys::getContainerStates()) ) ); }
[ "public", "static", "function", "get", "(", "$", "containerState", ")", "{", "// check if the requested container state is available and create a new instance", "if", "(", "in_array", "(", "$", "containerState", ",", "ContainerStateKeys", "::", "getContainerStates", "(", ")...
Factory method to create a new container state instance. @param integer $containerState The container state to create an instance for @return \AppserverIo\Appserver\Core\Utilities\ContainerStateKeys The container state key instance @throws \AppserverIo\Appserver\Core\Utilities\InvalidContainerStateException Is thrown if the container state is not available
[ "Factory", "method", "to", "create", "a", "new", "container", "state", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/ContainerStateKeys.php#L187-L203
appserver-io/appserver
src/AppserverIo/Appserver/Core/Consoles/Telnet.php
Telnet.run
public function run() { // register a shutdown handler for controlled shutdown register_shutdown_function(array(&$this, 'shutdown')); // we need the autloader again require SERVER_AUTOLOADER; // create a reference to the application server instance $applicationServer = $this->applicationServer; // initialize the event loop and the socket server $loop = \React\EventLoop\Factory::create(); $socket = new \React\Socket\Server($loop); // wait for connections $socket->on('connection', function ($conn) use ($applicationServer) { // wait for user input => usually a command $conn->on('data', function ($data) use ($conn, $applicationServer) { try { // extract command name and parameters $params = Arguments::split($data); $commandName = array_shift($params); try { // initialize and execute the command $command = CommandFactory::factory($commandName, array($conn, $applicationServer)); $command->execute($params); } catch (\ReflectionException $re) { $conn->write(sprintf("Unknown command %sERROR\n", $commandName)); } } catch (\Exception $e) { $conn->write("{$e->__toString()}ERROR\n"); } }); }); // listen to the management socket $socket->listen($this->getPort(), $this->getAddress()); // start the event loop and the socket server, but disable warnings as some React warnings cannot (or won't) be dealt with. // Specifically the warning if a client disconnects unexpectedly or does not even connect to begin with ("Interrupted system call") is unevitable // @see https://github.com/reactphp/react/pull/297 // @see https://github.com/reactphp/react/issues/296 // @see http://php.net/manual/de/function.stream-select.php $currentReportingLevel = error_reporting(); error_reporting(E_ALL ^ E_WARNING); $loop->run(); error_reporting($currentReportingLevel); }
php
public function run() { // register a shutdown handler for controlled shutdown register_shutdown_function(array(&$this, 'shutdown')); // we need the autloader again require SERVER_AUTOLOADER; // create a reference to the application server instance $applicationServer = $this->applicationServer; // initialize the event loop and the socket server $loop = \React\EventLoop\Factory::create(); $socket = new \React\Socket\Server($loop); // wait for connections $socket->on('connection', function ($conn) use ($applicationServer) { // wait for user input => usually a command $conn->on('data', function ($data) use ($conn, $applicationServer) { try { // extract command name and parameters $params = Arguments::split($data); $commandName = array_shift($params); try { // initialize and execute the command $command = CommandFactory::factory($commandName, array($conn, $applicationServer)); $command->execute($params); } catch (\ReflectionException $re) { $conn->write(sprintf("Unknown command %sERROR\n", $commandName)); } } catch (\Exception $e) { $conn->write("{$e->__toString()}ERROR\n"); } }); }); // listen to the management socket $socket->listen($this->getPort(), $this->getAddress()); // start the event loop and the socket server, but disable warnings as some React warnings cannot (or won't) be dealt with. // Specifically the warning if a client disconnects unexpectedly or does not even connect to begin with ("Interrupted system call") is unevitable // @see https://github.com/reactphp/react/pull/297 // @see https://github.com/reactphp/react/issues/296 // @see http://php.net/manual/de/function.stream-select.php $currentReportingLevel = error_reporting(); error_reporting(E_ALL ^ E_WARNING); $loop->run(); error_reporting($currentReportingLevel); }
[ "public", "function", "run", "(", ")", "{", "// register a shutdown handler for controlled shutdown", "register_shutdown_function", "(", "array", "(", "&", "$", "this", ",", "'shutdown'", ")", ")", ";", "// we need the autloader again", "require", "SERVER_AUTOLOADER", ";"...
The thread's run() method that runs asynchronously. @return void @link http://www.php.net/manual/en/thread.run.php
[ "The", "thread", "s", "run", "()", "method", "that", "runs", "asynchronously", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Consoles/Telnet.php#L151-L203
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/RequestHandler.php
RequestHandler.run
public function run() { try { // register the default autoloader require SERVER_AUTOLOADER; // register shutdown handler set_error_handler(array(&$this, 'errorHandler')); register_shutdown_function(array(&$this, 'shutdown')); // initialize the array for the errors $this->errors = array(); // synchronize the application instance and register the class loaders $application = $this->application; $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // synchronize the valves, servlet request/response $valves = $this->valves; $servletRequest = $this->servletRequest; $servletResponse = $this->servletResponse; // load the session and the authentication manager $sessionManager = $application->search(SessionManagerInterface::IDENTIFIER); $authenticationManager = $application->search(AuthenticationManagerInterface::IDENTIFIER); // inject the sapplication and servlet response $servletRequest->injectContext($application); $servletRequest->injectResponse($servletResponse); $servletRequest->injectSessionManager($sessionManager); $servletRequest->injectAuthenticationManager($authenticationManager); // prepare the request instance $servletRequest->prepare(); // initialize static request and application context RequestHandler::$requestContext = $servletRequest; RequestHandler::$applicationContext = $application; // add the application instance to the environment Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application); // create a simulated request/session ID whereas session equals request ID (as long as session has NOT been started) Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $requestId = SessionUtils::generateRandomString()); Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $requestId); // process the valves foreach ($valves as $valve) { $valve->invoke($servletRequest, $servletResponse); if ($servletRequest->isDispatched() === true) { break; } } // flush the session manager $sessionManager->flush(); // profile the request if the profile logger is available if ($profileLogger = $application->getInitialContext()->getLogger(LoggerUtils::PROFILE)) { $profileLogger->appendThreadContext('request-handler'); $profileLogger->debug($servletRequest->getUri()); } } catch (\Exception $e) { $this->addError(ErrorUtil::singleton()->fromException($e)); } // re-attach request and response instances $this->servletRequest = $servletRequest; $this->servletResponse = $servletResponse; }
php
public function run() { try { // register the default autoloader require SERVER_AUTOLOADER; // register shutdown handler set_error_handler(array(&$this, 'errorHandler')); register_shutdown_function(array(&$this, 'shutdown')); // initialize the array for the errors $this->errors = array(); // synchronize the application instance and register the class loaders $application = $this->application; $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // synchronize the valves, servlet request/response $valves = $this->valves; $servletRequest = $this->servletRequest; $servletResponse = $this->servletResponse; // load the session and the authentication manager $sessionManager = $application->search(SessionManagerInterface::IDENTIFIER); $authenticationManager = $application->search(AuthenticationManagerInterface::IDENTIFIER); // inject the sapplication and servlet response $servletRequest->injectContext($application); $servletRequest->injectResponse($servletResponse); $servletRequest->injectSessionManager($sessionManager); $servletRequest->injectAuthenticationManager($authenticationManager); // prepare the request instance $servletRequest->prepare(); // initialize static request and application context RequestHandler::$requestContext = $servletRequest; RequestHandler::$applicationContext = $application; // add the application instance to the environment Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application); // create a simulated request/session ID whereas session equals request ID (as long as session has NOT been started) Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $requestId = SessionUtils::generateRandomString()); Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $requestId); // process the valves foreach ($valves as $valve) { $valve->invoke($servletRequest, $servletResponse); if ($servletRequest->isDispatched() === true) { break; } } // flush the session manager $sessionManager->flush(); // profile the request if the profile logger is available if ($profileLogger = $application->getInitialContext()->getLogger(LoggerUtils::PROFILE)) { $profileLogger->appendThreadContext('request-handler'); $profileLogger->debug($servletRequest->getUri()); } } catch (\Exception $e) { $this->addError(ErrorUtil::singleton()->fromException($e)); } // re-attach request and response instances $this->servletRequest = $servletRequest; $this->servletResponse = $servletResponse; }
[ "public", "function", "run", "(", ")", "{", "try", "{", "// register the default autoloader", "require", "SERVER_AUTOLOADER", ";", "// register shutdown handler", "set_error_handler", "(", "array", "(", "&", "$", "this", ",", "'errorHandler'", ")", ")", ";", "regist...
The main method that handles the thread in a separate context. @return void
[ "The", "main", "method", "that", "handles", "the", "thread", "in", "a", "separate", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/RequestHandler.php#L121-L195
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/RequestHandler.php
RequestHandler.copyToHttpResponse
public function copyToHttpResponse(ResponseInterface $httpResponse) { // create a local copy of the response $servletResponse = $this->servletResponse; // copy response values to the HTTP response $httpResponse->setStatusCode($servletResponse->getStatusCode()); $httpResponse->setStatusReasonPhrase($servletResponse->getStatusReasonPhrase()); $httpResponse->setVersion($servletResponse->getVersion()); $httpResponse->setState($servletResponse->getState()); // copy the body content to the HTTP response $httpResponse->appendBodyStream($servletResponse->getBodyStream()); // copy headers to the HTTP response foreach ($servletResponse->getHeaders() as $headerName => $headerValue) { $httpResponse->addHeader($headerName, $headerValue); } // copy cookies to the HTTP response $httpResponse->setCookies($servletResponse->getCookies()); }
php
public function copyToHttpResponse(ResponseInterface $httpResponse) { // create a local copy of the response $servletResponse = $this->servletResponse; // copy response values to the HTTP response $httpResponse->setStatusCode($servletResponse->getStatusCode()); $httpResponse->setStatusReasonPhrase($servletResponse->getStatusReasonPhrase()); $httpResponse->setVersion($servletResponse->getVersion()); $httpResponse->setState($servletResponse->getState()); // copy the body content to the HTTP response $httpResponse->appendBodyStream($servletResponse->getBodyStream()); // copy headers to the HTTP response foreach ($servletResponse->getHeaders() as $headerName => $headerValue) { $httpResponse->addHeader($headerName, $headerValue); } // copy cookies to the HTTP response $httpResponse->setCookies($servletResponse->getCookies()); }
[ "public", "function", "copyToHttpResponse", "(", "ResponseInterface", "$", "httpResponse", ")", "{", "// create a local copy of the response", "$", "servletResponse", "=", "$", "this", "->", "servletResponse", ";", "// copy response values to the HTTP response", "$", "httpRes...
Copies the values from the request handler back to the passed HTTP response instance. @param \AppserverIo\Psr\HttpMessage\ResponseInterface $httpResponse A HTTP response object @return void
[ "Copies", "the", "values", "from", "the", "request", "handler", "back", "to", "the", "passed", "HTTP", "response", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/RequestHandler.php#L204-L226
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/RequestHandler.php
RequestHandler.errorHandler
public function errorHandler($errno, $errstr, $errfile, $errline) { // query whether or not we've to handle the passed error if ($errno > error_reporting()) { return true; } // add the passed error information to the array with the errors $error = ErrorUtil::singleton()->fromArray(array($errno, $errstr, $errfile, $errline)); // add the passed error information to the array with the errors $this->addError($error); return true; }
php
public function errorHandler($errno, $errstr, $errfile, $errline) { // query whether or not we've to handle the passed error if ($errno > error_reporting()) { return true; } // add the passed error information to the array with the errors $error = ErrorUtil::singleton()->fromArray(array($errno, $errstr, $errfile, $errline)); // add the passed error information to the array with the errors $this->addError($error); return true; }
[ "public", "function", "errorHandler", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "// query whether or not we've to handle the passed error", "if", "(", "$", "errno", ">", "error_reporting", "(", ")", ")", "{", "r...
PHP error handler implemenation that replaces the defaulf PHP error handling. As this method will NOT handle Fatal Errors with code E_ERROR or E_USER, so these have to be processed by the shutdown handler itself. @param integer $errno The intern PHP error number @param string $errstr The error message itself @param string $errfile The file where the error occurs @param integer $errline The line where the error occurs @return boolean Always return TRUE, because we want to disable default PHP error handling @link http://docs.php.net/manual/en/function.set-error-handler.php
[ "PHP", "error", "handler", "implemenation", "that", "replaces", "the", "defaulf", "PHP", "error", "handling", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/RequestHandler.php#L242-L256
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/RequestHandler.php
RequestHandler.shutdown
public function shutdown() { // create a local copy of the request/response $servletRequest = $this->servletRequest; $servletResponse = $this->servletResponse; // check if we had a fatal error that caused the shutdown if ($lastError = error_get_last()) { // add the fatal error $this->addError(ErrorUtil::singleton()->fromArray($lastError)); // in case of fatal errors, we need to override request with perpared // instances because error handling needs application access $servletRequest = RequestHandler::$requestContext; } // handle the errors if necessary ErrorUtil::singleton()->handleErrors($this, $servletRequest, $servletResponse); // copy request/response back to the thread context $this->servletRequest = $servletRequest; $this->servletResponse = $servletResponse; }
php
public function shutdown() { // create a local copy of the request/response $servletRequest = $this->servletRequest; $servletResponse = $this->servletResponse; // check if we had a fatal error that caused the shutdown if ($lastError = error_get_last()) { // add the fatal error $this->addError(ErrorUtil::singleton()->fromArray($lastError)); // in case of fatal errors, we need to override request with perpared // instances because error handling needs application access $servletRequest = RequestHandler::$requestContext; } // handle the errors if necessary ErrorUtil::singleton()->handleErrors($this, $servletRequest, $servletResponse); // copy request/response back to the thread context $this->servletRequest = $servletRequest; $this->servletResponse = $servletResponse; }
[ "public", "function", "shutdown", "(", ")", "{", "// create a local copy of the request/response", "$", "servletRequest", "=", "$", "this", "->", "servletRequest", ";", "$", "servletResponse", "=", "$", "this", "->", "servletResponse", ";", "// check if we had a fatal e...
Does shutdown logic for request handler if something went wrong and produces a fatal error for example. @return void
[ "Does", "shutdown", "logic", "for", "request", "handler", "if", "something", "went", "wrong", "and", "produces", "a", "fatal", "error", "for", "example", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/RequestHandler.php#L264-L286
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/RequestHandler.php
RequestHandler.addError
public function addError(ErrorInterface $error) { // create a local copy of the error stack $errors = $this->errors; // append the error to the stack $errors[] = $error; // copy the error stack back to the thread context $this->errors = $errors; }
php
public function addError(ErrorInterface $error) { // create a local copy of the error stack $errors = $this->errors; // append the error to the stack $errors[] = $error; // copy the error stack back to the thread context $this->errors = $errors; }
[ "public", "function", "addError", "(", "ErrorInterface", "$", "error", ")", "{", "// create a local copy of the error stack", "$", "errors", "=", "$", "this", "->", "errors", ";", "// append the error to the stack", "$", "errors", "[", "]", "=", "$", "error", ";",...
Append the passed error to the request handler's stack. @param \AppserverIo\Appserver\ServletEngine\Utils\ErrorInterface $error The error to append @return void
[ "Append", "the", "passed", "error", "to", "the", "request", "handler", "s", "stack", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/RequestHandler.php#L295-L305
appserver-io/appserver
src/AppserverIo/Appserver/Core/Listeners/SwitchSetupModeListener.php
SwitchSetupModeListener.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(); // load the configuration filename $configurationFilename = $applicationServer->getConfigurationFilename(); // write a log message that the event has been invoked $applicationServer->getSystemLogger()->info($event->getName()); // load the setup mode from the naming directory $setupMode = $namingDirectory->search('php:env/args/s'); $currentUser = $namingDirectory->search('php:env/currentUser'); // load the service instance and switch to the new setup mode /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */ $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\ContainerService'); $service->switchSetupMode($setupMode, $configurationFilename, $currentUser); } catch (NamingException $ne) { $applicationServer->getSystemLogger()->error('Please specify a setup mode, e. g. \'./server.php -s prod\''); } catch (\Exception $e) { $applicationServer->getSystemLogger()->error($e->__toString()); } }
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(); // load the configuration filename $configurationFilename = $applicationServer->getConfigurationFilename(); // write a log message that the event has been invoked $applicationServer->getSystemLogger()->info($event->getName()); // load the setup mode from the naming directory $setupMode = $namingDirectory->search('php:env/args/s'); $currentUser = $namingDirectory->search('php:env/currentUser'); // load the service instance and switch to the new setup mode /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */ $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\ContainerService'); $service->switchSetupMode($setupMode, $configurationFilename, $currentUser); } catch (NamingException $ne) { $applicationServer->getSystemLogger()->error('Please specify a setup mode, e. g. \'./server.php -s prod\''); } catch (\Exception $e) { $applicationServer->getSystemLogger()->error($e->__toString()); } }
[ "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/SwitchSetupModeListener.php#L46-L76
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/HostNode.php
HostNode.getDirectories
public function getDirectories() { return array( DirectoryKeys::TMP => $this->getTmpBase(), DirectoryKeys::DEPLOY => $this->getDeployBase(), DirectoryKeys::WEBAPPS => $this->getAppBase() ); }
php
public function getDirectories() { return array( DirectoryKeys::TMP => $this->getTmpBase(), DirectoryKeys::DEPLOY => $this->getDeployBase(), DirectoryKeys::WEBAPPS => $this->getAppBase() ); }
[ "public", "function", "getDirectories", "(", ")", "{", "return", "array", "(", "DirectoryKeys", "::", "TMP", "=>", "$", "this", "->", "getTmpBase", "(", ")", ",", "DirectoryKeys", "::", "DEPLOY", "=>", "$", "this", "->", "getDeployBase", "(", ")", ",", "...
Return's the host's directories, e. g. to be created. @return array The array with the host's directories
[ "Return", "s", "the", "host", "s", "directories", "e", ".", "g", ".", "to", "be", "created", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/HostNode.php#L140-L147
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/StandardScannerFactory.php
StandardScannerFactory.visit
public static function visit(ApplicationServerInterface $server, ScannerNodeInterface $scannerNode) { // load the initial context instance /** @var \AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext */ $initialContext = $server->getInitialContext(); // load the reflection class for the scanner type $reflectionClass = new \ReflectionClass($scannerNode->getType()); // prepare the scanner params $scannerParams = array($initialContext, $scannerNode->getName()); $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(); // load the reflection class for the scanner type $reflectionClass = new \ReflectionClass($scannerNode->getType()); // prepare the scanner params $scannerParams = array($initialContext, $scannerNode->getName()); $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/StandardScannerFactory.php#L46-L62
appserver-io/appserver
src/AppserverIo/Appserver/Core/Commands/ConsoleCommand.php
ConsoleCommand.doExcute
protected function doExcute(array $command = array()) { try { // prepare the application's lookup name with the first argument, which has to be the application name $lookupName = sprintf('php:global/combined-appserver/%s/ApplicationInterface', array_shift($command)); // try to load the application /** \AppserverIo\Psr\Application\ApplicationInterface $application */ $application = $this->getNamingDirectory()->search($lookupName); // try to load the application's console manager and execute the command /** @var \AppserverIo\Appserver\Console\ConsoleContextInterface $consoleManager */ $consoleManager = $application->search(ConsoleContextInterface::IDENTIFIER); $consoleManager->execute($this->connection, $command); } catch (\Exception $e) { // log the exception $this->getSystemLogger()->error($e->__toString()); // write the error message to the output $this->write("{$e->__toString()}ERROR\n"); } }
php
protected function doExcute(array $command = array()) { try { // prepare the application's lookup name with the first argument, which has to be the application name $lookupName = sprintf('php:global/combined-appserver/%s/ApplicationInterface', array_shift($command)); // try to load the application /** \AppserverIo\Psr\Application\ApplicationInterface $application */ $application = $this->getNamingDirectory()->search($lookupName); // try to load the application's console manager and execute the command /** @var \AppserverIo\Appserver\Console\ConsoleContextInterface $consoleManager */ $consoleManager = $application->search(ConsoleContextInterface::IDENTIFIER); $consoleManager->execute($this->connection, $command); } catch (\Exception $e) { // log the exception $this->getSystemLogger()->error($e->__toString()); // write the error message to the output $this->write("{$e->__toString()}ERROR\n"); } }
[ "protected", "function", "doExcute", "(", "array", "$", "command", "=", "array", "(", ")", ")", "{", "try", "{", "// prepare the application's lookup name with the first argument, which has to be the application name", "$", "lookupName", "=", "sprintf", "(", "'php:global/co...
Execute the Doctrine CLI tool. @param array $command The Doctrine command to be executed @return string The commands output
[ "Execute", "the", "Doctrine", "CLI", "tool", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Commands/ConsoleCommand.php#L93-L115
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimerServiceRegistryFactory.php
TimerServiceRegistryFactory.visit
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the service locator $serviceLocator = new ServiceLocator(); // initialize the stackable for the data, the services and the scheduled timer tasks $data = new StackableStorage(); $services = new StackableStorage(); $timerTasks = new GenericStackable(); $tasksToExecute = new GenericStackable(); $scheduledTimers = new GenericStackable(); // initialize the timer factory $timerFactory = new TimerFactory(); $timerFactory->injectApplication($application); $timerFactory->start(); // initialize the calendar timer factory $calendarTimerFactory = new CalendarTimerFactory(); $calendarTimerFactory->injectApplication($application); $calendarTimerFactory->start(); // initialize the executor for the scheduled timer tasks $timerServiceExecutor = new TimerServiceExecutor(); $timerServiceExecutor->injectApplication($application); $timerServiceExecutor->injectTimerTasks($timerTasks); $timerServiceExecutor->injectTasksToExecute($tasksToExecute); $timerServiceExecutor->injectScheduledTimers($scheduledTimers); $timerServiceExecutor->start(); // initialize the service registry $serviceRegistry = new TimerServiceRegistry(); $serviceRegistry->injectData($data); $serviceRegistry->injectServices($services); $serviceRegistry->injectApplication($application); $serviceRegistry->injectTimerFactory($timerFactory); $serviceRegistry->injectServiceLocator($serviceLocator); $serviceRegistry->injectCalendarTimerFactory($calendarTimerFactory); $serviceRegistry->injectTimerServiceExecutor($timerServiceExecutor); // attach the instance $application->addManager($serviceRegistry, $managerConfiguration); }
php
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the service locator $serviceLocator = new ServiceLocator(); // initialize the stackable for the data, the services and the scheduled timer tasks $data = new StackableStorage(); $services = new StackableStorage(); $timerTasks = new GenericStackable(); $tasksToExecute = new GenericStackable(); $scheduledTimers = new GenericStackable(); // initialize the timer factory $timerFactory = new TimerFactory(); $timerFactory->injectApplication($application); $timerFactory->start(); // initialize the calendar timer factory $calendarTimerFactory = new CalendarTimerFactory(); $calendarTimerFactory->injectApplication($application); $calendarTimerFactory->start(); // initialize the executor for the scheduled timer tasks $timerServiceExecutor = new TimerServiceExecutor(); $timerServiceExecutor->injectApplication($application); $timerServiceExecutor->injectTimerTasks($timerTasks); $timerServiceExecutor->injectTasksToExecute($tasksToExecute); $timerServiceExecutor->injectScheduledTimers($scheduledTimers); $timerServiceExecutor->start(); // initialize the service registry $serviceRegistry = new TimerServiceRegistry(); $serviceRegistry->injectData($data); $serviceRegistry->injectServices($services); $serviceRegistry->injectApplication($application); $serviceRegistry->injectTimerFactory($timerFactory); $serviceRegistry->injectServiceLocator($serviceLocator); $serviceRegistry->injectCalendarTimerFactory($calendarTimerFactory); $serviceRegistry->injectTimerServiceExecutor($timerServiceExecutor); // attach the instance $application->addManager($serviceRegistry, $managerConfiguration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ManagerNodeInterface", "$", "managerConfiguration", ")", "{", "// initialize the service locator", "$", "serviceLocator", "=", "new", "ServiceLocator", "(", ")", ";", "// ini...
The main method that creates new instances in a separate context. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration The manager configuration @return void
[ "The", "main", "method", "that", "creates", "new", "instances", "in", "a", "separate", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimerServiceRegistryFactory.php#L49-L92
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/GarbageCollectors/StandardGarbageCollector.php
StandardGarbageCollector.collectGarbage
public function collectGarbage() { // we need the bean manager that handles all the beans /** @var \AppserverIo\Psr\EnterpriseBeans\BeanContextInterface $beanManager */ $beanManager = $this->getApplication()->search(BeanContextInterface::IDENTIFIER); // load the map with the stateful session beans /** @var \AppserverIo\Storage\StorageInterface $statefulSessionBeans */ $statefulSessionBeans = $beanManager->getStatefulSessionBeans(); // initialize the timestamp with the actual time $actualTime = time(); // load the map with the SFSB lifetime data $lifetimeMap = $statefulSessionBeans->getLifetime(); // initialize the counter for the SFSBs $counter = 0; // iterate over the applications sessions with stateful session beans foreach ($lifetimeMap as $identifier => $lifetime) { // check the lifetime of the stateful session beans if ($lifetime < $actualTime) { // if the stateful session bean has timed out, remove it $statefulSessionBeans->remove($identifier, array($beanManager, 'destroyBeanInstance')); // write a log message $this->log(LogLevel::DEBUG, sprintf('Successfully removed SFSB %s', $identifier)); // reduce CPU load usleep(1000); } else { // raise the counter $counter++; // write a log message $this->log(LogLevel::DEBUG, sprintf('Lifetime %s of SFSB %s is > %s', $lifetime, $identifier, $actualTime)); } } // write a log message with size of SFSBs to be garbage collected $this->log(LogLevel::DEBUG, sprintf('Found %d SFSBs be garbage collected', $counter)); // profile the size of the sessions /** @var \Psr\Log\LoggerInterface $this->profileLogger */ if ($this->profileLogger) { $this->profileLogger->debug( sprintf('Processed standard garbage collector, handling %d SFSBs', sizeof($statefulSessionBeans)) ); } }
php
public function collectGarbage() { // we need the bean manager that handles all the beans /** @var \AppserverIo\Psr\EnterpriseBeans\BeanContextInterface $beanManager */ $beanManager = $this->getApplication()->search(BeanContextInterface::IDENTIFIER); // load the map with the stateful session beans /** @var \AppserverIo\Storage\StorageInterface $statefulSessionBeans */ $statefulSessionBeans = $beanManager->getStatefulSessionBeans(); // initialize the timestamp with the actual time $actualTime = time(); // load the map with the SFSB lifetime data $lifetimeMap = $statefulSessionBeans->getLifetime(); // initialize the counter for the SFSBs $counter = 0; // iterate over the applications sessions with stateful session beans foreach ($lifetimeMap as $identifier => $lifetime) { // check the lifetime of the stateful session beans if ($lifetime < $actualTime) { // if the stateful session bean has timed out, remove it $statefulSessionBeans->remove($identifier, array($beanManager, 'destroyBeanInstance')); // write a log message $this->log(LogLevel::DEBUG, sprintf('Successfully removed SFSB %s', $identifier)); // reduce CPU load usleep(1000); } else { // raise the counter $counter++; // write a log message $this->log(LogLevel::DEBUG, sprintf('Lifetime %s of SFSB %s is > %s', $lifetime, $identifier, $actualTime)); } } // write a log message with size of SFSBs to be garbage collected $this->log(LogLevel::DEBUG, sprintf('Found %d SFSBs be garbage collected', $counter)); // profile the size of the sessions /** @var \Psr\Log\LoggerInterface $this->profileLogger */ if ($this->profileLogger) { $this->profileLogger->debug( sprintf('Processed standard garbage collector, handling %d SFSBs', sizeof($statefulSessionBeans)) ); } }
[ "public", "function", "collectGarbage", "(", ")", "{", "// we need the bean manager that handles all the beans", "/** @var \\AppserverIo\\Psr\\EnterpriseBeans\\BeanContextInterface $beanManager */", "$", "beanManager", "=", "$", "this", "->", "getApplication", "(", ")", "->", "se...
Collects the SFSBs that has been timed out @return void
[ "Collects", "the", "SFSBs", "that", "has", "been", "timed", "out" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/GarbageCollectors/StandardGarbageCollector.php#L120-L168
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletValve.php
ServletValve.invoke
public function invoke(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) { // load the servlet manager /** @var \AppserverIo\Psr\Servlet\ServletContextInterface|\AppserverIo\Psr\Application\ManagerInterface $servletManager */ $servletManager = $servletRequest->getContext()->search('ServletContextInterface'); // locate and service the servlet $servlet = $servletManager->locate($servletRequest); $servlet->service($servletRequest, $servletResponse); // finally invoke the destroy() method $servlet->destroy(); // dispatch this request, because we have finished processing it $servletRequest->setDispatched(true); }
php
public function invoke(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) { // load the servlet manager /** @var \AppserverIo\Psr\Servlet\ServletContextInterface|\AppserverIo\Psr\Application\ManagerInterface $servletManager */ $servletManager = $servletRequest->getContext()->search('ServletContextInterface'); // locate and service the servlet $servlet = $servletManager->locate($servletRequest); $servlet->service($servletRequest, $servletResponse); // finally invoke the destroy() method $servlet->destroy(); // dispatch this request, because we have finished processing it $servletRequest->setDispatched(true); }
[ "public", "function", "invoke", "(", "HttpServletRequestInterface", "$", "servletRequest", ",", "HttpServletResponseInterface", "$", "servletResponse", ")", "{", "// load the servlet manager", "/** @var \\AppserverIo\\Psr\\Servlet\\ServletContextInterface|\\AppserverIo\\Psr\\Application\...
Processes the request by invoking the request handler that executes the servlet in a protected context. @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The response instance @return void
[ "Processes", "the", "request", "by", "invoking", "the", "request", "handler", "that", "executes", "the", "servlet", "in", "a", "protected", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletValve.php#L48-L64
appserver-io/appserver
src/AppserverIo/Appserver/Core/Utilities/LoggerUtils.php
LoggerUtils.log
public static function log($level, $message, array $context = array()) { // query whether or not the application has been registered in the environment if (Environment::singleton()->hasAttribute(EnvironmentKeys::APPLICATION)) { try { // try to load the application system logger Environment::singleton()->getAttribute(EnvironmentKeys::APPLICATION)->search(LoggerUtils::SYSTEM_LOGGER)->log($level, $message, $context); } catch (NamingException $ne) { // load the general system logger and log the message Environment::singleton()->getAttribute(EnvironmentKeys::APPLICATION)->search(LoggerUtils::SYSTEM)->log($level, $message, $context); } } else { // log the message with error_log() method as fallback error_log('Can\'t find a system logger in runtime environment, using error_log() message as fallback'); error_log($message); } }
php
public static function log($level, $message, array $context = array()) { // query whether or not the application has been registered in the environment if (Environment::singleton()->hasAttribute(EnvironmentKeys::APPLICATION)) { try { // try to load the application system logger Environment::singleton()->getAttribute(EnvironmentKeys::APPLICATION)->search(LoggerUtils::SYSTEM_LOGGER)->log($level, $message, $context); } catch (NamingException $ne) { // load the general system logger and log the message Environment::singleton()->getAttribute(EnvironmentKeys::APPLICATION)->search(LoggerUtils::SYSTEM)->log($level, $message, $context); } } else { // log the message with error_log() method as fallback error_log('Can\'t find a system logger in runtime environment, using error_log() message as fallback'); error_log($message); } }
[ "public", "static", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "// query whether or not the application has been registered in the environment", "if", "(", "Environment", "::", "singleto...
Logs with an arbitrary level. @param mixed $level The log level @param string $message The message to log @param array $context The context for log @return void
[ "Logs", "with", "an", "arbitrary", "level", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Utilities/LoggerUtils.php#L54-L72
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.initialize
public function initialize(ApplicationInterface $application) { // register the annotation registries $application->registerAnnotationRegistries(); // parse the object descriptors $this->parseObjectDescriptors(); // register the servlets $this->registerServlets($application); }
php
public function initialize(ApplicationInterface $application) { // register the annotation registries $application->registerAnnotationRegistries(); // parse the object descriptors $this->parseObjectDescriptors(); // register the servlets $this->registerServlets($application); }
[ "public", "function", "initialize", "(", "ApplicationInterface", "$", "application", ")", "{", "// register the annotation registries", "$", "application", "->", "registerAnnotationRegistries", "(", ")", ";", "// parse the object descriptors", "$", "this", "->", "parseObjec...
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/ServletEngine/ServletManager.php#L160-L171
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.registerServlets
public function registerServlets(ApplicationInterface $application) { // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // register the beans located by annotations and the XML configuration /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ foreach ($objectManager->getObjectDescriptors() as $descriptor) { // check if we've found a servlet descriptor and register the servlet if ($descriptor instanceof ServletDescriptorInterface) { $this->registerServlet($descriptor); } } }
php
public function registerServlets(ApplicationInterface $application) { // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER); // register the beans located by annotations and the XML configuration /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ foreach ($objectManager->getObjectDescriptors() as $descriptor) { // check if we've found a servlet descriptor and register the servlet if ($descriptor instanceof ServletDescriptorInterface) { $this->registerServlet($descriptor); } } }
[ "public", "function", "registerServlets", "(", "ApplicationInterface", "$", "application", ")", "{", "// load the object manager instance", "/** @var \\AppserverIo\\Psr\\Di\\ObjectManagerInterface $objectManager */", "$", "objectManager", "=", "$", "this", "->", "getApplication", ...
Finds all servlets which are provided by the webapps and initializes them. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance @return void @throws \AppserverIo\Appserver\ServletEngine\InvalidServletMappingException
[ "Finds", "all", "servlets", "which", "are", "provided", "by", "the", "webapps", "and", "initializes", "them", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletManager.php#L182-L197
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.registerServlet
public function registerServlet(ServletDescriptorInterface $descriptor) { try { // prepend the url-pattern - servlet mapping to the servlet mappings foreach ($descriptor->getUrlPatterns() as $pattern) { $this->addServletMapping($pattern, $descriptor->getName()); } // register's the servlet's references $this->registerReferences($descriptor); } catch (\Exception $e) { // log the exception $this->getApplication()->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
php
public function registerServlet(ServletDescriptorInterface $descriptor) { try { // prepend the url-pattern - servlet mapping to the servlet mappings foreach ($descriptor->getUrlPatterns() as $pattern) { $this->addServletMapping($pattern, $descriptor->getName()); } // register's the servlet's references $this->registerReferences($descriptor); } catch (\Exception $e) { // log the exception $this->getApplication()->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
[ "public", "function", "registerServlet", "(", "ServletDescriptorInterface", "$", "descriptor", ")", "{", "try", "{", "// prepend the url-pattern - servlet mapping to the servlet mappings", "foreach", "(", "$", "descriptor", "->", "getUrlPatterns", "(", ")", "as", "$", "pa...
Register the servlet described by the passed descriptor. @param \AppserverIo\Psr\Servlet\Description\ServletDescriptorInterface $descriptor The servlet descriptor @return void
[ "Register", "the", "servlet", "described", "by", "the", "passed", "descriptor", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletManager.php#L206-L222
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.postStartup
public function postStartup(ApplicationInterface $application) { // register the annotation registries $application->registerAnnotationRegistries(); // 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 ServletDescriptorInterface) { // instantiate the servlet $instance = $this->get($servletName = $descriptor->getName()); // initialize the servlet configuration $servletConfig = new ServletConfiguration(); $servletConfig->injectServletContext($this); $servletConfig->injectServletName($servletName); // append the init params to the servlet configuration foreach ($descriptor->getInitParams() as $paramName => $paramValue) { $servletConfig->addInitParameter($paramName, $paramValue); } // initialize the servlet $instance->init($servletConfig); // the servlet is added to the dictionary using the complete request path as the key $this->addServlet($servletName, $instance); } } }
php
public function postStartup(ApplicationInterface $application) { // register the annotation registries $application->registerAnnotationRegistries(); // 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 ServletDescriptorInterface) { // instantiate the servlet $instance = $this->get($servletName = $descriptor->getName()); // initialize the servlet configuration $servletConfig = new ServletConfiguration(); $servletConfig->injectServletContext($this); $servletConfig->injectServletName($servletName); // append the init params to the servlet configuration foreach ($descriptor->getInitParams() as $paramName => $paramValue) { $servletConfig->addInitParameter($paramName, $paramValue); } // initialize the servlet $instance->init($servletConfig); // the servlet is added to the dictionary using the complete request path as the key $this->addServlet($servletName, $instance); } } }
[ "public", "function", "postStartup", "(", "ApplicationInterface", "$", "application", ")", "{", "// register the annotation registries", "$", "application", "->", "registerAnnotationRegistries", "(", ")", ";", "// load the object manager", "/** @var \\AppserverIo\\Psr\\Di\\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/ServletEngine/ServletManager.php#L232-L267
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.getServlet
public function getServlet($key) { if ($this->servlets->has($key)) { return $this->servlets->get($key); } }
php
public function getServlet($key) { if ($this->servlets->has($key)) { return $this->servlets->get($key); } }
[ "public", "function", "getServlet", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "servlets", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "servlets", "->", "get", "(", "$", "key", ")", ";", "}", "}" ]
Returns the servlet with the passed name. @param string $key The name of the servlet to return @return \AppserverIo\Psr\Servlet\ServletInterface The servlet instance
[ "Returns", "the", "servlet", "with", "the", "passed", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletManager.php#L307-L312
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.getServletByMapping
public function getServletByMapping($urlMapping) { if (isset($this->servletMappings[$urlMapping])) { return $this->getServlet($this->servletMappings[$urlMapping]); } }
php
public function getServletByMapping($urlMapping) { if (isset($this->servletMappings[$urlMapping])) { return $this->getServlet($this->servletMappings[$urlMapping]); } }
[ "public", "function", "getServletByMapping", "(", "$", "urlMapping", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "servletMappings", "[", "$", "urlMapping", "]", ")", ")", "{", "return", "$", "this", "->", "getServlet", "(", "$", "this", "->", ...
Returns the servlet for the passed URL mapping. @param string $urlMapping The URL mapping to return the servlet for @return \AppserverIo\Psr\Servlet\ServletInterface The servlet instance
[ "Returns", "the", "servlet", "for", "the", "passed", "URL", "mapping", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletManager.php#L321-L326
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.getInitParameter
public function getInitParameter($name) { if ($this->initParameters->has($name)) { return $this->initParameters->get($name); } }
php
public function getInitParameter($name) { if ($this->initParameters->has($name)) { return $this->initParameters->get($name); } }
[ "public", "function", "getInitParameter", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "initParameters", "->", "has", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "initParameters", "->", "get", "(", "$", "name", ")", ";"...
Returns the init parameter with the passed name. @param string $name Name of the init parameter to return @return null|string
[ "Returns", "the", "init", "parameter", "with", "the", "passed", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletManager.php#L384-L389
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.getSessionParameter
public function getSessionParameter($name) { if ($this->sessionParameters->has($name)) { return $this->sessionParameters->get($name); } }
php
public function getSessionParameter($name) { if ($this->sessionParameters->has($name)) { return $this->sessionParameters->get($name); } }
[ "public", "function", "getSessionParameter", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "sessionParameters", "->", "has", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "sessionParameters", "->", "get", "(", "$", "name", "...
Returns the session parameter with the passed name. @param string $name Name of the session parameter to return @return null|string
[ "Returns", "the", "session", "parameter", "with", "the", "passed", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletManager.php#L445-L450
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/ServletManager.php
ServletManager.locate
public function locate(HttpServletRequestInterface $servletRequest, array $args = array()) { // load the servlet path => to locate the servlet $servletPath = $servletRequest->getServletPath(); // if a session cookie has been sent, initialize the session manager and the session if ($manager = $this->getApplication()->search(SessionManagerInterface::IDENTIFIER)) { $requestedSessionName = $manager->getSessionSettings()->getSessionName(); if ($servletRequest->hasCookie($requestedSessionName)) { $servletRequest->getCookie($requestedSessionName)->getValue(); } } // return the instance return $this->lookup($servletPath, $args); }
php
public function locate(HttpServletRequestInterface $servletRequest, array $args = array()) { // load the servlet path => to locate the servlet $servletPath = $servletRequest->getServletPath(); // if a session cookie has been sent, initialize the session manager and the session if ($manager = $this->getApplication()->search(SessionManagerInterface::IDENTIFIER)) { $requestedSessionName = $manager->getSessionSettings()->getSessionName(); if ($servletRequest->hasCookie($requestedSessionName)) { $servletRequest->getCookie($requestedSessionName)->getValue(); } } // return the instance return $this->lookup($servletPath, $args); }
[ "public", "function", "locate", "(", "HttpServletRequestInterface", "$", "servletRequest", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "// load the servlet path => to locate the servlet", "$", "servletPath", "=", "$", "servletRequest", "->", "getServl...
Tries to locate the resource related with the request. @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance to return the servlet for @param array $args The arguments passed to the servlet constructor @return \AppserverIo\Psr\Servlet\ServletInterface The requested servlet @see \AppserverIo\Appserver\ServletEngine\ServletLocator::locate()
[ "Tries", "to", "locate", "the", "resource", "related", "with", "the", "request", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/ServletManager.php#L481-L497
appserver-io/appserver
src/AppserverIo/Appserver/Core/Modules/ProfileModule.php
ProfileModule.init
public function init(ServerContextInterface $serverContext) { // initialize the server context $this->serverContext = $serverContext; // initialize the profile logger if ($serverContext->hasLogger(LoggerUtils::PROFILE)) { $this->profileLogger = $serverContext->getLogger(LoggerUtils::PROFILE); } }
php
public function init(ServerContextInterface $serverContext) { // initialize the server context $this->serverContext = $serverContext; // initialize the profile logger if ($serverContext->hasLogger(LoggerUtils::PROFILE)) { $this->profileLogger = $serverContext->getLogger(LoggerUtils::PROFILE); } }
[ "public", "function", "init", "(", "ServerContextInterface", "$", "serverContext", ")", "{", "// initialize the server context", "$", "this", "->", "serverContext", "=", "$", "serverContext", ";", "// initialize the profile logger", "if", "(", "$", "serverContext", "->"...
Initiates the module @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance @return bool @throws \AppserverIo\Server\Exceptions\ModuleException
[ "Initiates", "the", "module" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Modules/ProfileModule.php#L74-L84
appserver-io/appserver
src/AppserverIo/Appserver/Core/Modules/ProfileModule.php
ProfileModule.process
public function process( RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook ) { // profile this request if we've a logger instance if (ModuleHooks::RESPONSE_POST === $hook && $this->profileLogger instanceof ThreadSafeLoggerInterface) { $this->profileLogger->debug($request->getUri()); } }
php
public function process( RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook ) { // profile this request if we've a logger instance if (ModuleHooks::RESPONSE_POST === $hook && $this->profileLogger instanceof ThreadSafeLoggerInterface) { $this->profileLogger->debug($request->getUri()); } }
[ "public", "function", "process", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "RequestContextInterface", "$", "requestContext", ",", "$", "hook", ")", "{", "// profile this request if we've a logger instance", "if", "(", "Modu...
Implement's module logic for given hook @param \AppserverIo\Psr\HttpMessage\RequestInterface $request A request object @param \AppserverIo\Psr\HttpMessage\ResponseInterface $response A response object @param \AppserverIo\Server\Interfaces\RequestContextInterface $requestContext A requests context instance @param int $hook The current hook to process logic for @return bool @throws \AppserverIo\Server\Exceptions\ModuleException
[ "Implement", "s", "module", "logic", "for", "given", "hook" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Modules/ProfileModule.php#L97-L108
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractManager.php
AbstractManager.getAttribute
public function getAttribute($key) { if ($this->data->has($key)) { return $this->data->get($key); } }
php
public function getAttribute($key) { if ($this->data->has($key)) { return $this->data->get($key); } }
[ "public", "function", "getAttribute", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "data", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "data", "->", "get", "(", "$", "key", ")", ";", "}", "}" ]
Returns the attribute with the passed key from the container. @param string $key The key the requested value is registered with @return mixed|null The requested value if available
[ "Returns", "the", "attribute", "with", "the", "passed", "key", "from", "the", "container", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractManager.php#L194-L199
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractManager.php
AbstractManager.newInstance
public function newInstance($className, array $args = array()) { return $this->getApplication()->search(ProviderInterface::IDENTIFIER)->newInstance($className, $args); }
php
public function newInstance($className, array $args = array()) { return $this->getApplication()->search(ProviderInterface::IDENTIFIER)->newInstance($className, $args); }
[ "public", "function", "newInstance", "(", "$", "className", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "getApplication", "(", ")", "->", "search", "(", "ProviderInterface", "::", "IDENTIFIER", ")", "->", "ne...
Returns a new instance of the passed class name. @param string $className The fully qualified class name to return the instance for @param array $args Arguments to pass to the constructor of the instance @return object The instance itself
[ "Returns", "a", "new", "instance", "of", "the", "passed", "class", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractManager.php#L258-L261
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractManager.php
AbstractManager.set
public function set($id, $value) { return $this->getApplication()->search(ProviderInterface::IDENTIFIER)->set($id, $value); }
php
public function set($id, $value) { return $this->getApplication()->search(ProviderInterface::IDENTIFIER)->set($id, $value); }
[ "public", "function", "set", "(", "$", "id", ",", "$", "value", ")", "{", "return", "$", "this", "->", "getApplication", "(", ")", "->", "search", "(", "ProviderInterface", "::", "IDENTIFIER", ")", "->", "set", "(", "$", "id", ",", "$", "value", ")",...
Register's the passed value with the passed ID. @param string $id The ID of the value to add @param string $value The value to add @return void @throws \AppserverIo\Appserver\DependencyInjectionContainer\ContainerException Is thrown, if a value with the passed key has already been added
[ "Register", "s", "the", "passed", "value", "with", "the", "passed", "ID", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractManager.php#L303-L306
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractManager.php
AbstractManager.parseObjectDescriptors
public function parseObjectDescriptors() { // load the manager configuration /** @var \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration */ $managerConfiguration = $this->getManagerConfiguration(); // load the object description configuration $objectDescription = $managerConfiguration->getObjectDescription(); // initialize the parsers and start initializing the object descriptors /** @var \AppserverIo\Appserver\Core\Api\Node\ParserNodeInterface */ foreach ($objectDescription->getParsers() as $parserConfiguration) { // query whether or not a factory has been configured if ($parserFactoryConfiguration = $parserConfiguration->getFactory()) { // create a reflection class from the parser factory $reflectionClass = new ReflectionClass($parserFactoryConfiguration); $factory = $reflectionClass->newInstance(); // create the parser instance and start parsing $parser = $factory->createParser($parserConfiguration, $this); $parser->parse(); } } }
php
public function parseObjectDescriptors() { // load the manager configuration /** @var \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration */ $managerConfiguration = $this->getManagerConfiguration(); // load the object description configuration $objectDescription = $managerConfiguration->getObjectDescription(); // initialize the parsers and start initializing the object descriptors /** @var \AppserverIo\Appserver\Core\Api\Node\ParserNodeInterface */ foreach ($objectDescription->getParsers() as $parserConfiguration) { // query whether or not a factory has been configured if ($parserFactoryConfiguration = $parserConfiguration->getFactory()) { // create a reflection class from the parser factory $reflectionClass = new ReflectionClass($parserFactoryConfiguration); $factory = $reflectionClass->newInstance(); // create the parser instance and start parsing $parser = $factory->createParser($parserConfiguration, $this); $parser->parse(); } } }
[ "public", "function", "parseObjectDescriptors", "(", ")", "{", "// load the manager configuration", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\ManagerNodeInterface $managerConfiguration */", "$", "managerConfiguration", "=", "$", "this", "->", "getManagerConfiguration", "(", ...
Parse the manager's object descriptors. @return void
[ "Parse", "the", "manager", "s", "object", "descriptors", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractManager.php#L337-L361
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/ScannerService.php
ScannerService.findAll
public function findAll() { try { // initialize the array with the CRON instances $cronInstances = array(); // load the service necessary to validate CRON configuration files /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); // load the base CRON configuration file $baseCronPath = $this->getConfdDir('cron.xml'); // we will need to test our CRON configuration files $configurationService->validateFile($baseCronPath, null); // validate the base CRON file and load it as default if validation succeeds $cronInstance = new CronNode(); $cronInstance->initFromFile($baseCronPath); // iterate over all jobs to configure the directory where they has to be executed /** @var \AppserverIo\Appserver\Core\Api\Node\JobNodeInterface $jobNode */ foreach ($cronInstance->getJobs() as $job) { // load the execution information $execute = $job->getExecute(); // query whether or not a base directory has been specified if ($execute && $execute->getDirectory() == null) { // set the directory where the cron.xml file located as base directory, if not $execute->setDirectory(dirname($baseCronPath)); } } // add the default CRON configuration $cronInstances[] = $cronInstance; // iterate over the configured containers /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) { // iterate over all applications and create the CRON configuration foreach (glob($this->getWebappsDir($containerNode) . '/*', GLOB_ONLYDIR) as $webappPath) { // iterate through all CRON configurations (cron.xml), validate and merge them foreach ($this->globDir(AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, 'META-INF/cron')) as $cronFile) { try { // validate the file, but skip it if validation fails $configurationService->validateFile($cronFile, null); // load the system properties $properties = $this->getSystemProperties($containerNode); // append the application specific properties $properties->add(SystemPropertyKeys::WEBAPP, $webappPath); $properties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath)); // create a new CRON node instance and replace the properties $cronInstance = new CronNode(); $cronInstance->initFromFile($cronFile); $cronInstance->replaceProperties($properties); // append it to the other CRON configurations $cronInstances[] = $cronInstance; } catch (ConfigurationException $ce) { // load the logger and log the XML validation errors $systemLogger = $this->getInitialContext()->getSystemLogger(); $systemLogger->error($ce->__toString()); // additionally log a message that CRON configuration will be missing $systemLogger->critical( sprintf('Will skip app specific CRON configuration %s, configuration might be faulty.', $cronFile) ); } } } } } catch (ConfigurationException $ce) { // load the logger and log the XML validation errors $systemLogger = $this->getInitialContext()->getSystemLogger(); $systemLogger->error($ce->__toString()); // additionally log a message that DS will be missing $systemLogger->critical( sprintf('Problems validating base CRON file %s, this might affect app configurations badly.', $baseCronPath) ); } // return the array with the CRON instances return $cronInstances; }
php
public function findAll() { try { // initialize the array with the CRON instances $cronInstances = array(); // load the service necessary to validate CRON configuration files /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); // load the base CRON configuration file $baseCronPath = $this->getConfdDir('cron.xml'); // we will need to test our CRON configuration files $configurationService->validateFile($baseCronPath, null); // validate the base CRON file and load it as default if validation succeeds $cronInstance = new CronNode(); $cronInstance->initFromFile($baseCronPath); // iterate over all jobs to configure the directory where they has to be executed /** @var \AppserverIo\Appserver\Core\Api\Node\JobNodeInterface $jobNode */ foreach ($cronInstance->getJobs() as $job) { // load the execution information $execute = $job->getExecute(); // query whether or not a base directory has been specified if ($execute && $execute->getDirectory() == null) { // set the directory where the cron.xml file located as base directory, if not $execute->setDirectory(dirname($baseCronPath)); } } // add the default CRON configuration $cronInstances[] = $cronInstance; // iterate over the configured containers /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */ foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) { // iterate over all applications and create the CRON configuration foreach (glob($this->getWebappsDir($containerNode) . '/*', GLOB_ONLYDIR) as $webappPath) { // iterate through all CRON configurations (cron.xml), validate and merge them foreach ($this->globDir(AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, 'META-INF/cron')) as $cronFile) { try { // validate the file, but skip it if validation fails $configurationService->validateFile($cronFile, null); // load the system properties $properties = $this->getSystemProperties($containerNode); // append the application specific properties $properties->add(SystemPropertyKeys::WEBAPP, $webappPath); $properties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath)); // create a new CRON node instance and replace the properties $cronInstance = new CronNode(); $cronInstance->initFromFile($cronFile); $cronInstance->replaceProperties($properties); // append it to the other CRON configurations $cronInstances[] = $cronInstance; } catch (ConfigurationException $ce) { // load the logger and log the XML validation errors $systemLogger = $this->getInitialContext()->getSystemLogger(); $systemLogger->error($ce->__toString()); // additionally log a message that CRON configuration will be missing $systemLogger->critical( sprintf('Will skip app specific CRON configuration %s, configuration might be faulty.', $cronFile) ); } } } } } catch (ConfigurationException $ce) { // load the logger and log the XML validation errors $systemLogger = $this->getInitialContext()->getSystemLogger(); $systemLogger->error($ce->__toString()); // additionally log a message that DS will be missing $systemLogger->critical( sprintf('Problems validating base CRON file %s, this might affect app configurations badly.', $baseCronPath) ); } // return the array with the CRON instances return $cronInstances; }
[ "public", "function", "findAll", "(", ")", "{", "try", "{", "// initialize the array with the CRON instances", "$", "cronInstances", "=", "array", "(", ")", ";", "// load the service necessary to validate CRON configuration files", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Con...
Initializes the available CRON configurations and returns them. @return array The array with the available CRON configurations
[ "Initializes", "the", "available", "CRON", "configurations", "and", "returns", "them", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/ScannerService.php#L57-L145
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/ScannerService.php
ScannerService.resolvePath
protected function resolvePath($webappPath, $path = null) { // query whether or not a base directory has been specified if ($path == null) { // set the directory where the cron.xml file located as base directory $path = $webappPath; // query whether or not we found an absolute path or not } elseif ($path != null) { if (strpos($path, '/') > 0) { $path = sprintf('%s/%s', $webappPath, $path); } } // return the resolved path return $path; }
php
protected function resolvePath($webappPath, $path = null) { // query whether or not a base directory has been specified if ($path == null) { // set the directory where the cron.xml file located as base directory $path = $webappPath; // query whether or not we found an absolute path or not } elseif ($path != null) { if (strpos($path, '/') > 0) { $path = sprintf('%s/%s', $webappPath, $path); } } // return the resolved path return $path; }
[ "protected", "function", "resolvePath", "(", "$", "webappPath", ",", "$", "path", "=", "null", ")", "{", "// query whether or not a base directory has been specified", "if", "(", "$", "path", "==", "null", ")", "{", "// set the directory where the cron.xml file located as...
Resolves the passed path. If the passed path is NULL, the webapp path is used, if the passed path is relative, the webapp path is prepended. @param string $webappPath The absolute path to the webapp @param string $path The path to be resolved @return string The resolved path
[ "Resolves", "the", "passed", "path", ".", "If", "the", "passed", "path", "is", "NULL", "the", "webapp", "path", "is", "used", "if", "the", "passed", "path", "is", "relative", "the", "webapp", "path", "is", "prepended", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/ScannerService.php#L156-L173
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimedObjectInvoker.php
TimedObjectInvoker.getMethodAnnotation
public function getMethodAnnotation(MethodInterface $reflectionMethod, $annotationName) { return $this->getAnnotationReader()->getMethodAnnotation($reflectionMethod->toPhpReflectionMethod(), $annotationName); }
php
public function getMethodAnnotation(MethodInterface $reflectionMethod, $annotationName) { return $this->getAnnotationReader()->getMethodAnnotation($reflectionMethod->toPhpReflectionMethod(), $annotationName); }
[ "public", "function", "getMethodAnnotation", "(", "MethodInterface", "$", "reflectionMethod", ",", "$", "annotationName", ")", "{", "return", "$", "this", "->", "getAnnotationReader", "(", ")", "->", "getMethodAnnotation", "(", "$", "reflectionMethod", "->", "toPhpR...
Return's the method annotation with the passed name, if available. @param \AppserverIo\Lang\Reflection\MethodInterface $reflectionMethod The reflection method to return the annotation for @param string $annotationName The name of the annotation to return @return object|null The method annotation, or NULL if not available
[ "Return", "s", "the", "method", "annotation", "with", "the", "passed", "name", "if", "available", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimedObjectInvoker.php#L94-L97
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimedObjectInvoker.php
TimedObjectInvoker.callTimeout
public function callTimeout(TimerInterface $timer, MethodInterface $timeoutMethod = null) { try { // synchronize the application instance and register the class loaders $application = $this->getApplication(); $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // initialize the initial context instance $initialContext = new InitialContext(); $initialContext->injectApplication($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); // log a message with the timed object information \info(sprintf('Now invoke timed object "%s" with session ID "%s"', $this->getTimedObjectId(), $sessionId)); // lookup the enterprise bean using the initial context $instance = $initialContext->lookup($this->getTimedObjectId()); // check if the timeout method has been passed if ($timeoutMethod != null) { // if yes, invoke it on the proxy $callback = array($instance, $timeoutMethod->getMethodName()); call_user_func_array($callback, array($timer)); return; } // check if we've a default timeout method if ($this->defaultTimeoutMethod != null) { // if yes, invoke it on the proxy $callback = array($instance, $this->defaultTimeoutMethod->getMethodName()); call_user_func_array($callback, array($timer)); return; } } catch (\Exception $e) { error_log($e->__toString()); } }
php
public function callTimeout(TimerInterface $timer, MethodInterface $timeoutMethod = null) { try { // synchronize the application instance and register the class loaders $application = $this->getApplication(); $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // initialize the initial context instance $initialContext = new InitialContext(); $initialContext->injectApplication($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); // log a message with the timed object information \info(sprintf('Now invoke timed object "%s" with session ID "%s"', $this->getTimedObjectId(), $sessionId)); // lookup the enterprise bean using the initial context $instance = $initialContext->lookup($this->getTimedObjectId()); // check if the timeout method has been passed if ($timeoutMethod != null) { // if yes, invoke it on the proxy $callback = array($instance, $timeoutMethod->getMethodName()); call_user_func_array($callback, array($timer)); return; } // check if we've a default timeout method if ($this->defaultTimeoutMethod != null) { // if yes, invoke it on the proxy $callback = array($instance, $this->defaultTimeoutMethod->getMethodName()); call_user_func_array($callback, array($timer)); return; } } catch (\Exception $e) { error_log($e->__toString()); } }
[ "public", "function", "callTimeout", "(", "TimerInterface", "$", "timer", ",", "MethodInterface", "$", "timeoutMethod", "=", "null", ")", "{", "try", "{", "// synchronize the application instance and register the class loaders", "$", "application", "=", "$", "this", "->...
Responsible for invoking the timeout method on the target object. The timerservice implementation invokes this method as a callback when a timeout occurs for the passed timer. The timerservice implementation will be responsible for passing the correct timeout method corresponding to the <code>timer</code> on which the timeout has occurred. @param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer The timer that is passed to timeout @param \AppserverIo\Lang\Reflection\MethodInterface $timeoutMethod The timeout method @return void
[ "Responsible", "for", "invoking", "the", "timeout", "method", "on", "the", "target", "object", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimedObjectInvoker.php#L187-L234
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/TimedObjectInvoker.php
TimedObjectInvoker.start
public function start() { // create a reflection object instance of the timed object $reflectionClass = $this->getTimedObject(); // first check if the bean implements the timed object interface => so we've a default timeout method if ($reflectionClass->implementsInterface('AppserverIo\Psr\EnterpriseBeans\TimedObjectInterface')) { $this->defaultTimeoutMethod = $reflectionClass->getMethod(TimedObjectInterface::DEFAULT_TIMEOUT_METHOD); } // check the methods of the bean for a @Timeout annotation => overwrite the default // timeout method defined by the interface /** @var \AppserverIo\Lang\Reflection\MethodInterface $timeoutMethod */ foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $timeoutMethod) { // check if the timed object instance has @Timeout annotation => default timeout method if ($this->getMethodAnnotation($timeoutMethod, Timeout::class)) { $this->defaultTimeoutMethod = $timeoutMethod; } // check if the timed object instance has @Schedule annotation if ($this->getMethodAnnotation($timeoutMethod, Schedule::class)) { $this->timeoutMethods[$timeoutMethod->getMethodName()] = $timeoutMethod; } } }
php
public function start() { // create a reflection object instance of the timed object $reflectionClass = $this->getTimedObject(); // first check if the bean implements the timed object interface => so we've a default timeout method if ($reflectionClass->implementsInterface('AppserverIo\Psr\EnterpriseBeans\TimedObjectInterface')) { $this->defaultTimeoutMethod = $reflectionClass->getMethod(TimedObjectInterface::DEFAULT_TIMEOUT_METHOD); } // check the methods of the bean for a @Timeout annotation => overwrite the default // timeout method defined by the interface /** @var \AppserverIo\Lang\Reflection\MethodInterface $timeoutMethod */ foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $timeoutMethod) { // check if the timed object instance has @Timeout annotation => default timeout method if ($this->getMethodAnnotation($timeoutMethod, Timeout::class)) { $this->defaultTimeoutMethod = $timeoutMethod; } // check if the timed object instance has @Schedule annotation if ($this->getMethodAnnotation($timeoutMethod, Schedule::class)) { $this->timeoutMethods[$timeoutMethod->getMethodName()] = $timeoutMethod; } } }
[ "public", "function", "start", "(", ")", "{", "// create a reflection object instance of the timed object", "$", "reflectionClass", "=", "$", "this", "->", "getTimedObject", "(", ")", ";", "// first check if the bean implements the timed object interface => so we've a default timeo...
Initializes the timed object invoker with the methods annotated with the @Timeout or @Schedule annotation. @return void
[ "Initializes", "the", "timed", "object", "invoker", "with", "the", "methods", "annotated", "with", "the", "@Timeout", "or", "@Schedule", "annotation", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/TimedObjectInvoker.php#L242-L267
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/VirtualHostService.php
VirtualHostService.findAll
public function findAll() { $virtualHostNodes = array(); foreach ($this->getSystemConfiguration()->getContainers() as $containerNodes) { foreach ($containerNodes->getServers() as $serverNode) { foreach ($serverNode->getVirtualHosts() as $virtualHostNode) { $virtualHostNodes[$virtualHostNode->getPrimaryKey()] = $virtualHostNode; } } } return $virtualHostNodes; }
php
public function findAll() { $virtualHostNodes = array(); foreach ($this->getSystemConfiguration()->getContainers() as $containerNodes) { foreach ($containerNodes->getServers() as $serverNode) { foreach ($serverNode->getVirtualHosts() as $virtualHostNode) { $virtualHostNodes[$virtualHostNode->getPrimaryKey()] = $virtualHostNode; } } } return $virtualHostNodes; }
[ "public", "function", "findAll", "(", ")", "{", "$", "virtualHostNodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getContainers", "(", ")", "as", "$", "containerNodes", ")", "{", "foreach", ...
Returns all configured virtual hosts. @return array All configured virtual hosts @see \AppserverIo\Psr\ApplicationServer\ServiceInterface::findAll()
[ "Returns", "all", "configured", "virtual", "hosts", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/VirtualHostService.php#L41-L52
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/VirtualHostService.php
VirtualHostService.load
public function load($uuid) { foreach ($this->findAll() as $virtualHostNode) { if ($virtualHostNode->getPrimaryKey() == $uuid) { return $virtualHostNode; } } }
php
public function load($uuid) { foreach ($this->findAll() as $virtualHostNode) { if ($virtualHostNode->getPrimaryKey() == $uuid) { return $virtualHostNode; } } }
[ "public", "function", "load", "(", "$", "uuid", ")", "{", "foreach", "(", "$", "this", "->", "findAll", "(", ")", "as", "$", "virtualHostNode", ")", "{", "if", "(", "$", "virtualHostNode", "->", "getPrimaryKey", "(", ")", "==", "$", "uuid", ")", "{",...
Returns the virtual host with the passed UUID. @param string $uuid UUID of the virtual host to return @return \AppserverIo\Appserver\Core\Api\Node\VirtualHostNode|null The virtual host with the UUID passed as parameter @see \AppserverIo\Psr\ApplicationServer\ServiceInterface::load()
[ "Returns", "the", "virtual", "host", "with", "the", "passed", "UUID", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/VirtualHostService.php#L62-L69
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getBaseDirectory
public function getBaseDirectory($directoryToAppend = null) { // load the base directory from the system configuration $baseDirectory = $this->getSystemConfiguration()->getBaseDirectory(); // if a directory has been passed, make it absolute and append it if ($directoryToAppend != null) { $baseDirectory .= $this->makePathAbsolute($directoryToAppend); } // return the base directory, with the passed path appended return $baseDirectory; }
php
public function getBaseDirectory($directoryToAppend = null) { // load the base directory from the system configuration $baseDirectory = $this->getSystemConfiguration()->getBaseDirectory(); // if a directory has been passed, make it absolute and append it if ($directoryToAppend != null) { $baseDirectory .= $this->makePathAbsolute($directoryToAppend); } // return the base directory, with the passed path appended return $baseDirectory; }
[ "public", "function", "getBaseDirectory", "(", "$", "directoryToAppend", "=", "null", ")", "{", "// load the base directory from the system configuration", "$", "baseDirectory", "=", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getBaseDirectory", "(", "...
Returns the application servers base directory. @param string|null $directoryToAppend Append this directory to the base directory before returning it @return string The base directory
[ "Returns", "the", "application", "servers", "base", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L156-L169
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getDirectories
public function getDirectories() { // initialize the array with the directories $directories = array(); // iterate over the directory keys and read the configuration values foreach (DirectoryKeys::getServerDirectoryKeys() as $directoryKey) { $directories[$directoryKey] = $this->getSystemConfiguration()->getParam($directoryKey); } // return the array with the directories return $directories; }
php
public function getDirectories() { // initialize the array with the directories $directories = array(); // iterate over the directory keys and read the configuration values foreach (DirectoryKeys::getServerDirectoryKeys() as $directoryKey) { $directories[$directoryKey] = $this->getSystemConfiguration()->getParam($directoryKey); } // return the array with the directories return $directories; }
[ "public", "function", "getDirectories", "(", ")", "{", "// initialize the array with the directories", "$", "directories", "=", "array", "(", ")", ";", "// iterate over the directory keys and read the configuration values", "foreach", "(", "DirectoryKeys", "::", "getServerDirec...
Returns the directory structure to be created at first start. @return array The directory structure to be created if necessary
[ "Returns", "the", "directory", "structure", "to", "be", "created", "at", "first", "start", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L176-L189
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getFiles
public function getFiles() { // initialize the array with the files $files = array(); // iterate over the file keys and read the configuration values foreach (FileKeys::getServerFileKeys() as $fileKey) { $files[$fileKey] = $this->getSystemConfiguration()->getParam($fileKey); } // return the array with the files return $files; }
php
public function getFiles() { // initialize the array with the files $files = array(); // iterate over the file keys and read the configuration values foreach (FileKeys::getServerFileKeys() as $fileKey) { $files[$fileKey] = $this->getSystemConfiguration()->getParam($fileKey); } // return the array with the files return $files; }
[ "public", "function", "getFiles", "(", ")", "{", "// initialize the array with the files", "$", "files", "=", "array", "(", ")", ";", "// iterate over the file keys and read the configuration values", "foreach", "(", "FileKeys", "::", "getServerFileKeys", "(", ")", "as", ...
Returns the files to be created at first start. @return array The files to be created if necessary
[ "Returns", "the", "files", "to", "be", "created", "at", "first", "start", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L196-L209
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.makePathAbsolute
public function makePathAbsolute($path = '') { if (empty($path) === false) { return DIRECTORY_SEPARATOR . trim(DirectoryKeys::realpath($path), DIRECTORY_SEPARATOR); } }
php
public function makePathAbsolute($path = '') { if (empty($path) === false) { return DIRECTORY_SEPARATOR . trim(DirectoryKeys::realpath($path), DIRECTORY_SEPARATOR); } }
[ "public", "function", "makePathAbsolute", "(", "$", "path", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "path", ")", "===", "false", ")", "{", "return", "DIRECTORY_SEPARATOR", ".", "trim", "(", "DirectoryKeys", "::", "realpath", "(", "$", "path", ...
Makes the path an absolute path or returns null if passed path is empty. @param string $path A path to absolute @return string The absolute path
[ "Makes", "the", "path", "an", "absolute", "path", "or", "returns", "null", "if", "passed", "path", "is", "empty", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L218-L223
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getTmpDir
public function getTmpDir(ContainerConfigurationInterface $containerNode, $relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $containerNode->getHost()->getTmpBase() . $this->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getTmpDir(ContainerConfigurationInterface $containerNode, $relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $containerNode->getHost()->getTmpBase() . $this->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getTmpDir", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "realpath", "(", "$", "this", "->", "makePathAbsolute", "(", "$", "containerNode", ...
Returns the servers tmp directory, append with the passed 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
[ "Returns", "the", "servers", "tmp", "directory", "append", "with", "the", "passed", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L233-L240
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getDeployDir
public function getDeployDir(ContainerConfigurationInterface $containerNode, $relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $containerNode->getHost()->getDeployBase() . $this->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getDeployDir(ContainerConfigurationInterface $containerNode, $relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $containerNode->getHost()->getDeployBase() . $this->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getDeployDir", "(", "ContainerConfigurationInterface", "$", "containerNode", ",", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "realpath", "(", "$", "this", "->", "makePathAbsolute", "(", "$", "containerNode...
Returns the servers deploy directory. @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode The container to return the deployment directory for @param string $relativePathToAppend A relative path to append @return string
[ "Returns", "the", "servers", "deploy", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L250-L257
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getLogDir
public function getLogDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::VAR_LOG) . $this->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getLogDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::VAR_LOG) . $this->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getLogDir", "(", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "realpath", "(", "$", "this", "->", "makePathAbsolute", "(", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getParam", "(", ...
Returns the servers log directory. @param string $relativePathToAppend A relative path to append @return string
[ "Returns", "the", "servers", "log", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L283-L290
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getVendorDir
public function getVendorDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::VENDOR) . $this->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getVendorDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::VENDOR) . $this->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getVendorDir", "(", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "realpath", "(", "$", "this", "->", "makePathAbsolute", "(", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getParam", "(...
Return's the system's vendor directory. @param string $relativePathToAppend A relative path to append @return string The system's vendor directory
[ "Return", "s", "the", "system", "s", "vendor", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L309-L316
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getSystemTmpDir
public function getSystemTmpDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::TMP) . $this->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getSystemTmpDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::TMP) . $this->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getSystemTmpDir", "(", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "realpath", "(", "$", "this", "->", "makePathAbsolute", "(", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getParam", ...
Return's the system's temporary directory. @param string $relativePathToAppend A relative path to append @return string The system's temporary directory
[ "Return", "s", "the", "system", "s", "temporary", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L325-L332
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getEtcDir
public function getEtcDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::ETC) . $this->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getEtcDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::ETC) . $this->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getEtcDir", "(", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "realpath", "(", "$", "this", "->", "makePathAbsolute", "(", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getParam", "(", ...
Return's the server's base configuration directory. @param string $relativePathToAppend A relative path to append @return string The server's base configuration directory
[ "Return", "s", "the", "server", "s", "base", "configuration", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L341-L348
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getConfDir
public function getConfDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::ETC_APPSERVER) . $this->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getConfDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::ETC_APPSERVER) . $this->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getConfDir", "(", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "realpath", "(", "$", "this", "->", "makePathAbsolute", "(", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getParam", "(",...
Return's the server's main configuration directory. @param string $relativePathToAppend A relative path to append @return string The server's main configuration directory
[ "Return", "s", "the", "server", "s", "main", "configuration", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L357-L364
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getConfdDir
public function getConfdDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::ETC_APPSERVER_CONFD) . $this->makePathAbsolute($relativePathToAppend) ) ); }
php
public function getConfdDir($relativePathToAppend = '') { return $this->realpath( $this->makePathAbsolute( $this->getSystemConfiguration()->getParam(DirectoryKeys::ETC_APPSERVER_CONFD) . $this->makePathAbsolute($relativePathToAppend) ) ); }
[ "public", "function", "getConfdDir", "(", "$", "relativePathToAppend", "=", "''", ")", "{", "return", "$", "this", "->", "realpath", "(", "$", "this", "->", "makePathAbsolute", "(", "$", "this", "->", "getSystemConfiguration", "(", ")", "->", "getParam", "("...
Return's the server's configuration subdirectory. @param string $relativePathToAppend A relative path to append @return string The server's configuration subdirectory
[ "Return", "s", "the", "server", "s", "configuration", "subdirectory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L373-L380
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.globDir
public function globDir($pattern, $flags = 0, $recursive = true) { return FileSystem::globDir($pattern, $flags, $recursive); }
php
public function globDir($pattern, $flags = 0, $recursive = true) { return FileSystem::globDir($pattern, $flags, $recursive); }
[ "public", "function", "globDir", "(", "$", "pattern", ",", "$", "flags", "=", "0", ",", "$", "recursive", "=", "true", ")", "{", "return", "FileSystem", "::", "globDir", "(", "$", "pattern", ",", "$", "flags", ",", "$", "recursive", ")", ";", "}" ]
Parses and returns the directories and files that matches the passed glob pattern in a recursive way (if wanted). @param string $pattern The glob pattern used to parse the directories @param integer $flags The flags passed to the glob function @param boolean $recursive Whether or not to parse directories recursively @return array The directories matches the passed glob pattern @link http://php.net/glob
[ "Parses", "and", "returns", "the", "directories", "and", "files", "that", "matches", "the", "passed", "glob", "pattern", "in", "a", "recursive", "way", "(", "if", "wanted", ")", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L420-L423
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getServerSignature
public function getServerSignature() { // try to load the OS identifier list($os, ) = sscanf(strtolower(php_uname('s')), '%s %s'); // check if we've a file with the actual version number if (file_exists($filename = $this->getConfDir('/.release-version'))) { $version = file_get_contents($filename); } else { $version = 'dev-' . gethostname(); } // prepare and return the server signature return sprintf('appserver/%s (%s) PHP/%s', $version, $os, PHP_VERSION); }
php
public function getServerSignature() { // try to load the OS identifier list($os, ) = sscanf(strtolower(php_uname('s')), '%s %s'); // check if we've a file with the actual version number if (file_exists($filename = $this->getConfDir('/.release-version'))) { $version = file_get_contents($filename); } else { $version = 'dev-' . gethostname(); } // prepare and return the server signature return sprintf('appserver/%s (%s) PHP/%s', $version, $os, PHP_VERSION); }
[ "public", "function", "getServerSignature", "(", ")", "{", "// try to load the OS identifier", "list", "(", "$", "os", ",", ")", "=", "sscanf", "(", "strtolower", "(", "php_uname", "(", "'s'", ")", ")", ",", "'%s %s'", ")", ";", "// check if we've a file with th...
Returns the real server signature depending on the installed appserver version and the PHP version we're running on, for example: appserver/1.0.1-45 (darwin) PHP/5.5.21 @return string The server signature
[ "Returns", "the", "real", "server", "signature", "depending", "on", "the", "installed", "appserver", "version", "and", "the", "PHP", "version", "we", "re", "running", "on", "for", "example", ":" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L434-L449
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/AbstractService.php
AbstractService.getSystemProperties
public function getSystemProperties(ContainerConfigurationInterface $containerNode = null, ApplicationInterface $application = null) { // initialize the properties $properties = Properties::create(); // append the system properties $properties->add(SystemPropertyKeys::BASE, $this->getBaseDirectory()); $properties->add(SystemPropertyKeys::VAR_LOG, $this->getLogDir()); $properties->add(SystemPropertyKeys::ETC, $this->getEtcDir()); $properties->add(SystemPropertyKeys::VENDOR, $this->getVendorDir()); $properties->add(SystemPropertyKeys::ETC_APPSERVER, $this->getConfDir()); $properties->add(SystemPropertyKeys::ETC_APPSERVER_CONFD, $this->getConfdDir()); // append the declared system propertie /** @var \AppserverIo\Appserver\Core\Api\Node\SystemPropertyNode $systemProperty */ foreach ($this->getSystemConfiguration()->getSystemProperties() as $systemProperty) { $properties->add($systemProperty->getName(), $systemProperty->castToType()); } // query whether or not a container node has been passed if ($containerNode != null) { // append the container specific properties $properties->add(SystemPropertyKeys::TMP, $this->getTmpDir($containerNode)); $properties->add(SystemPropertyKeys::CONTAINER_NAME, $containerNode->getName()); $properties->add(SystemPropertyKeys::WEBAPPS, $this->getWebappsDir($containerNode)); // append the host specific system properties if ($host = $containerNode->getHost()) { $properties->add(SystemPropertyKeys::HOST_APP_BASE, $host->getAppBase()); $properties->add(SystemPropertyKeys::HOST_TMP_BASE, $host->getTmpBase()); $properties->add(SystemPropertyKeys::HOST_DEPLOY_BASE, $host->getDeployBase()); } } // query whether or not an application instance has been passed if ($application != null) { // append the application specific properties $properties->add(SystemPropertyKeys::WEBAPP, $webappPath = $application->getWebappPath()); $properties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath)); $properties->add(SystemPropertyKeys::WEBAPP_DATA, $application->getDataDir()); $properties->add(SystemPropertyKeys::WEBAPP_CACHE, $application->getCacheDir()); $properties->add(SystemPropertyKeys::WEBAPP_SESSION, $application->getSessionDir()); } // return the properties return $properties; }
php
public function getSystemProperties(ContainerConfigurationInterface $containerNode = null, ApplicationInterface $application = null) { // initialize the properties $properties = Properties::create(); // append the system properties $properties->add(SystemPropertyKeys::BASE, $this->getBaseDirectory()); $properties->add(SystemPropertyKeys::VAR_LOG, $this->getLogDir()); $properties->add(SystemPropertyKeys::ETC, $this->getEtcDir()); $properties->add(SystemPropertyKeys::VENDOR, $this->getVendorDir()); $properties->add(SystemPropertyKeys::ETC_APPSERVER, $this->getConfDir()); $properties->add(SystemPropertyKeys::ETC_APPSERVER_CONFD, $this->getConfdDir()); // append the declared system propertie /** @var \AppserverIo\Appserver\Core\Api\Node\SystemPropertyNode $systemProperty */ foreach ($this->getSystemConfiguration()->getSystemProperties() as $systemProperty) { $properties->add($systemProperty->getName(), $systemProperty->castToType()); } // query whether or not a container node has been passed if ($containerNode != null) { // append the container specific properties $properties->add(SystemPropertyKeys::TMP, $this->getTmpDir($containerNode)); $properties->add(SystemPropertyKeys::CONTAINER_NAME, $containerNode->getName()); $properties->add(SystemPropertyKeys::WEBAPPS, $this->getWebappsDir($containerNode)); // append the host specific system properties if ($host = $containerNode->getHost()) { $properties->add(SystemPropertyKeys::HOST_APP_BASE, $host->getAppBase()); $properties->add(SystemPropertyKeys::HOST_TMP_BASE, $host->getTmpBase()); $properties->add(SystemPropertyKeys::HOST_DEPLOY_BASE, $host->getDeployBase()); } } // query whether or not an application instance has been passed if ($application != null) { // append the application specific properties $properties->add(SystemPropertyKeys::WEBAPP, $webappPath = $application->getWebappPath()); $properties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath)); $properties->add(SystemPropertyKeys::WEBAPP_DATA, $application->getDataDir()); $properties->add(SystemPropertyKeys::WEBAPP_CACHE, $application->getCacheDir()); $properties->add(SystemPropertyKeys::WEBAPP_SESSION, $application->getSessionDir()); } // return the properties return $properties; }
[ "public", "function", "getSystemProperties", "(", "ContainerConfigurationInterface", "$", "containerNode", "=", "null", ",", "ApplicationInterface", "$", "application", "=", "null", ")", "{", "// initialize the properties", "$", "properties", "=", "Properties", "::", "c...
Returns the system proprties. If a container node has been passed, the container properties will also be appended. @param \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface|null $containerNode The container to return the system properties for @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance @return \AppserverIo\Properties\Properties The system properties
[ "Returns", "the", "system", "proprties", ".", "If", "a", "container", "node", "has", "been", "passed", "the", "container", "properties", "will", "also", "be", "appended", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/AbstractService.php#L460-L507
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php
StandardSessionManager.initialize
public function initialize(ApplicationInterface $application) { // load the servlet manager with the session settings configured in web.xml /** @var \AppserverIo\Psr\Servlet\ServletContextInterface|\AppserverIo\Psr\Application\ManagerInterface $servletManager */ $servletManager = $application->search(ServletContextInterface::IDENTIFIER); // load the settings, set the default session save path $sessionSettings = $this->getSessionSettings(); $sessionSettings->setSessionSavePath($application->getSessionDir()); // if we've session parameters defined in our servlet context if ($servletManager->hasSessionParameters()) { // we want to merge the session settings from the servlet context $sessionSettings->mergeServletContext($servletManager); } }
php
public function initialize(ApplicationInterface $application) { // load the servlet manager with the session settings configured in web.xml /** @var \AppserverIo\Psr\Servlet\ServletContextInterface|\AppserverIo\Psr\Application\ManagerInterface $servletManager */ $servletManager = $application->search(ServletContextInterface::IDENTIFIER); // load the settings, set the default session save path $sessionSettings = $this->getSessionSettings(); $sessionSettings->setSessionSavePath($application->getSessionDir()); // if we've session parameters defined in our servlet context if ($servletManager->hasSessionParameters()) { // we want to merge the session settings from the servlet context $sessionSettings->mergeServletContext($servletManager); } }
[ "public", "function", "initialize", "(", "ApplicationInterface", "$", "application", ")", "{", "// load the servlet manager with the session settings configured in web.xml", "/** @var \\AppserverIo\\Psr\\Servlet\\ServletContextInterface|\\AppserverIo\\Psr\\Application\\ManagerInterface $servletM...
Initializes the session manager. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance @return void @see \AppserverIo\Psr\Application\ManagerInterface::initialize()
[ "Initializes", "the", "session", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php#L318-L334
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php
StandardSessionManager.create
public function create( $id, $name, $lifetime = null, $maximumAge = null, $domain = null, $path = null, $secure = null, $httpOnly = null ) { // copy the default session configuration for lifetime from the settings if ($lifetime == null) { $lifetime = time() + $this->getSessionSettings()->getSessionCookieLifetime(); } // copy the default session configuration for maximum from the settings if ($maximumAge == null) { $maximumAge = $this->getSessionSettings()->getSessionMaximumAge(); } // copy the default session configuration for cookie domain from the settings if ($domain == null) { $domain = $this->getSessionSettings()->getSessionCookieDomain(); } // copy the default session configuration for the cookie path from the settings if ($path == null) { $path = $this->getSessionSettings()->getSessionCookiePath(); } // copy the default session configuration for the secure flag from the settings if ($secure == null) { $secure = $this->getSessionSettings()->getSessionCookieSecure(); } // copy the default session configuration for the http only flag from the settings if ($httpOnly == null) { $httpOnly = $this->getSessionSettings()->getSessionCookieHttpOnly(); } // initialize and return the session instance $session = Session::emptyInstance(); $session->init($id, $name, $lifetime, $maximumAge, $domain, $path, $secure, $httpOnly); // attach the session to the manager $this->attach($session); // return the session return $session; }
php
public function create( $id, $name, $lifetime = null, $maximumAge = null, $domain = null, $path = null, $secure = null, $httpOnly = null ) { // copy the default session configuration for lifetime from the settings if ($lifetime == null) { $lifetime = time() + $this->getSessionSettings()->getSessionCookieLifetime(); } // copy the default session configuration for maximum from the settings if ($maximumAge == null) { $maximumAge = $this->getSessionSettings()->getSessionMaximumAge(); } // copy the default session configuration for cookie domain from the settings if ($domain == null) { $domain = $this->getSessionSettings()->getSessionCookieDomain(); } // copy the default session configuration for the cookie path from the settings if ($path == null) { $path = $this->getSessionSettings()->getSessionCookiePath(); } // copy the default session configuration for the secure flag from the settings if ($secure == null) { $secure = $this->getSessionSettings()->getSessionCookieSecure(); } // copy the default session configuration for the http only flag from the settings if ($httpOnly == null) { $httpOnly = $this->getSessionSettings()->getSessionCookieHttpOnly(); } // initialize and return the session instance $session = Session::emptyInstance(); $session->init($id, $name, $lifetime, $maximumAge, $domain, $path, $secure, $httpOnly); // attach the session to the manager $this->attach($session); // return the session return $session; }
[ "public", "function", "create", "(", "$", "id", ",", "$", "name", ",", "$", "lifetime", "=", "null", ",", "$", "maximumAge", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "path", "=", "null", ",", "$", "secure", "=", "null", ",", "$", ...
Creates a new session with the passed session ID and session name if given. @param mixed $id The session ID @param string $name The session name @param integer|\DateTime $lifetime Date and time after the session expires @param integer|null $maximumAge Number of seconds until the session expires @param string|null $domain The host to which the user agent will send this cookie @param string $path The path describing the scope of this cookie @param boolean $secure If this cookie should only be sent through a "secure" channel by the user agent @param boolean $httpOnly If this cookie should only be used through the HTTP protocol @return \AppserverIo\Psr\Servlet\ServletSessionInterface The requested session
[ "Creates", "a", "new", "session", "with", "the", "passed", "session", "ID", "and", "session", "name", "if", "given", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php#L350-L400
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php
StandardSessionManager.find
public function find($id) { // return immediately if the requested session ID is empty if (empty($id)) { return; } // declare the session variable $session = null; // query whether or not the session with the passed ID exists if ($this->getSessions()->exists($id)) { $session = $this->getSessions()->get($id); } else { // iterate over the session handlers and try to un-persist the session /** @var \AppserverIo\Appserver\ServletEngine\Session\SessionHandlerInterface $sessionHandler */ foreach ($this->getSessionHandlers() as $sessionHandler) { try { if ($session = $sessionHandler->load($id)) { $this->attach($session); break; } } catch (\Exception $e) { // log the exception if a system logger is available if ($logger = $this->getLogger(LoggerUtils::SYSTEM)) { // log the error message $logger->error(sprintf('Can\'t load session data for session with ID "%s" because of: "%s"', $id, $e->getMessage())); // log the stack trace in debug log level $logger->debug($e->__toString()); } } } } // if we found a session, we've to check if it can be resumed if ($session instanceof ServletSessionInterface) { if ($session->canBeResumed()) { $session->resume(); return $session; } } }
php
public function find($id) { // return immediately if the requested session ID is empty if (empty($id)) { return; } // declare the session variable $session = null; // query whether or not the session with the passed ID exists if ($this->getSessions()->exists($id)) { $session = $this->getSessions()->get($id); } else { // iterate over the session handlers and try to un-persist the session /** @var \AppserverIo\Appserver\ServletEngine\Session\SessionHandlerInterface $sessionHandler */ foreach ($this->getSessionHandlers() as $sessionHandler) { try { if ($session = $sessionHandler->load($id)) { $this->attach($session); break; } } catch (\Exception $e) { // log the exception if a system logger is available if ($logger = $this->getLogger(LoggerUtils::SYSTEM)) { // log the error message $logger->error(sprintf('Can\'t load session data for session with ID "%s" because of: "%s"', $id, $e->getMessage())); // log the stack trace in debug log level $logger->debug($e->__toString()); } } } } // if we found a session, we've to check if it can be resumed if ($session instanceof ServletSessionInterface) { if ($session->canBeResumed()) { $session->resume(); return $session; } } }
[ "public", "function", "find", "(", "$", "id", ")", "{", "// return immediately if the requested session ID is empty", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", ";", "}", "// declare the session variable", "$", "session", "=", "null", ";", "// ...
Tries to find a session for the given request. The session-ID will be searched in the cookie header of the request, and in the request query string. If both values are present, the value in the query string takes precedence. If no session id is found, a new one is created and assigned to the request. @param string $id The unique session ID to that has to be returned @return \AppserverIo\Psr\Servlet\ServletSessionInterface|null The requested session
[ "Tries", "to", "find", "a", "session", "for", "the", "given", "request", ".", "The", "session", "-", "ID", "will", "be", "searched", "in", "the", "cookie", "header", "of", "the", "request", "and", "in", "the", "request", "query", "string", ".", "If", "...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php#L427-L471
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php
StandardSessionManager.flush
public function flush() { // persist all sessions /** @var \AppserverIo\Psr\Servlet\ServletSessionInterface $session */ foreach ($this->getSessions() as $session) { // iterate over the session handlers and persist the sessions /** @var \AppserverIo\Appserver\ServletEngine\Session\SessionHandlerInterface $sessionHandler */ foreach ($this->getSessionHandlers() as $sessionHandler) { try { $sessionHandler->save($session); } catch (\Exception $e) { // log the exception if a system logger is available if ($logger = $this->getLogger(LoggerUtils::SYSTEM)) { $logger->error($e->__toString()); } } } } }
php
public function flush() { // persist all sessions /** @var \AppserverIo\Psr\Servlet\ServletSessionInterface $session */ foreach ($this->getSessions() as $session) { // iterate over the session handlers and persist the sessions /** @var \AppserverIo\Appserver\ServletEngine\Session\SessionHandlerInterface $sessionHandler */ foreach ($this->getSessionHandlers() as $sessionHandler) { try { $sessionHandler->save($session); } catch (\Exception $e) { // log the exception if a system logger is available if ($logger = $this->getLogger(LoggerUtils::SYSTEM)) { $logger->error($e->__toString()); } } } } }
[ "public", "function", "flush", "(", ")", "{", "// persist all sessions", "/** @var \\AppserverIo\\Psr\\Servlet\\ServletSessionInterface $session */", "foreach", "(", "$", "this", "->", "getSessions", "(", ")", "as", "$", "session", ")", "{", "// iterate over the session han...
Flushes the session storage and persists all sessions. @return void
[ "Flushes", "the", "session", "storage", "and", "persists", "all", "sessions", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php#L478-L497
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php
StandardSessionManager.getLogger
public function getLogger($loggerName) { try { // first let's see if we've an application logger registered if ($logger = $this->getApplication()->getLogger($loggerName)) { return $logger; } // then try to load the global logger instance if available return $this->getApplication()->getNamingDirectory()->search(sprintf('php:global/log/%s', $loggerName)); } catch (NamingException $ne) { // do nothing, we simply have no logger with the requested name } }
php
public function getLogger($loggerName) { try { // first let's see if we've an application logger registered if ($logger = $this->getApplication()->getLogger($loggerName)) { return $logger; } // then try to load the global logger instance if available return $this->getApplication()->getNamingDirectory()->search(sprintf('php:global/log/%s', $loggerName)); } catch (NamingException $ne) { // do nothing, we simply have no logger with the requested name } }
[ "public", "function", "getLogger", "(", "$", "loggerName", ")", "{", "try", "{", "// first let's see if we've an application logger registered", "if", "(", "$", "logger", "=", "$", "this", "->", "getApplication", "(", ")", "->", "getLogger", "(", "$", "loggerName"...
Return's the logger with the requested name. First we look in the application and then in the system itself. @param string $loggerName The name of the logger to return @return \Psr\Log\LoggerInterface The logger with the requested name
[ "Return", "s", "the", "logger", "with", "the", "requested", "name", ".", "First", "we", "look", "in", "the", "application", "and", "then", "in", "the", "system", "itself", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardSessionManager.php#L529-L544
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php
AbstractLoginModule.initialize
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // initialize the passed parameters $this->params = $params; $this->subject = $subject; $this->sharedState = $sharedState; $this->callbackHandler = $callbackHandler; // query whether or not we have password stacking activated or not if ($params->exists(ParamKeys::PASSWORD_STACKING) && $params->get(ParamKeys::PASSWORD_STACKING) === 'useFirstPass') { $this->useFirstPass = true; } // check for a custom principal implementation if ($params->exists(ParamKeys::PRINCIPAL_CLASS)) { $this->principalClassName = new String($params->get(ParamKeys::PRINCIPAL_CLASS)); } // check for unauthenticatedIdentity option. if ($params->exists(ParamKeys::UNAUTHENTICATED_IDENTITY)) { $this->unauthenticatedIdentity = $this->createIdentity($params->get(ParamKeys::UNAUTHENTICATED_IDENTITY)); } }
php
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // initialize the passed parameters $this->params = $params; $this->subject = $subject; $this->sharedState = $sharedState; $this->callbackHandler = $callbackHandler; // query whether or not we have password stacking activated or not if ($params->exists(ParamKeys::PASSWORD_STACKING) && $params->get(ParamKeys::PASSWORD_STACKING) === 'useFirstPass') { $this->useFirstPass = true; } // check for a custom principal implementation if ($params->exists(ParamKeys::PRINCIPAL_CLASS)) { $this->principalClassName = new String($params->get(ParamKeys::PRINCIPAL_CLASS)); } // check for unauthenticatedIdentity option. if ($params->exists(ParamKeys::UNAUTHENTICATED_IDENTITY)) { $this->unauthenticatedIdentity = $this->createIdentity($params->get(ParamKeys::UNAUTHENTICATED_IDENTITY)); } }
[ "public", "function", "initialize", "(", "Subject", "$", "subject", ",", "CallbackHandlerInterface", "$", "callbackHandler", ",", "MapInterface", "$", "sharedState", ",", "MapInterface", "$", "params", ")", "{", "// initialize the passed parameters", "$", "this", "->"...
Initialize the login module. This stores the subject, callbackHandler and sharedState and options for the login session. Subclasses should override if they need to process their own options. A call to parent::initialize() must be made in the case of an override. The following parameters can by default be passed from the configuration. passwordStacking: If this is set to "useFirstPass", the login identity will be taken from the appserver.security.auth.login.name value of the sharedState map, and the proof of identity from the appserver.security.auth.login.password value of the sharedState map principalClass: A Principal implementation that support a constructor taking a string argument for the princpal name unauthenticatedIdentity: The name of the principal to asssign and authenticate when a null username and password are seen @param \AppserverIo\Psr\Security\Auth\Subject $subject The Subject to update after a successful login @param \AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface $callbackHandler The callback handler that will be used to obtain the user identity and credentials @param \AppserverIo\Collections\MapInterface $sharedState A map shared between all configured login module instances @param \AppserverIo\Collections\MapInterface $params The parameters passed to the login module @return void
[ "Initialize", "the", "login", "module", ".", "This", "stores", "the", "subject", "callbackHandler", "and", "sharedState", "and", "options", "for", "the", "login", "session", ".", "Subclasses", "should", "override", "if", "they", "need", "to", "process", "their",...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php#L128-L151
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php
AbstractLoginModule.login
public function login() { // initialize the login state $this->loginOk = false; // query whether or not we should use the shared state if ($this->useFirstPass) { $name = $this->sharedState->get(SharedStateKeys::LOGIN_NAME); $password = $this->sharedState->get(SharedStateKeys::LOGIN_PASSWORD); // if we've a username and a password login has been successful if ($name && $password) { $this->loginOk = true; return true; } } // return FALSE if login has not been successful return false; }
php
public function login() { // initialize the login state $this->loginOk = false; // query whether or not we should use the shared state if ($this->useFirstPass) { $name = $this->sharedState->get(SharedStateKeys::LOGIN_NAME); $password = $this->sharedState->get(SharedStateKeys::LOGIN_PASSWORD); // if we've a username and a password login has been successful if ($name && $password) { $this->loginOk = true; return true; } } // return FALSE if login has not been successful return false; }
[ "public", "function", "login", "(", ")", "{", "// initialize the login state", "$", "this", "->", "loginOk", "=", "false", ";", "// query whether or not we should use the shared state", "if", "(", "$", "this", "->", "useFirstPass", ")", "{", "$", "name", "=", "$",...
Looks for servlet_engine.authentication.login_module.login_name and servlet_engine.authentication.login_module.login_password values in the sharedState map if the useFirstPass option was true and returns TRUE if they exist. If they do not or are NULL this method returns FALSE. Note that subclasses that override the login method must set the loginOk var to TRUE if the login succeeds in order for the commit phase to populate the Subject. This implementation sets loginOk to TRUE if the login() method returns TRUE, otherwise, it sets loginOk to FALSE. Perform the authentication of username and password. @return boolean TRUE if the login credentials are available in the sharedMap, else FALSE @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if an error during login occured
[ "Looks", "for", "servlet_engine", ".", "authentication", ".", "login_module", ".", "login_name", "and", "servlet_engine", ".", "authentication", ".", "login_module", ".", "login_password", "values", "in", "the", "sharedState", "map", "if", "the", "useFirstPass", "op...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php#L175-L195
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php
AbstractLoginModule.logout
public function logout() { // load the user identity and the subject's principals $identity = $this->getIdentity(); $principals = $this->subject->getPrincipals(); // remove the user identity from the subject foreach ($principals as $key => $principal) { if ($identity->equals($principal)) { $principals->remove($key); } } // return TRUE on success return true; }
php
public function logout() { // load the user identity and the subject's principals $identity = $this->getIdentity(); $principals = $this->subject->getPrincipals(); // remove the user identity from the subject foreach ($principals as $key => $principal) { if ($identity->equals($principal)) { $principals->remove($key); } } // return TRUE on success return true; }
[ "public", "function", "logout", "(", ")", "{", "// load the user identity and the subject's principals", "$", "identity", "=", "$", "this", "->", "getIdentity", "(", ")", ";", "$", "principals", "=", "$", "this", "->", "subject", "->", "getPrincipals", "(", ")",...
Remove the user identity and roles added to the Subject during commit. @return boolean Always TRUE @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if an error during login occured
[ "Remove", "the", "user", "identity", "and", "roles", "added", "to", "the", "Subject", "during", "commit", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/AbstractLoginModule.php#L203-L219