Author: Tim Wagner (tw@appserver.io)
Inheritance: extends AppserverIo\Psr\Application\ManagerConfigurationInterface, extends AppserverIo\Configuration\Interfaces\NodeInterface
 /**
  * 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
  */
 public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration)
 {
     // initialize the stackable storage
     $data = new StackableStorage();
     $servlets = new StackableStorage();
     $errorPages = new StackableStorage();
     $initParameters = new StackableStorage();
     $servletMappings = new GenericStackable();
     $securedUrlConfigs = new StackableStorage();
     $sessionParameters = new StackableStorage();
     // initialize the default settings for the stateful session beans
     $servletManagerSettings = new StandardManagerSettings();
     $servletManagerSettings->mergeWithParams($managerConfiguration->getParamsAsArray());
     // initialize the servlet locator
     $servletLocator = new ServletLocator();
     // initialize the servlet manager
     $servletManager = new ServletManager();
     $servletManager->injectData($data);
     $servletManager->injectServlets($servlets);
     $servletManager->injectErrorPages($errorPages);
     $servletManager->injectApplication($application);
     $servletManager->injectInitParameters($initParameters);
     $servletManager->injectResourceLocator($servletLocator);
     $servletManager->injectServletMappings($servletMappings);
     $servletManager->injectSecuredUrlConfigs($securedUrlConfigs);
     $servletManager->injectSessionParameters($sessionParameters);
     $servletManager->injectManagerSettings($servletManagerSettings);
     $servletManager->injectDirectories($managerConfiguration->getDirectories());
     // create the naming context and add it the manager
     $contextFactory = $managerConfiguration->getContextFactory();
     $contextFactory::visit($servletManager);
     // attach the instance
     $application->addManager($servletManager, $managerConfiguration);
 }
 /**
  * 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
  */
 public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration)
 {
     // initialize the sessions and the session settings
     $sessionHandlers = new HashMap();
     $sessionSettings = new DefaultSessionSettings();
     $sessionMarshaller = new StandardSessionMarshaller();
     // add the configured session handlers
     /** @var \AppserverIo\Appserver\Core\Api\Node\SessionHandlerNode $sessionHandlerNode */
     foreach ($managerConfiguration->getSessionHandlers() as $sessionHandlerNode) {
         if ($factory = $sessionHandlerNode->getFactory()) {
             $sessionHandlers->add($sessionHandlerNode->getName(), $factory::create($sessionHandlerNode, $sessionSettings, $sessionMarshaller));
         }
     }
     // we need a garbage collector
     $garbageCollector = new StandardGarbageCollector();
     $garbageCollector->injectApplication($application);
     $garbageCollector->injectSessionSettings($sessionSettings);
     $garbageCollector->start();
     // and finally we need the session manager instance
     $sessionManager = new StandardSessionManager();
     $sessionManager->injectApplication($application);
     $sessionManager->injectSessionSettings($sessionSettings);
     $sessionManager->injectSessionHandlers($sessionHandlers);
     $sessionManager->injectGarbageCollector($garbageCollector);
     $sessionManager->injectSessionMarshaller($sessionMarshaller);
     $sessionManager->injectManagerConfiguration($managerConfiguration);
     // attach the instance
     $application->addManager($sessionManager, $managerConfiguration);
 }
 /**
  * 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
  */
 public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration)
 {
     // create the initial context instance
     $initialContext = new NamingContext();
     $initialContext->injectApplication($application);
     // initialize the stackable storage
     $data = new StackableStorage();
     $servlets = new StackableStorage();
     $initParameters = new StackableStorage();
     $servletMappings = new GenericStackable();
     $securedUrlConfigs = new StackableStorage();
     $sessionParameters = new StackableStorage();
     // initialize the servlet locator
     $servletLocator = new ServletLocator();
     // initialize the servlet manager
     $servletManager = new ServletManager();
     $servletManager->injectData($data);
     $servletManager->injectServlets($servlets);
     $servletManager->injectApplication($application);
     $servletManager->injectInitialContext($initialContext);
     $servletManager->injectInitParameters($initParameters);
     $servletManager->injectResourceLocator($servletLocator);
     $servletManager->injectServletMappings($servletMappings);
     $servletManager->injectSecuredUrlConfigs($securedUrlConfigs);
     $servletManager->injectSessionParameters($sessionParameters);
     $servletManager->injectDirectories($managerConfiguration->getDirectories());
     // attach the instance
     $application->addManager($servletManager, $managerConfiguration);
 }
 /**
  * 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
  */
 public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration)
 {
     // load the configured descriptors from the configuration
     $configuredDescriptors = $managerConfiguration->getDescriptors();
     // create the storage for the data and the bean descriptors
     $data = new StackableStorage();
     $objectDescriptors = new StackableStorage();
     // create and initialize the object manager instance
     $objectManager = new ObjectManager();
     $objectManager->injectData($data);
     $objectManager->injectApplication($application);
     $objectManager->injectObjectDescriptors($objectDescriptors);
     $objectManager->injectConfiguredDescriptors($configuredDescriptors);
     // attach the instance
     $application->addManager($objectManager, $managerConfiguration);
 }
