/**
  * 
  * @param String $filename réal path of the php file to scan ex: /home/project/src/org/foo/bar.php
  * @param String $namespace the name space of this file ex: org\foo
  * @return void
  * @throws IocException
  */
 protected function scanFile($filename, $namespace)
 {
     if (!is_file($filename)) {
         \org\equinox\utils\Logger::error("({$filename}) is not a file!");
         throw new IocException("({$filename}) is not a file!");
     }
     include_once $filename;
     $name = basename($filename);
     $className = $namespace . '\\' . substr($name, 0, strpos($name, '.'));
     if (class_exists($className)) {
         $ref = new \ReflectionAnnotatedClass($className);
         $listAnnotation = $ref->getAllAnnotations();
         if (empty($listAnnotation)) {
             return;
             // this class is not a Component !
         }
         $bean = new BeanDefinition();
         $bean->setClassName($className);
         foreach ($listAnnotation as $annotation) {
             if ($annotation instanceof annotations\ClassAnnotation) {
                 $annotation->doBean($bean, $className);
             }
         }
         if ($bean->getId() == null) {
             throw new IocException("Equinox annotation found but no @Component annotation found (mandatory) in {$className}");
         }
         $listProperties = $ref->getProperties();
         foreach ($listProperties as $property) {
             $this->doProperty($bean, $property);
         }
         $listMethod = $ref->getMethods();
         foreach ($listMethod as $method) {
             $this->doMethod($bean, $method);
         }
         $this->context->addBeanDefinition($bean);
     }
 }