/** * Release bean $beanName * * @param BeanEnvelope $beanStructure the name of the bean * @param string $contextReferenceId the context application id * * @throws OvoCircularDependencyException */ public static function release(BeanEnvelope $beanStructure, $contextReferenceId) { $beanName = $beanStructure->getName(); if (!isset(self::$repository[$contextReferenceId][$beanName]) and $beanStructure->getScope() == ScopeValue::PROTOTYPE) { $schema = join(self::ARROW, self::$repository[$contextReferenceId]); throw new OvoCircularDependencyException('Dependency error [maybe Circular dependency?][' . $schema . self::ARROW . $beanName . ']'); } unset(self::$repository[$contextReferenceId][$beanName]); }
public function createBean(BeanEnvelope $beanEnvelope) { $beanName = $beanEnvelope->getName(); $this->logger->debug('Create session bean with name: ' . $beanName); $beanInstance = $this->checkIfSessionBeanExists($beanName); if ($beanInstance == null) { $this->logger->debug('Session instance not exists, try to create'); $beanInstance = $this->createObject($beanEnvelope); $this->beanRepository->addBean($beanName, $beanInstance); } return $beanInstance; }
public function createBean(BeanEnvelope $beanEnvelope) { $beanName = $beanEnvelope->getName(); $this->logger->debug('Create singleton Object for the bean with name: ' . $beanName); $beanInstance = $this->checkIfSingletonBeanExists($beanName); if ($beanInstance == null) { $this->logger->debug('Singleton instance not exists found, try to create'); $beanInstance = $this->createObject($beanEnvelope); $this->singletonBeanRepositoryImpl->addBean($beanName, $beanInstance); } return $beanInstance; }
/** * 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; }
public function createBean(BeanEnvelope $beanEnvelope) { $this->logger->debug('Create prototype bean with name: ' . $beanEnvelope->getName()); return $this->createObject($beanEnvelope); }
/** * Check if bean has destroy method. If has, register into DestroyMethodRepository * * @param BeanEnvelope $beanEnvelope * * @return void */ private function registerDestroyMethod(BeanEnvelope $beanEnvelope) { if ($beanEnvelope->getDestroyMethod() != null) { $this->logger->debug('Bean' . $beanEnvelope->getName() . ' has destroy method ' . $beanEnvelope->getDestroyMethod()); $this->beansWithDestroyMethod->add($beanEnvelope); } }