<?php
/**
* Container implementation.
*
* PHP Version 5
*
* @category Ding
* @package Container
* @subpackage Impl
* @author Marcelo Gornstein <[email protected]>
* @license http://marcelog.github.com/ Apache License 2.0
* @version SVN: $Id$
* @link http://marcelog.github.com/
*
* Copyright 2011 Marcelo Gornstein <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
namespace Ding\Container\Impl;
use Ding\Bean\Factory\Driver\PropertiesDriver;
use Ding\Bean\Factory\Driver\ResourcesDriver;
use Ding\Resource\Impl\IncludePathResource;
use Ding\Resource\Impl\FilesystemResource;
use Ding\Resource\Impl\URLResource;
use Ding\Cache\Locator\CacheLocator;
use Ding\Container\IContainer;
use Ding\Aspect\Proxy;
use Ding\Aspect\AspectManager;
use Ding\Aspect\InterceptorDefinition;
use Ding\Aspect\AspectDefinition;
use Ding\Aspect\Interceptor\IDispatcher;
use Ding\Aspect\Interceptor\DispatcherImpl;
use Ding\Reflection\ReflectionFactory;
use Ding\Bean\Lifecycle\BeanLifecycle;
use Ding\Bean\Lifecycle\BeanLifecycleManager;
use Ding\Bean\Factory\IBeanFactory;
use Ding\Bean\Factory\Driver\BeanXmlDriver;
use Ding\Bean\Factory\Driver\BeanYamlDriver;
use Ding\Bean\Factory\Driver\MVCAnnotationDriver;
use Ding\Bean\Factory\Driver\DependsOnDriver;
use Ding\Bean\Factory\Driver\MessageSourceDriver;
use Ding\Bean\Factory\Driver\MethodInjectionDriver;
use Ding\Bean\Factory\Driver\TimezoneDriver;
use Ding\Bean\Factory\Driver\ShutdownDriver;
use Ding\Bean\Factory\Driver\BeanAnnotationDriver;
use Ding\Bean\Factory\Driver\BeanCacheDefinitionDriver;
use Ding\Bean\Factory\Driver\BeanAspectDriver;
use Ding\Bean\Factory\Driver\ErrorHandlerDriver;
use Ding\Bean\Factory\Driver\SignalHandlerDriver;
use Ding\Bean\Factory\Driver\SetterInjectionDriver;
use Ding\Bean\Factory\Driver\AnnotationAspectDriver;
use Ding\Bean\Factory\Driver\AnnotationRequiredDriver;
use Ding\Bean\Factory\Driver\AnnotationResourceDriver;
use Ding\Bean\Factory\Driver\AnnotationInitDestroyMethodDriver;
use Ding\Bean\Factory\Driver\ContainerAwareDriver;
use Ding\Bean\Factory\Driver\LoggerAwareDriver;
use Ding\Bean\Factory\Driver\ResourceLoaderAwareDriver;
use Ding\Bean\Factory\Driver\BeanNameAwareDriver;
use Ding\Bean\Factory\Driver\AspectManagerAwareDriver;
use Ding\Bean\Factory\Driver\LifecycleDriver;
use Ding\Bean\Factory\Exception\BeanFactoryException;
use Ding\Bean\BeanConstructorArgumentDefinition;
use Ding\Bean\BeanDefinition;
use Ding\Bean\BeanPropertyDefinition;
use Ding\MessageSource\IMessageSource;
/**
* Container implementation.
*
* PHP Version 5
*
* @category Ding
* @package Container
* @subpackage Impl
* @author Marcelo Gornstein <[email protected]>
* @license http://marcelog.github.com/ Apache License 2.0
* @link http://marcelog.github.com/
*/
class ContainerImpl implements IContainer
{
/**
* log4php logger or our own.
* @var Logger
*/
private $_logger;
/**
* Cache for isDebugEnabled()
* @var boolean
*/
private $_logDebugEnabled;
/**
* Dispatcher to be cloned for proxy.
* @var DispatcherImpl
*/
private $_dispatcherTemplate = false;
/**
* MessageSource implementation.
* @var IMessageSource
*/
private $_messageSource = false;
/**
* Default options.
* @var array
*/
private static $_options = array(
'bdef' => array(),
'properties' => array(),
'drivers' => array()
);
/**
* Registered shutdown methods for beans (destroy-methods).
* @var array
*/
private $_shutdowners = array();
/**
* Beans already instantiated.
* @var object[]
*/
private $_beans;
/**
* Holds our beans cache.
* @var ICache
*/
private $_beanCache;
/**
* Beans already instantiated.
* @var BeanDefinition[]
*/
private $_beanDefs;
/**
* Holds our bean definitions cache.
* @var ICache
*/
private $_beanDefCache;
/**
* Container instance.
* @var ContainerImpl
*/
private static $_containerInstance = false;
/**
* The aspect manager.
* @var AspectManager
*/
private $_aspectManager = false;
/**
* The lifecycle manager.
* @var BeanLifecycleManager
*/
private $_lifecycleManager = false;
/**
* Resources multiton.
* @var IResource[]
*/
private $_resources = false;
/**
* Prevent serialization.
*
* @return array
*/
public function __sleep()
{
return array('_aspectManager', '_lifecycleManager');
}
/**
* Returns a bean definition.
*
* @param string $name Bean name.
*
* @return BeanDefinition
* @throws BeanFactoryException
*/
public function getBeanDefinition($name)
{
$beanName = $name . '.beandef';
if (isset($this->_beanDefs[$name])) {
if ($this->_logDebugEnabled) {
$this->_logger->debug('Serving already known: ' . $beanName);
}
return $this->_beanDefs[$name];
}
$result = false;
$beanDefinition = $this->_beanDefCache->fetch($beanName, $result);
if ($result !== false) {
$this->_beanDefs[$name] = $beanDefinition;
if ($this->_logDebugEnabled) {
$this->_logger->debug('Serving cached: ' . $beanName);
}
return $beanDefinition;
}
$beanDefinition = null;
if ($this->_logDebugEnabled) {
$this->_logger->debug('Running BeforeDefinition: ' . $beanName);
}
$beanDefinition = $this->_lifecycleManager->beforeDefinition($this, $name, $beanDefinition);
if ($beanDefinition === null) {
throw new BeanFactoryException('Unknown bean: ' . $name);
}
if ($this->_logDebugEnabled) {
$this->_logger->debug('Running AfterDefinition: ' . $beanName);
}
$beanDefinition = $this->_lifecycleManager->afterDefinition($this, $beanDefinition);
$this->setBeanDefinition($name, $beanDefinition);
return $beanDefinition;
}
/**
* Sets a bean definition (adds or overwrites).
*
* @param string $name Bean name.
* @param BeanDefinition $definition New bean definition.
*
* @return void
*/
public function setBeanDefinition($name, BeanDefinition $definition)
{
$beanName = $name . '.beandef';
$this->_beanDefs[$name] = $definition;
$this->_beanDefCache->store($beanName, $definition);
if ($this->_logDebugEnabled) {
$this->_logger->debug('New: ' . $beanName);
}
}
/**
* Sets a bean (adds or overwrites).
*
* @param string $name Bean name.
* @param object $bean New object.
*
* @return void
*/
public function setBean($name, $bean)
{
$beanName = $name . '.bean';
$this->_beans[$name] = $bean;
/**
* @todo This is not suppose to exist. We need to refactor the proxy so it
* can be correctly serialized. This check is used internally by the
* container to know that this bean cant be cached (although it can cache
* its definition).
*/
//if (!isset($bean::$iAmADingProxy)) {
// $this->_beanCache->store($beanName, $bean);
//}
if ($this->_logDebugEnabled) {
没有合适的资源?快使用搜索试试~ 我知道了~
ASP实例开发源码-PHP marcelog Ding 0.95.zip
共380个文件
php:220个
xml:67个
properties:52个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 6 浏览量
2022-11-15
13:02:07
上传
评论
收藏 421KB ZIP 举报
温馨提示
ASP实例开发源码—PHP marcelog Ding 0.95.zip ASP实例开发源码—PHP marcelog Ding 0.95.zip ASP实例开发源码—PHP marcelog Ding 0.95.zip
资源推荐
资源详情
资源评论
收起资源包目录
ASP实例开发源码-PHP marcelog Ding 0.95.zip (380个子文件)
README.Autoloader 388B
donotscan 0B
view.some.html 467B
view.exception.html 388B
view.annotated.html 314B
view.exception.html 302B
view.annotated.html 295B
view.some.html 285B
view.index.html 31B
view.fwd.html 29B
view.someTwig.html 24B
view.someOtherException.html 20B
view.someException.html 14B
view.some.html 8B
LICENSE 10KB
donotscan2.notaphp 0B
ContainerImpl.php 23KB
BeanXmlDriver.php 19KB
Test_XML_IoC.php 16KB
Test_YAML_IoC.php 16KB
BeanYamlDriver.php 16KB
Test_IoC_Cache_File.php 13KB
Test_IoC_Cache_ZF.php 12KB
Test_IoC_Cache_Memcached.php 12KB
Test_IoC_Cache_APC.php 12KB
BeanAnnotationDriver.php 12KB
TCPServerHelper.php 12KB
Test_Annotation_IoC.php 11KB
Test_HttpFrontController.php 10KB
TCPClientHelper.php 10KB
BeanLifecycleManager.php 10KB
BeanDefinition.php 10KB
ReflectionFactory.php 9KB
example.php 9KB
Proxy.php 9KB
Test_IoC_Annotation_Cache_ZF.php 7KB
Test_IoC_Annotation_Cache_Memcached.php 7KB
Test_IoC_Annotation_Cache_File.php 7KB
Test_IoC_Annotation_Cache_APC.php 7KB
Test_XML_AOP.php 6KB
HttpFrontController.php 6KB
Test_Error.php 6KB
Test_HttpDispatcher.php 6KB
Test_YAML_AOP.php 6KB
MethodInvocation.php 6KB
Test_TCP_Server.php 6KB
example.php 5KB
DispatcherImpl.php 5KB
example.php 5KB
Test_XML_Filter.php 5KB
HttpUrlMapper.php 5KB
Test_Lifecycle_Aware.php 5KB
MethodInjectionDriver.php 5KB
AspectManager.php 5KB
Test_Filesystem_Resource.php 5KB
AnnotationAspectDriver.php 5KB
PropertiesHelper.php 5KB
example.php 5KB
Test_TCP_Client.php 5KB
URLResource.php 5KB
example.php 5KB
PamiHelper.php 5KB
SyslogHelper.php 5KB
example.php 5KB
Test_Proxy.php 5KB
AnnotationResourceDriver.php 5KB
CacheLocator.php 5KB
FilesystemResource.php 5KB
Autoloader.php 4KB
example.php 4KB
ErrorInfo.php 4KB
example.php 4KB
MessageSourceImpl.php 4KB
example.php 4KB
example.php 4KB
example.php 4KB
FileCacheImpl.php 4KB
example.php 4KB
example.php 4KB
SignalHandlerDriver.php 4KB
Test_Shutdown.php 4KB
SetterInjectionDriver.php 4KB
AspectDefinition.php 4KB
example.php 4KB
Test_Dispatcher.php 4KB
TimerHelper.php 4KB
HttpViewResolver.php 4KB
Test_Signal.php 4KB
BeanPropertyDefinition.php 4KB
ShutdownDriver.php 4KB
ResourcesDriver.php 4KB
ErrorHandlerDriver.php 4KB
LifecycleDriver.php 3KB
ZendCacheImpl.php 3KB
BeanConstructorArgumentDefinition.php 3KB
MemcachedCacheImpl.php 3KB
example.php 3KB
Test_Annotation_AOP.php 3KB
Test_Container.php 3KB
example.php 3KB
共 380 条
- 1
- 2
- 3
- 4
资源评论
毕业_设计
- 粉丝: 1935
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功