Example #5
0
 /**
  * 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
  */
 public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration)
 {
     // load the registered loggers
     $loggers = $application->getInitialContext()->getLoggers();
     // initialize the bean locator
     $beanLocator = new BeanLocator();
     // create the initial context instance
     $initialContext = new NamingContext();
     $initialContext->injectApplication($application);
     // initialize the stackable for the data, the stateful + singleton session beans and the naming directory
     $data = new StackableStorage();
     $instances = new GenericStackable();
     $statefulSessionBeans = new StackableStorage();
     $singletonSessionBeans = new StackableStorage();
     // initialize the default settings for the stateful session beans
     $statefulSessionBeanSettings = new DefaultStatefulSessionBeanSettings();
     $statefulSessionBeanSettings->mergeWithParams($managerConfiguration->getParamsAsArray());
     // we need a factory instance for the stateful session bean instances
     $statefulSessionBeanMapFactory = new StatefulSessionBeanMapFactory($statefulSessionBeans);
     $statefulSessionBeanMapFactory->injectLoggers($loggers);
     $statefulSessionBeanMapFactory->start();
     // 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();
     // initialize the bean manager
     $beanManager = new BeanManager();
     $beanManager->injectData($data);
     $beanManager->injectApplication($application);
     $beanManager->injectResourceLocator($beanLocator);
     $beanManager->injectObjectFactory($objectFactory);
     $beanManager->injectInitialContext($initialContext);
     $beanManager->injectGarbageCollector($garbageCollector);
     $beanManager->injectStatefulSessionBeans($statefulSessionBeans);
     $beanManager->injectSingletonSessionBeans($singletonSessionBeans);
     $beanManager->injectDirectories($managerConfiguration->getDirectories());
     $beanManager->injectStatefulSessionBeanSettings($statefulSessionBeanSettings);
     $beanManager->injectStatefulSessionBeanMapFactory($statefulSessionBeanMapFactory);
     // attach the instance
     $application->addManager($beanManager, $managerConfiguration);
 }
 /**
  * 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
  */
 public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration)
 {
     // initialize the stackable for the entity managers
     $entityManagers = new GenericStackable();
     // initialize the default settings for the persistence units
     $persistenceManagerSettings = new PersistenceManagerSettings();
     $persistenceManagerSettings->mergeWithParams($managerConfiguration->getParamsAsArray());
     // initialize the persistence manager instance
     $persistenceManager = new PersistenceManager();
     $persistenceManager->injectApplication($application);
     $persistenceManager->injectEntityManagers($entityManagers);
     $persistenceManager->injectManagerSettings($persistenceManagerSettings);
     // create the naming context and add it the manager
     $contextFactory = $managerConfiguration->getContextFactory();
     $contextFactory::visit($persistenceManager);
     // attach the instance
     $application->addManager($persistenceManager, $managerConfiguration);
 }
 /**
  * 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
  */
 public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration)
 {
     // initialize the stackable containers
     $queues = new GenericStackable();
     $workers = new GenericStackable();
     $messages = new GenericStackable();
     // initialize the queue locator
     $queueLocator = new QueueLocator();
     // initialize the default settings for message queue
     $queueManagerSettings = new QueueManagerSettings();
     $queueManagerSettings->mergeWithParams($managerConfiguration->getParamsAsArray());
     // initialize the queue manager
     $queueManager = new QueueManager();
     $queueManager->injectQueues($queues);
     $queueManager->injectWorkers($workers);
     $queueManager->injectMessages($messages);
     $queueManager->injectApplication($application);
     $queueManager->injectResourceLocator($queueLocator);
     $queueManager->injectManagerSettings($queueManagerSettings);
     // attach the instance
     $application->addManager($queueManager, $managerConfiguration);
 }
Example #8
0
 /**
  * Injects manager instance and the configuration.
  *
  * @param \AppserverIo\Psr\Application\ManagerInterface             $manager       A manager instance
  * @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $configuration The managers configuration
  *
  * @return void
  */
 public function addManager(ManagerInterface $manager, ManagerNodeInterface $configuration)
 {
     // bind the manager callback to the naming directory => the application itself
     $this->getNamingDirectory()->bind(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getManager'), array($configuration->getName()));
     // add the manager instance to the application
     $this->managers[$configuration->getName()] = $manager;
 }
Example #9
0
 /**
  * This method merges the configuration of the passed manager node
  * into this one.
  *
  * @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerNode The node with the manager configuration we want to merge
  *
  * @return void
  */
 public function merge(ManagerNodeInterface $managerNode)
 {
     // make sure, we only merge nodes with the same name
     if (strcasecmp($this->getName(), $managerNode->getName()) !== 0) {
         return;
     }
     // override type and factory attributes
     $this->type = $managerNode->getType();
     $this->factory = $managerNode->getFactory();
     $this->contextFactory = $managerNode->getContextFactory();
     // load the authenticators of this manager node
     $localAuthenticators = $this->getAuthenticators();
     // iterate over the authenticator nodes of the passed manager node and merge them
     foreach ($managerNode->getAuthenticators() as $authenticatorNode) {
         $isMerged = false;
         foreach ($localAuthenticators as $key => $localAuthenticator) {
             if (strcasecmp($localAuthenticator->getName(), $authenticatorNode->getName()) === 0) {
                 $localAuthenticators[$key] = $authenticatorNode;
                 $isMerged = true;
             }
         }
         if ($isMerged === false) {
             $localAuthenticators[$authenticatorNode->getUuid()] = $authenticatorNode;
         }
     }
     // override the authenticators with the merged mones
     $this->authenticators = $localAuthenticators;
     // override the descriptors if available
     if (sizeof($descriptors = $managerNode->getDescriptors()) > 0) {
         $this->descriptors = $descriptors;
     }
     // override the directories if available
     if (sizeof($directories = $managerNode->getDirectories()) > 0) {
         $this->directories = $directories;
     }
     // override the params if available
     if (sizeof($params = $managerNode->getParams()) > 0) {
         $this->params = $params;
     }
     // override the security domains if available
     if (sizeof($securityDomains = $managerNode->getSecurityDomains()) > 0) {
         $this->securityDomains = $securityDomains;
     }
 }