public function removeBean($beanName) { $this->logger->debug('removeFromRepository bean: ' . $beanName); if (isset($this->loadedBeanSingleton[$beanName])) { unset($this->loadedBeanSingleton[$beanName]); } }
/** * 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; }
/** * 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; }
/** * All Objects with static factory method are created here * * @param string $name the name of the Object to create * @param array $args construct args * @param string $factoryMethod the static method used to create the Object instance * * @return Object */ public static function createObjectFromFactoryMethod($name, $args, $factoryMethod) { $logger = OvoLogger::getLogger('ObjectCreator'); $logger->debug('Create Object ' . $name . ' form static method ' . $factoryMethod); try { $reflectionMethod = new \ReflectionMethod($name, $factoryMethod); return $reflectionMethod->invokeArgs(null, $args); } catch (\ReflectionException $e) { $logger->error('Reflection Error: ' . $e->getMessage()); throw new OvoContainerException('Can not create Object (from factory) ' . $name . ' - ' . $e->getMessage()); } }
public function __construct($path, $dir = null) { $this->logger = OvoLogger::getLogger(get_class($this)); $this->logger->debug('Annotation context on path ' . $path); $this->basicPath = $path; $cacheDir = PropertiesLoader::getProperty(self::ANNOTATION_CACHE); if (!isset($cacheDir) or $cacheDir == '') { $cacheDir = sys_get_temp_dir(); } $this->logger->debug('Create annotation reader with cache dir: ' . $cacheDir); $this->annotationReader = new FileCacheReader(new AnnotationReader(), $cacheDir, PropertiesLoader::getProperty(self::ANNOTATION_DEBUG)); $this->registerAnnotationFile(); $this->scanContext($this->scanClassPath($path)); }
/** * 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; }
public function __construct(ContextReader $reader, $contextReferenceId) { $this->contextReferenceId = $contextReferenceId; $this->logger = OvoLogger::getLogger(get_class($this)); $this->contextReader = $reader; }
public function unserialize($serialized) { $unserializedData = unserialize($serialized); $this->preLoadedBeans = isset($unserializedData[ConfigurationLoader::PRE_LOADED_BEANS]) ? $unserializedData[ConfigurationLoader::PRE_LOADED_BEANS] : array(); $this->logger = OvoLogger::getLogger(get_class($this)); }
/** * 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); }
public function __wakeup() { $this->logger = OvoLogger::getLogger(get_class($this)); $this->logger->debug('re-create Logger'); }