/**
  * Creates a new scanner instance and attaches it to the passed server instance.
  *
  * @param \AppserverIo\Appserver\Core\Interfaces\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
  */
 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));
 }
 /**
  * Creates a new scanner instance and attaches it to the passed server instance.
  *
  * @param \AppserverIo\Appserver\Core\Interfaces\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
  */
 public static function visit(ApplicationServerInterface $server, ScannerNodeInterface $scannerNode)
 {
     // load the initial context instance
     /** @var \AppserverIo\Appserver\Application\Interfaces\ContextInterface $initialContext */
     $initialContext = $server->getInitialContext();
     // iterate over the configured directories and create a scanner instance for each of them
     /** @var \AppserverIo\Appserver\Core\Api\Node\DirectoryNodeInterface $directoryNode */
     foreach ($scannerNode->getDirectories() as $directoryNode) {
         // load the reflection class for the scanner type
         $reflectionClass = new \ReflectionClass($scannerNode->getType());
         // prepare the unique scanner name
         $scannerName = sprintf('%s-%s', $scannerNode->getName(), $directoryNode->getNodeValue()->__toString());
         // prepare the scanner params
         $scannerParams = array($initialContext, $scannerName, $directoryNode->getNodeValue()->__toString());
         $scannerParams = array_merge($scannerParams, $scannerNode->getParamsAsArray());
         // register and start the scanner as daemon
         $server->bindService(ApplicationServerInterface::DAEMON, $reflectionClass->newInstanceArgs($scannerParams));
     }
 }