Exemplo n.º 1
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;
 }
Exemplo n.º 2
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;
     }
 }