Please be aware that Spring Actionscript's concept of a singleton object is quite different from the Singleton pattern as defined in the seminal Gang of Four (GoF) patterns book. The GoF Singleton hard codes the scope of an object such that one and only one instance of a particular class will ever be created. The scope of the Spring Actionscript singleton is best described as per container and per object. This means that if you define one object for a particular class in a single Spring Actionscript container, then the Spring Actionscript container will create one and only one instance of the class defined by that object definition. The singleton scope is the default scope in Spring Actionscript. To define an object as a singleton in XML, you would write configuration like so:
Spring 的单例与单例设计模式不同之处就是:
前者一个容器一个对象,后者始终一个对象,
IOC容器肯定是Spring容器的一部分,所以初始化一个Spring容器 就等同于初始化了IOC
AbstractApplicationContext ctx = new ClassPathXMLApplicationContext();....手写可能有误java的
var ctx:ApplicationContext =new ApplicationContext();//spring actionscript的