/**
  * Initializes the AOP framework.
  *
  * During initialization the specified configuration of objects is searched for possible
  * aspect annotations. If an aspect class is found, the poincut expressions are parsed and
  * a new aspect with one or more advisors is added to the aspect registry of the AOP framework.
  * Finally all advices are woven into their target classes by generating proxy classes.
  *
  * The class names of all proxied classes is stored back in the $objectConfigurations array.
  *
  * @param array &$objectConfigurations
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function initialize(array &$objectConfigurations)
 {
     if ($this->isInitialized) {
         throw new \F3\FLOW3\AOP\Exception('The AOP framework has already been initialized!', 1169550994);
     }
     $this->isInitialized = TRUE;
     if ($this->proxyBuildInformationCache->has('targetAndProxyClassNames')) {
         $this->targetAndProxyClassNames = $this->proxyBuildInformationCache->get('targetAndProxyClassNames');
     }
     if (!$this->proxyBuildInformationCache->has('allProxyClassesUpToDate')) {
         $allAvailableClassNames = $this->getAllImplementationClassesFromObjectConfigurations($objectConfigurations);
         $cachedTargetClassNames = $this->proxyBuildInformationCache->has('targetClassNames') ? $this->proxyBuildInformationCache->get('targetClassNames') : array();
         $cachedAspectClassNames = $this->proxyBuildInformationCache->has('aspectClassNames') ? $this->proxyBuildInformationCache->get('aspectClassNames') : array();
         $actualTargetClassNames = $this->getProxyableClasses($allAvailableClassNames);
         $actualAspectClassNames = $this->reflectionService->getClassNamesByTag('aspect');
         sort($actualTargetClassNames);
         sort($actualAspectClassNames);
         $this->aspectContainers = $this->buildAspectContainers($allAvailableClassNames);
         $dirtyTargetClassNames = $actualTargetClassNames;
         if ($cachedAspectClassNames === $actualAspectClassNames) {
             $validProxyClassesCount = 0;
             $outdatedProxyClassesCount = 0;
             foreach ($this->targetAndProxyClassNames as $targetClassName => $proxyClassName) {
                 if ($this->proxyClassesCache->has(str_replace('\\', '_', $proxyClassName))) {
                     $validProxyClassesCount++;
                     $dirtyTargetClassNames = array_diff($dirtyTargetClassNames, array($targetClassName));
                 } else {
                     $outdatedProxyClassesCount++;
                     unset($this->targetAndProxyClassNames[$targetClassName]);
                 }
             }
             $this->systemLogger->log(sprintf('At least one target class changed, aspects unchanged. Found %s valid and %s outdated proxy classes.', $validProxyClassesCount, $outdatedProxyClassesCount), LOG_INFO);
         } else {
             $this->systemLogger->log(sprintf('At least one aspect changed, rebuilding proxy classes for %s target classes.', count($actualTargetClassNames)), LOG_INFO);
             $this->proxyClassesCache->flush();
             $this->targetAndProxyClassNames = array();
         }
         foreach ($dirtyTargetClassNames as $targetClassName) {
             $proxyBuildResult = $this->proxyClassBuilder->buildProxyClass($targetClassName, $this->aspectContainers, $this->objectManager->getContext());
             if ($proxyBuildResult !== FALSE) {
                 $this->targetAndProxyClassNames[$targetClassName] = $proxyBuildResult['proxyClassName'];
                 $this->systemLogger->log(sprintf('Built proxy class "%s" for target class "%s" (length: %s).', $proxyBuildResult['proxyClassName'], $targetClassName, strlen($proxyBuildResult['proxyClassCode'])), LOG_DEBUG);
                 $this->proxyClassesCache->set(str_replace('\\', '_', $proxyBuildResult['proxyClassName']), $proxyBuildResult['proxyClassCode'], array($this->proxyClassesCache->getClassTag($targetClassName)));
             } else {
                 unset($this->targetAndProxyClassNames[$targetClassName]);
             }
         }
         $aspectClassesTags = array();
         foreach ($actualAspectClassNames as $aspectClassName) {
             $aspectClassesTags[] = $this->proxyBuildInformationCache->getClassTag($aspectClassName);
         }
         $this->proxyBuildInformationCache->set('targetAndProxyClassNames', $this->targetAndProxyClassNames);
         $this->proxyBuildInformationCache->set('aspectClassNames', $actualAspectClassNames, $aspectClassesTags);
         $this->proxyBuildInformationCache->set('targetClassNames', $actualTargetClassNames);
         $this->proxyBuildInformationCache->set('allProxyClassesUpToDate', '', array($this->proxyClassesCache->getClassTag()));
     }
     foreach ($this->targetAndProxyClassNames as $targetClassName => $proxyClassName) {
         if (class_exists($proxyClassName, FALSE)) {
             throw new \F3\FLOW3\AOP\Exception('Class ' . $proxyClassName . ' already exists.', 1229361833);
         }
         if (!$this->proxyClassesCache->has(str_replace('\\', '_', $proxyClassName))) {
             throw new \F3\FLOW3\AOP\Exception('No proxy class code for class "' . $proxyClassName . '" found in cache.', 1229362833);
         }
         $this->proxyClassesCache->requireOnce(str_replace('\\', '_', $proxyClassName));
         foreach ($objectConfigurations as $objectName => $objectConfiguration) {
             if ($objectConfiguration->getClassName() === $targetClassName) {
                 $objectConfigurations[$objectName]->setClassName($proxyClassName);
             }
         }
     }
 }