/**
  * Provisions all web applications.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance
  *
  * @return void
  */
 public function provision(ApplicationInterface $application)
 {
     // check if the webapps directory exists
     if (is_dir($webappPath = $application->getWebappPath())) {
         // prepare the glob expression with the application's directories to parse
         $applicationDirectories = AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, '{WEB-INF,META-INF}/provision', GLOB_BRACE);
         // load the service instance
         /** @var \AppserverIo\Appserver\Core\Api\ProvisioningService $service */
         $service = $this->getService();
         // load the configuration service instance
         /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */
         $configurationService = $this->getInitialContext()->newService('AppserverIo\\Appserver\\Core\\Api\\ConfigurationService');
         // load the container node to initialize the system properties
         /** @var \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $containerNode */
         $containerNode = $application->getContainer()->getContainerNode();
         // iterate through all provisioning files (provision.xml), validate them and attach them to the configuration
         foreach ($service->globDir($applicationDirectories, GLOB_BRACE) as $provisionFile) {
             try {
                 // validate the file, but skip it if the validation fails
                 $configurationService->validateFile($provisionFile, null);
                 // load the system properties
                 $properties = $service->getSystemProperties($containerNode);
                 // append the application specific properties
                 $properties->add(SystemPropertyKeys::WEBAPP, $webappPath);
                 $properties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath));
                 $properties->add(SystemPropertyKeys::WEBAPP_CACHE, $application->getCacheDir());
                 $properties->add(SystemPropertyKeys::WEBAPP_SESSION, $application->getSessionDir());
                 // create a new provision node instance and replace the properties
                 $provisionNode = new ProvisionNode();
                 $provisionNode->initFromFile($provisionFile);
                 $provisionNode->replaceProperties($properties);
                 // query whether we've a datasource configured or not
                 if ($datasource = $provisionNode->getDatasource()) {
                     // try to load the datasource from the system configuration
                     $datasourceNode = $service->findByName($datasource->getName());
                     // try to inject the datasource node if available
                     if ($datasourceNode != null) {
                         $provisionNode->injectDatasource($datasourceNode);
                     }
                 }
                 /* Re-provision the provision.xml (reinitialize).
                  *
                  * ATTENTION: The re-provisioning is extremely important, because
                  * this allows dynamic replacement of placeholders by using the
                  * XML file as a template that will reinterpreted with the PHP
                  * interpreter!
                  */
                 $provisionNode->reprovision($provisionFile);
                 // execute the provisioning workflow
                 $this->executeProvision($application, $provisionNode, new \SplFileInfo($webappPath));
             } 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('Will skip reading provisioning steps in %s, provisioning might not have been done.', $provisionFile));
             }
         }
     }
 }
 /**
  * Creates a new entity manager instance based on the passed configuration.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface                 $application         The application instance to create the entity manager for
  * @param \AppserverIo\Appserver\Core\Api\Node\PersistenceUnitNodeInterface $persistenceUnitNode The datasource configuration
  *
  * @return object The entity manager instance
  */
 public static function factory(ApplicationInterface $application, PersistenceUnitNodeInterface $persistenceUnitNode)
 {
     // register additional annotation libraries
     foreach ($persistenceUnitNode->getAnnotationRegistries() as $annotationRegistry) {
         AnnotationRegistry::registerAutoloadNamespace($annotationRegistry->getNamespace(), $annotationRegistry->getDirectoriesAsArray($application->getWebappPath()));
     }
     // globally ignore configured annotations to ignore
     foreach ($persistenceUnitNode->getIgnoredAnnotations() as $ignoredAnnotation) {
         AnnotationReader::addGlobalIgnoredName($ignoredAnnotation->getNodeValue()->__toString());
     }
     // load the metadata configuration
     $metadataConfiguration = $persistenceUnitNode->getMetadataConfiguration();
     // prepare the setup properties
     $absolutePaths = $metadataConfiguration->getDirectoriesAsArray($application->getWebappPath());
     $proxyDir = $metadataConfiguration->getParam(MetadataConfigurationNode::PARAM_PROXY_DIR);
     $isDevMode = $metadataConfiguration->getParam(MetadataConfigurationNode::PARAM_IS_DEV_MODE);
     $useSimpleAnnotationReader = $metadataConfiguration->getParam(MetadataConfigurationNode::PARAM_USE_SIMPLE_ANNOTATION_READER);
     // load the factory method from the available mappings
     $factoryMethod = EntityManagerFactory::$metadataMapping[$metadataConfiguration->getType()];
     // create the database configuration and initialize the entity manager
     $configuration = Setup::$factoryMethod($absolutePaths, $isDevMode, $proxyDir, null, $useSimpleAnnotationReader);
     // load the datasource node
     $datasourceNode = null;
     foreach ($application->getInitialContext()->getSystemConfiguration()->getDatasources() as $datasourceNode) {
         if ($datasourceNode->getName() === $persistenceUnitNode->getDatasource()->getName()) {
             break;
         }
     }
     // throw a exception if the configured datasource is NOT available
     if ($datasourceNode == null) {
         throw new \Exception(sprintf('Can\'t find a datasource node for persistence unit %s', $persistenceUnitNode->getName()));
     }
     // load the database node
     $databaseNode = $datasourceNode->getDatabase();
     // throw an exception if the configured database is NOT available
     if ($databaseNode == null) {
         throw new \Exception(sprintf('Can\'t find database node for persistence unit %s', $persistenceUnitNode->getName()));
     }
     // load the driver node
     $driverNode = $databaseNode->getDriver();
     // throw an exception if the configured driver is NOT available
     if ($driverNode == null) {
         throw new \Exception(sprintf('Can\'t find driver node for persistence unit %s', $persistenceUnitNode->getName()));
     }
     // initialize and return a entity manager decorator instance
     return new DoctrineEntityManagerDecorator(EntityManager::create(ConnectionUtil::get($application)->fromDatabaseNode($databaseNode), $configuration));
 }
 /**
  * Visitor method that registers the class loaders in the application.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface             $application   The application instance to register the class loader with
  * @param \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration The class loader configuration
  *
  * @return void
  */
 public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration)
 {
     // load the web application path we want to register the class loader for
     $webappPath = $application->getWebappPath();
     // initialize the class path and the enforcement directories
     $classPath = array();
     $enforcementDirs = array();
     // add the possible class path if folder is available
     foreach ($configuration->getDirectories() as $directory) {
         if (is_dir($webappPath . $directory->getNodeValue())) {
             array_push($classPath, $webappPath . $directory->getNodeValue());
             if ($directory->isEnforced()) {
                 array_push($enforcementDirs, $webappPath . $directory->getNodeValue());
             }
         }
     }
     // initialize the arrays of different omit possibilities
     $omittedEnforcement = array();
     $omittedAutoLoading = array();
     // iterate over all namespaces and check if they are omitted in one or the other way
     foreach ($configuration->getNamespaces() as $namespace) {
         // is the enforcement omitted for this namespace?
         if ($namespace->omitEnforcement()) {
             $omittedEnforcement[] = $namespace->getNodeValue()->__toString();
         }
         // is the autoloading omitted for this namespace?
         if ($namespace->omitAutoLoading()) {
             $omittedAutoLoading[] = $namespace->getNodeValue()->__toString();
         }
     }
     // initialize the class loader configuration
     $config = new Config();
     // set the environment mode we want to use
     $config->setValue('environment', $configuration->getEnvironment());
     // set the cache directory
     $config->setValue('cache/dir', $application->getCacheDir());
     // set the default autoloader values
     $config->setValue('autoloader/dirs', $classPath);
     // collect the omitted namespaces (if any)
     $config->setValue('autoloader/omit', $omittedAutoLoading);
     $config->setValue('enforcement/omit', $omittedEnforcement);
     // set the default enforcement configuration values
     $config->setValue('enforcement/dirs', $enforcementDirs);
     $config->setValue('enforcement/enforce-default-type-safety', $configuration->getTypeSafety());
     $config->setValue('enforcement/processing', $configuration->getProcessing());
     $config->setValue('enforcement/level', $configuration->getEnforcementLevel());
     $config->setValue('enforcement/logger', $application->getInitialContext()->getSystemLogger());
     // create a autoloader instance and initialize it
     $classLoader = new DgClassLoader($config);
     $classLoader->init(new StackableStructureMap($config->getValue('autoloader/dirs'), $config->getValue('enforcement/dirs'), $config), new AspectRegister());
     // add the autoloader to the manager
     $application->addClassLoader($classLoader, $configuration);
 }
 /**
  * Visitor method that registers the class loaders in the application.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface             $application   The application instance to register the class loader with
  * @param \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration The class loader configuration
  *
  * @return void
  */
 public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration)
 {
     // initialize the storage for the class map and the include path
     $classMap = new GenericStackable();
     $includePath = array();
     // load the application directory
     $webappPath = $application->getWebappPath();
     // load the composer class loader for the configured directories
     foreach ($configuration->getDirectories() as $directory) {
         // we prepare the directories to include scripts AFTER registering (in application context)
         $includePath[] = $webappPath . $directory->getNodeValue();
     }
     // initialize and return the SPL class loader instance
     $application->addClassLoader(new SplClassLoader($classMap, $includePath), $configuration);
 }
 /**
  * Visitor method that registers the class loaders in the application.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface             $application   The application instance to register the class loader with
  * @param \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration The class loader configuration
  *
  * @return void
  */
 public static function visit(ApplicationInterface $application, ClassLoaderNodeInterface $configuration)
 {
     // load the application directory
     $webappPath = $application->getWebappPath();
     // initialize the array with the configured directories
     $directories = array();
     // load the composer class loader for the configured directories
     /** @var \AppserverIo\Appserver\Core\Api\Node\DirectoryNode $directory */
     foreach ($configuration->getDirectories() as $directory) {
         // we prepare the directories to include scripts AFTER registering (in application context)
         $directories[] = $webappPath . $directory->getNodeValue();
         // check if an autoload.php is available
         if (file_exists($webappPath . $directory->getNodeValue() . DIRECTORY_SEPARATOR . 'autoload.php')) {
             // if yes, we try to instanciate a new class loader instance
             $classLoader = new ComposerClassLoader($directories);
             // set the composer include paths
             if (file_exists($webappPath . $directory->getNodeValue() . '/composer/include_paths.php')) {
                 $includePaths = (require $webappPath . $directory->getNodeValue() . '/composer/include_paths.php');
                 array_push($includePaths, get_include_path());
                 set_include_path(join(PATH_SEPARATOR, $includePaths));
             }
             // add the composer namespace declarations
             if (file_exists($webappPath . $directory->getNodeValue() . '/composer/autoload_namespaces.php')) {
                 $map = (require $webappPath . $directory->getNodeValue() . '/composer/autoload_namespaces.php');
                 foreach ($map as $namespace => $path) {
                     $classLoader->set($namespace, $path);
                 }
             }
             // add the composer PSR-4 compatible namespace declarations
             if (file_exists($webappPath . $directory->getNodeValue() . '/composer/autoload_psr4.php')) {
                 $map = (require $webappPath . $directory->getNodeValue() . '/composer/autoload_psr4.php');
                 foreach ($map as $namespace => $path) {
                     $classLoader->setPsr4($namespace, $path);
                 }
             }
             // add the composer class map
             if (file_exists($webappPath . $directory->getNodeValue() . '/composer/autoload_classmap.php')) {
                 $classMap = (require $webappPath . $directory->getNodeValue() . '/composer/autoload_classmap.php');
                 if ($classMap) {
                     $classLoader->addClassMap($classMap);
                 }
             }
             // attach the class loader instance
             $application->addClassLoader($classLoader, $configuration);
         }
     }
 }
 /**
  * Connects the passed application to the system configuration.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface $application The application to be prepared
  *
  * @return void
  */
 public function addApplicationToSystemConfiguration(ApplicationInterface $application)
 {
     // try to load the API app service instance
     $appNode = $this->getService()->loadByWebappPath($application->getWebappPath());
     // check if the application has already been attached to the container
     if ($appNode == null) {
         $this->getService()->newFromApplication($application);
     }
     // connect the application to the container
     $application->connect();
 }
