Skip to content

Commit

Permalink
Merge pull request #1105 from wagnert/master
Browse files Browse the repository at this point in the history
* Add member contextNode and getter to Application class
  • Loading branch information
wagnert authored Aug 4, 2018
2 parents 7ab90df + 675aadb commit 7b2ab33
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 77 deletions.
51 changes: 32 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
Version 1.1.11
# Version 1.1.12

## Bugfixes

* Add member contextNode and getter to Application class
* Add improved error handling the appserver-io/doppelgaenger GeneratorThread
* Refactor StandardSessionMarshaller to use array instead of \stdClass when persisting session data
* Servlets will now be initialized in ServletManager::postStartup() instead of ServletManager::registerServlet() method

## Features

* None

# Version 1.1.11

## Bugfixes

Expand All @@ -8,7 +21,7 @@ Version 1.1.11

* None

Version 1.1.10
# Version 1.1.10

## Bugfixes

Expand All @@ -19,7 +32,7 @@ Version 1.1.10
* Add configuration option for Doctrine repository factory + repository default class
* Remove appserver-io/routlt library (has to be addes as dependency to your project)

Version 1.1.9
# Version 1.1.9

## Bugfixes

Expand All @@ -29,7 +42,7 @@ Version 1.1.9

* None

Version 1.1.8
# Version 1.1.8

## Bugfixes

Expand All @@ -40,7 +53,7 @@ Version 1.1.8
* Refactor MQ implementation with callbacks and optimized workflow handling
* Refactor AbstractStep by adding configuratble retries

Version 1.1.7
# Version 1.1.7

## Bugfixes

Expand All @@ -51,7 +64,7 @@ Version 1.1.7
* Switch to appserver-io/logger version 2.0.* and appserver-io/application version 1.5.*
* Add postStartup() lifecycle callback to managers to allow actions after the application has been connected

Version 1.1.6
# Version 1.1.6

## Bugfixes

Expand All @@ -61,7 +74,7 @@ Version 1.1.6

* None

Version 1.1.5
# Version 1.1.5

## Bugfixes

Expand All @@ -71,7 +84,7 @@ Version 1.1.5

* Release version 1.1.5

Version 1.1.5-beta12
# Version 1.1.5-beta12

## Bugfixes

Expand All @@ -81,7 +94,7 @@ Version 1.1.5-beta12

* Refactor logger integration, switch to function usage instead of loading logger instances via application or initial context

Version 1.1.5-beta11
# Version 1.1.5-beta11

## Bugfixes

Expand All @@ -93,7 +106,7 @@ Version 1.1.5-beta11
* Switch to latest runtime with PHP version 5.6.35
* Register environment in BeanManager::initialize() and Job::run() methods to allow usage of short logging functions

Version 1.1.5-beta10
# Version 1.1.5-beta10

## Bugfixes

Expand All @@ -106,7 +119,7 @@ Version 1.1.5-beta10
* Move descriptor configuration to appserver-io-psr/epb and implementation to appserver-io/description
* Extract interfaces from appserver-io/appserver to appserver-io-psr/cli and appserver-io-psr/application-server

Version 1.1.5-beta9
# Version 1.1.5-beta9

## Bugfixes

Expand All @@ -116,7 +129,7 @@ Version 1.1.5-beta9

* Refactor StandardSecurityManager to make configuration of security constraints simpler

Version 1.1.5-beta8
# Version 1.1.5-beta8

## Bugfixes

Expand All @@ -126,7 +139,7 @@ Version 1.1.5-beta8

* None

Version 1.1.5-beta7
# Version 1.1.5-beta7

## Bugfixes

Expand All @@ -137,7 +150,7 @@ Version 1.1.5-beta7
* Switch to appserver-io/console 3.0 to add command to load Doctrine Fixtures
* Temporary persist entity manager names in PersistenceManager instance to allow loading an applications default entity manager by name

Version 1.1.5-beta6
# Version 1.1.5-beta6

## Bugfixes

Expand All @@ -147,7 +160,7 @@ Version 1.1.5-beta6

* None

Version 1.1.5-beta5
# Version 1.1.5-beta5

## Bugfixes

Expand All @@ -157,7 +170,7 @@ Version 1.1.5-beta5

* Switch to latest appserver-io/console version 2.0.0

Version 1.1.5-beta4
# Version 1.1.5-beta4

## Bugfixes

Expand All @@ -168,7 +181,7 @@ Version 1.1.5-beta4
* Integrate Doctrine ORM, DBAL and Migrations console commands
* Extend DI functionality for method invocation on instanciated objects

Version 1.1.5-beta3
# Version 1.1.5-beta3

## Bugfixes

Expand All @@ -178,7 +191,7 @@ Version 1.1.5-beta3

* None

Version 1.1.5-beta2
# Version 1.1.5-beta2

## Bugfixes

Expand All @@ -193,7 +206,7 @@ Version 1.1.5-beta2
* Switch to VarDumpertFormatter for system logger to allow logging ALL instances, including recursive ones and passing objects without converting them to strings
* Add helper functions for all log levels (alert, info, debug etc.) to make logging more comfortable

Version 1.1.5-beta1
# Version 1.1.5-beta1

## Bugfixes

Expand Down
3 changes: 3 additions & 0 deletions UPGRADE-1.1.12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Upgrade from 1.1.11 to 1.1.12

