public function removeBean($beanName)
 {
     $this->logger->debug('removeFromRepository bean: ' . $beanName);
     if (isset($this->loadedBeanSingleton[$beanName])) {
         unset($this->loadedBeanSingleton[$beanName]);
     }
 }
 /**
  * @param string $beanName
  * @return null|Object
  */
 public function getBean($beanName)
 {
     $this->logger->debug('Get bean with name: ' . $beanName);
     $instance = null;
     if (isset($this->preLoadedBeans[$beanName])) {
         $this->logger->debug('Init Object exists for bean ' . $beanName);
         $instance = $this->preLoadedBeans[$beanName];
         unset($this->preLoadedBeans[$beanName]);
     }
     return $instance;
 }
 /**
  * Create the object from the $beanStructure
  *
  * @param BeanEnvelope $beanEnvelope
  *
  * @return Object
  */
 protected function createObject(BeanEnvelope $beanEnvelope)
 {
     $beanClass = $beanEnvelope->getClass();
     $beanArgs = $beanEnvelope->getArgs();
     $beanFactoryMethod = $beanEnvelope->getFactoryMethod();
     $this->logger->debug('Create bean name: ' . $beanEnvelope->getName() . ' on class: ' . $beanClass);
     if ($beanFactoryMethod != null) {
         $beanInstance = ObjectCreator::createObjectFromFactoryMethod($beanClass, $beanArgs, $beanFactoryMethod);
     } else {
         $beanInstance = ObjectCreator::createObject($beanClass, $beanArgs);
     }
     return $beanInstance;
 }
Beispiel #4
0
 /**
  * The destruct method is used to serialize the session object and to clean up  the factory bean envelope
  */
 public function __destruct()
 {
     $this->logger->debug('Call __destruct method with context id {' . $this->contextReferenceId . '}');
     if ($this->close == false) {
         $this->serializingSessionBeans();
         $this->factoryBeanEnvelope->close();
     }
 }
 /**
  * @param $scope
  *
  * @return BeanCreator
  *
  * @throws OvoContainerException
  */
 private function getScopeObjectCreator($scope)
 {
     $this->logger->debug('Get BeanCreator for scope ' . $scope);
     switch ($scope) {
         case ScopeValue::PROTOTYPE:
             $beanCreator = $this->prototypeBeanCreator;
             break;
         case ScopeValue::SESSION:
             $beanCreator = $this->sessionBeanCreator;
             break;
         case ScopeValue::SINGLETON:
             $beanCreator = $this->singletonBeanCreator;
             break;
         default:
             $this->logger->debug('Error during the creation of the bean with scope ' . $scope . ', scope not found');
             throw new OvoContainerException('Scope not valide [' . $scope . ']');
             break;
     }
     return $beanCreator;
 }
 /**
  * Method to serialize all the objects handled by the session manager
  *
  * @return void
  */
 public function store()
 {
     $this->logger->debug('Save all beans of the session');
     foreach ($this->sessionObjectsRepository as $beanName => $beanInstance) {
         try {
             $_SESSION[$this->sessionName][$beanName] = serialize($beanInstance);
         } catch (\Exception $e) {
             if (is_object($beanInstance)) {
                 $this->logger->error('Error while serializing class ' . get_class($beanInstance) . ' for bean: ' . $beanName);
             }
             $this->logger->error($e->getMessage());
             throw new OvoContainerException($e->getMessage());
         }
     }
 }
 /**
  * Search if exists the session Reader Object.
  * If not, ora data modified it's different, reload it
  *
  * @return ContextReader
  */
 private function getReaderFromSession()
 {
     $this->logger->debug('Try to get ContextReader from the session');
     $contextReader = $this->serializer->getObject(self::READER);
     $storedModificationData = $this->serializer->getObject(self::CONFIGURATION_FILE_MODIFICATON_DATE);
     $actualModificationData = filemtime($this->file);
     //if datemod Config file is different from data configfile in session, reload it
     //TODO check this for all the config file (ex: <include-file path='other.xml'>)
     if ($contextReader instanceof ContextReader and $storedModificationData != $actualModificationData) {
         $this->logger->debug('Reload configuration [ ' . $storedModificationData . ' - ' . $actualModificationData . ' ]');
         $this->serializer->serializeObject(self::CONFIGURATION_FILE_MODIFICATON_DATE, $actualModificationData);
         $contextReader->reload();
         $this->reload = true;
     }
     return $contextReader;
 }
 /**
  * Method to pre-create all beans scoped as SINGLETON or the beans with init-on-load set to TRUE
  * during the first time application boot
  *
  * @param ContextReader $contextReader
  *
  * return void
  */
 private function initBeans(ContextReader $contextReader)
 {
     $this->logger->debug('Pre-Load all init-on-boot beans');
     $beansToPreload = $contextReader->getInitBeans();
     $this->preLoadedBeansRepository = new SimplePreLoadedBeansRepositoryImpl();
     if ($beansToPreload != null) {
         foreach ($beansToPreload as $bean) {
             try {
                 $this->preLoadedBeansRepository->addBean($bean, $this->coreContainer->getBean($bean));
             } catch (OvoContainerException $e) {
                 $this->coreContainer->close();
                 throw new OvoLoaderException($e->getMessage());
             }
         }
     }
 }
 /**
  * (non-PHPdoc)
  * @see include/Core/Container/Core/Rule/InterfaceSessionBean#removeSessionBean()
  */
 public function addBean($beanName, $beanBeanInstance)
 {
     $this->logger->debug('addBeanToRepository ' . $beanName);
     $this->sessionBeans[$beanName] = $beanBeanInstance;
 }
 /**
  * Get the setter name from property name
  *
  * @param string $beanPropertyName the property's name
  *
  * @return string the setter name
  */
 private static function getSetterName($beanPropertyName)
 {
     self::$logger->debug('Get setter for property: ' . $beanPropertyName);
     return self::SETTER . ucfirst($beanPropertyName);
 }
Beispiel #11
0
 public function __wakeup()
 {
     $this->logger = OvoLogger::getLogger(get_class($this));
     $this->logger->debug('re-create Logger');
 }