Exemplo n.º 7
0
 /**
  * Registers the entity managers at startup.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance
  *
  * @return void
  */
 public function registerEntityManagers(ApplicationInterface $application)
 {
     // build up META-INF directory var
     $metaInfDir = $this->getWebappPath() . DIRECTORY_SEPARATOR . 'META-INF';
     // check if we've found a valid directory
     if (is_dir($metaInfDir) === false) {
         return;
     }
     // 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 . 'persistence'));
     // 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\Appserver\Core\Api\Node\ContainerNodeInterface $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_CACHE, $application->getCacheDir());
             $properties->add(SystemPropertyKeys::WEBAPP_SESSION, $application->getSessionDir());
             // create a new persistence manager node instance and replace the properties
             $persistenceNode = new PersistenceNode();
             $persistenceNode->initFromFile($file);
             $persistenceNode->replaceProperties($properties);
             // register the entity managers found in the configuration
             foreach ($persistenceNode->getPersistenceUnits() as $persistenceUnitNode) {
                 $this->registerEntityManager($application, $persistenceUnitNode);
             }
         } 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 entity managers 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());
             }
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Creates a new entity manager instance based on the passed configuration.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface                 $application         The application instance to create the entity manager for
  * @param \AppserverIo\Appserver\Core\Api\Node\PersistenceUnitNodeInterface $persistenceUnitNode The datasource configuration
  *
  * @return object The entity manager instance
  */
 public static function factory(ApplicationInterface $application, PersistenceUnitNodeInterface $persistenceUnitNode)
 {
     // register additional annotation libraries
     foreach ($persistenceUnitNode->getAnnotationRegistries() as $annotationRegistry) {
         AnnotationRegistry::registerAutoloadNamespace($annotationRegistry->getNamespace(), $annotationRegistry->getDirectoriesAsArray($application->getWebappPath()));
     }
     // load the metadata configuration
     $metadataConfiguration = $persistenceUnitNode->getMetadataConfiguration();
     // prepare the setup properties
     $absolutePaths = $metadataConfiguration->getDirectoriesAsArray($application->getWebappPath());
     $proxyDir = $metadataConfiguration->getParam(MetadataConfigurationNode::PARAM_PROXY_DIR);
     $isDevMode = $metadataConfiguration->getParam(MetadataConfigurationNode::PARAM_IS_DEV_MODE);
     $useSimpleAnnotationReader = $metadataConfiguration->getParam(MetadataConfigurationNode::PARAM_USE_SIMPLE_ANNOTATION_READER);
     // load the factory method from the available mappings
     $factoryMethod = EntityManagerFactory::$metadataMapping[$metadataConfiguration->getType()];
     // create the database configuration and initialize the entity manager
     $configuration = Setup::$factoryMethod($absolutePaths, $isDevMode, $proxyDir, null, $useSimpleAnnotationReader);
     // load the datasource node
     $datasourceNode = null;
     foreach ($application->getInitialContext()->getSystemConfiguration()->getDatasources() as $datasourceNode) {
         if ($datasourceNode->getName() === $persistenceUnitNode->getDatasource()->getName()) {
             break;
         }
     }
     // throw a exception if the configured datasource is NOT available
     if ($datasourceNode == null) {
         throw new \Exception(sprintf('Can\'t find a datasource node for persistence unit %s', $persistenceUnitNode->getName()));
     }
     // load the database node
     $databaseNode = $datasourceNode->getDatabase();
     // throw an exception if the configured database is NOT available
     if ($databaseNode == null) {
         throw new \Exception(sprintf('Can\'t find database node for persistence unit %s', $persistenceUnitNode->getName()));
     }
     // load the driver node
     $driverNode = $databaseNode->getDriver();
     // throw an exception if the configured driver is NOT available
     if ($driverNode == null) {
         throw new \Exception(sprintf('Can\'t find driver node for persistence unit %s', $persistenceUnitNode->getName()));
     }
     // initialize the connection parameters with the mandatory driver
     $connectionParameters = array('driver' => $databaseNode->getDriver()->getNodeValue()->__toString());
     // initialize the path/memory to the database when we use sqlite for example
     if ($pathNode = $databaseNode->getPath()) {
         $connectionParameters['path'] = $application->getWebappPath() . DIRECTORY_SEPARATOR . $pathNode->getNodeValue()->__toString();
     } elseif ($memoryNode = $databaseNode->getMemory()) {
         $connectionParameters['memory'] = Boolean::valueOf(new String($memoryNode->getNodeValue()->__toString()))->booleanValue();
     } else {
         // do nothing here, because there is NO option
     }
     // add username, if specified
     if ($userNode = $databaseNode->getUser()) {
         $connectionParameters['user'] = $userNode->getNodeValue()->__toString();
     }
     // add password, if specified
     if ($passwordNode = $databaseNode->getPassword()) {
         $connectionParameters['password'] = $passwordNode->getNodeValue()->__toString();
     }
     // add database name if using another PDO driver than sqlite
     if ($databaseNameNode = $databaseNode->getDatabaseName()) {
         $connectionParameters['dbname'] = $databaseNameNode->getNodeValue()->__toString();
     }
     // add database host if using another PDO driver than sqlite
     if ($databaseHostNode = $databaseNode->getDatabaseHost()) {
         $connectionParameters['host'] = $databaseHostNode->getNodeValue()->__toString();
     }
     // add charset, if specified
     if ($charsetNode = $databaseNode->getCharset()) {
         $connectionParameters['charset'] = $charsetNode->getNodeValue()->__toString();
     }
     // add driver options, if specified
     if ($driverOptionsNode = $databaseNode->getDriverOptions()) {
         // explode the raw options separated with a semicolon
         $rawOptions = explode(';', $driverOptionsNode->getNodeValue()->__toString());
         // prepare the array with the driver options key/value pair (separated with a =)
         $options = array();
         foreach ($rawOptions as $rawOption) {
             list($key, $value) = explode('=', $rawOption);
             $options[$key] = $value;
         }
         // set the driver options
         $connectionParameters['driverOptions'] = $options;
     }
     // add driver options, if specified
     if ($unixSocketNode = $databaseNode->getUnixSocket()) {
         $connectionParameters['unix_socket'] = $unixSocketNode->getNodeValue()->__toString();
     }
     // initialize and return a entity manager decorator instance
     return new DoctrineEntityManagerDecorator(EntityManager::create($connectionParameters, $configuration));
 }