Updating from 1.1.11 to 1.1.12 doesn't have any impacts. Please read the apropriate UPGRADE-1.x.x files for updates from older versions to 1.1.11.
29 changes: 20 additions & 9 deletions src/AppserverIo/Appserver/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
* @property string $containerName Name of the container the application is bound to
* @property string $containerRunlevel Runlevel of the container the application is bound to
* @property \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory The naming directory instance
* @property \AppserverIo\Appserver\Core\Api\Node\ContextNode $contextNode The application configuration instance
*/
class Application extends \Thread implements ApplicationInterface, DirectoryAwareInterface, FilesystemAwareInterface, \AppserverIo\Psr\Context\ContextInterface
{
Expand Down Expand Up @@ -271,6 +272,16 @@ public function getNamingDirectory()
return $this->namingDirectory;
}

/**
* Return's the application configuration.
*
* @return \AppserverIo\Appserver\Core\Api\Node\ContextNode The application configuration
*/
public function getContextNode()
{
return $this->contextNode;
}

/**
* Returns the absolute path to the servers document root directory
*
Expand Down Expand Up @@ -632,16 +643,16 @@ public function addLogger(LoggerInterface $logger, LoggerNodeInterface $configur
* Prepares the application with the specific data found in the
* passed context node.
*
* @param \AppserverIo\Psr\ApplicationServer\ContainerInterface $container The container instance bind the application to
* @param \AppserverIo\Appserver\Core\Api\Node\ContextNode $context The application configuration
* @param \AppserverIo\Psr\ApplicationServer\ContainerInterface $container The container instance bind the application to
* @param \AppserverIo\Appserver\Core\Api\Node\ContextNode $contextNode The application configuration
*
* @return void
*/
public function prepare(ContainerInterface $container, ContextNode $context)
public function prepare(ContainerInterface $container, ContextNode $contextNode)
{


$this->context = $context;
// set the application configuration
$this->contextNode = $contextNode;

// load the unique application name + the naming directory
$uniqueName = $this->getUniqueName();
Expand All @@ -662,9 +673,9 @@ public function prepare(ContainerInterface $container, ContextNode $context)
// prepare the application specific directories
$webappPath = sprintf('%s/%s', $this->getAppBase(), $this->getName());
$tmpDirectory = sprintf('%s/%s', $container->getTmpDir(), $this->getName());
$dataDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($context->getParam(DirectoryKeys::DATA), '/'));
$cacheDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($context->getParam(DirectoryKeys::CACHE), '/'));
$sessionDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($context->getParam(DirectoryKeys::SESSION), '/'));
$dataDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::DATA), '/'));
$cacheDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::CACHE), '/'));
$sessionDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::SESSION), '/'));

// prepare the application specific environment variables
$namingDirectory->bind(sprintf('php:env/%s/webappPath', $uniqueName), $webappPath);
Expand Down Expand Up @@ -772,7 +783,7 @@ public function registerAnnotationRegistries()
AnnotationRegistry::reset();

// register additional annotation libraries
foreach ($this->context->getAnnotationRegistries() as $annotationRegistry) {
foreach ($this->getContextNode()->getAnnotationRegistries() as $annotationRegistry) {
// register the annotations specified by the annotation registery
$annotationRegistryType = $annotationRegistry->getType();
$registry = new $annotationRegistryType();
Expand Down
52 changes: 49 additions & 3 deletions src/AppserverIo/Appserver/Core/GeneratorThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace AppserverIo\Appserver\Core;

use AppserverIo\Doppelgaenger\Generator;
use Psr\Log\LogLevel;

/**
* Simple thread for parallel creation of contract-enabled structure definitions.
Expand All @@ -32,6 +33,7 @@
*/
class GeneratorThread extends \Thread
{

/**
* Generator instance to use for creation
*
Expand Down Expand Up @@ -66,12 +68,56 @@ public function __construct(Generator $generator, array $structures)
public function run()
{

// register a shutdown function
register_shutdown_function(array($this, 'shutdown'));

// register the default autoloader
require SERVER_AUTOLOADER;

// iterate over all structures and generate them
foreach ($this->structures as $structure) {
$this->generator->create($structure);
try {
// iterate over all structures and generate them
foreach ($this->structures as $structure) {
$this->generator->create($structure);
}

} catch (\Exception $e) {
$this->log(LogLevel::ERROR, $e->__toString());
}
}

/**
* The shutdown method implementation.
*
*@return void
*/
public function shutdown()
{

// check if there was a fatal error caused shutdown
if ($lastError = error_get_last()) {
// initialize error type and message
$type = 0;
$message = '';
// extract the last error values
extract($lastError);
// query whether we've a fatal/user error
if ($type === E_ERROR || $type === E_USER_ERROR) {
$this->log(LogLevel::ERROR, $message);
}
}
}

/**
* This is a very basic method to log some stuff by using the error_log() method of PHP.
*
* @param mixed $level The log level to use
* @param string $message The message we want to log
* @param array $context The context we of the message
*
* @return void
*/
public function log($level, $message, array $context = array())
{
error_log(sprintf($this->getDefaultLogFormat(), date('Y-m-d H:i:s'), gethostname(), $level, $message, json_encode($context)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
use AppserverIo\Appserver\PersistenceContainer\GarbageCollectors\StandardGarbageCollector;
use AppserverIo\Appserver\PersistenceContainer\RemoteMethodInvocation\ProxyGeneratorInterface;
use AppserverIo\Appserver\PersistenceContainer\GarbageCollectors\StartupBeanTaskGarbageCollector;
use Doctrine\Common\Annotations\AnnotationRegistry;

/**
* The bean manager handles the message and session beans registered for the application.
Expand Down
Loading

0 comments on commit 7b2ab33

Please sign in to comment.