Exemplo n.º 9
0
 /**
  * Will initialize an existing app node from a given application
  *
  * @param ApplicationInterface $application The application to init from
  *
  * @return null
  */
 public function initFromApplication(ApplicationInterface $application)
 {
     $this->setNodeName(self::NODE_NAME);
     $this->name = $application->getName();
     $this->webappPath = $application->getWebappPath();
     $this->setUuid($this->newUuid());
 }
 /**
  * Initializes the manager instance.
  *
  * @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance
  *
  * @return void
  * @see \AppserverIo\Psr\Application\ManagerInterface::initialize()
  *
  * @throws \Exception
  */
 public function initialize(ApplicationInterface $application)
 {
     // iterate over all servlets and return the matching one
     $authenticationAdapters = array();
     foreach ($application->search('ServletContextInterface')->getSecuredUrlConfigs() as $securedUrlConfig) {
         // continue if the can't find a config
         if ($securedUrlConfig == null) {
             continue;
         }
         // extract URL pattern and authentication configuration
         list($urlPattern, $auth) = array_values($securedUrlConfig);
         // load security configuration
         $configuredAuthType = $securedUrlConfig['auth']['auth-type'];
         // check the authentication type
         switch ($configuredAuthType) {
             case "Basic":
                 $authImplementation = '\\AppserverIo\\Http\\Authentication\\BasicAuthentication';
                 break;
             case "Digest":
                 $authImplementation = '\\AppserverIo\\Http\\Authentication\\DigestAuthentication';
                 break;
             default:
                 throw new \Exception(sprintf('Unknown authentication type %s', $configuredAuthType));
         }
         // in preparation we have to flatten the configuration structure
         $config = $securedUrlConfig['auth'];
         array_shift($config);
         $options = $config['options'];
         unset($config['options']);
         // we do need to make some alterations
         if (isset($options['file'])) {
             $options['file'] = $application->getWebappPath() . DIRECTORY_SEPARATOR . $options['file'];
         }
         // initialize the authentication manager
         /** @var \AppserverIo\Http\Authentication\AuthenticationInterface $auth */
         $auth = new $authImplementation(array_merge(array('type' => $authImplementation), $config, $options));
         $authenticationAdapters[$urlPattern] = $auth;
     }
     $this->authenticationAdapters = $authenticationAdapters;
 }
Exemplo n.º 11
0
 /**
  * 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()
  */
 public function initialize(ApplicationInterface $application)
 {
     // build up META-INF directory var
     $metaInfDir = $application->getWebappPath() . DIRECTORY_SEPARATOR . 'META-INF';
     // check if we've found a valid directory
     if (is_dir($metaInfDir) === false) {
         return;
     }
     // load the timer service executor and timer factories
     $timerFactory = $this->getTimerFactory();
     $calendarTimerFactory = $this->getCalendarTimerFactory();
     $timerServiceExecutor = $this->getTimerServiceExecutor();
     // load the service to iterate over application folders
     /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */
     $service = $application->newService('AppserverIo\\Appserver\\Core\\Api\\DeploymentService');
     $phpFiles = $service->globDir($metaInfDir . DIRECTORY_SEPARATOR . '*.php');
     // iterate all php files
     foreach ($phpFiles as $phpFile) {
         try {
             // cut off the META-INF directory and replace OS specific directory separators
             $relativePathToPhpFile = str_replace(DIRECTORY_SEPARATOR, '\\', str_replace($metaInfDir, '', $phpFile));
             // now cut off the first directory, that will be '/classes' by default
             $pregResult = preg_replace('%^(\\\\*)[^\\\\]+%', '', $relativePathToPhpFile);
             $className = substr($pregResult, 0, -4);
             // create the reflection class instance
             $reflectionClass = new \ReflectionClass($className);
             // initialize the timed object instance with the data from the reflection class
             $timedObject = TimedObject::fromPhpReflectionClass($reflectionClass);
             // check if we have a bean with a @Stateless, @Singleton or @MessageDriven annotation
             if ($timedObject->hasAnnotation(Stateless::ANNOTATION) === false && $timedObject->hasAnnotation(Singleton::ANNOTATION) === false && $timedObject->hasAnnotation(MessageDriven::ANNOTATION) === false) {
                 continue;
                 // if not, we don't care here!
             }
             // initialize the stackable for the timeout methods
             $timeoutMethods = new StackableStorage();
             // create the timed object invoker
             $timedObjectInvoker = new TimedObjectInvoker();
             $timedObjectInvoker->injectApplication($application);
             $timedObjectInvoker->injectTimedObject($timedObject);
             $timedObjectInvoker->injectTimeoutMethods($timeoutMethods);
             $timedObjectInvoker->start(PTHREADS_INHERIT_NONE | PTHREADS_INHERIT_CONSTANTS);
             // initialize the stackable for the timers
             $timers = new StackableStorage();
             // initialize the timer service
             $timerService = new TimerService();
             $timerService->injectTimers($timers);
             $timerService->injectTimerFactory($timerFactory);
             $timerService->injectTimedObjectInvoker($timedObjectInvoker);
             $timerService->injectCalendarTimerFactory($calendarTimerFactory);
             $timerService->injectTimerServiceExecutor($timerServiceExecutor);
             $timerService->start(PTHREADS_INHERIT_NONE | PTHREADS_INHERIT_CONSTANTS);
             // register the initialized timer service
             $this->register($timerService);
             // log a message that the timer service has been registered
             $application->getInitialContext()->getSystemLogger()->info(sprintf('Successfully registered timer service for bean %s', $reflectionClass->getName()));
             // if class can not be reflected continue with next class
         } catch (\Exception $e) {
             // log an error message
             $application->getInitialContext()->getSystemLogger()->error($e->__toString());
             // proceed with the next bean
             continue;
         }
     }
 }