一个简单的 POJO factory 实现
很简单,看看代码就明白了,不比 “hello,world” 复杂 。 主入口类 ServiceFactory 类似于 spring 的 BeanFactory: /** * * @author javafuns */ public class ServiceFactory { private static Map beansMap = Configuration.getInstance().getAllServices(); private ServiceFactory() { } public static T getService(Class superClaz) throws XxxException { String serviceClazShortName = BeanUtil.getClassShortName(superClaz); String impl = beansMap.get(serviceClazShortName); if (isBlank(impl)) { throw new XxxException(); } try { [...]
Categorized in: Design Patterns, Java · Tagged with: DesignPatterns, IOC, Java
Spring notes(二) – Ioc container
IOC container, in spring framework is BeanFactory, contains the following functions: controls the lifecycle (creation, init, destroy) controls the scope (like singleton, prototype, request, session, applicationcontext, new in spring) maintains beans’ dependence BeanFactory is the base of the other modules in springframework. Collection type for bean’s property: list set map props Lazy init for bean: [...]
Categorized in: Java, Scripts · Tagged with: AOP, IOC, Java, Spring
Spring notes(一) – Overview
Spring contains following modules: Core: the core(beanfactory) of springframework providing bean management Context: based on BeanFactory, but supports more functions, such as i18n, event-broadcasting, resource-loading, mail, validation, etc. DAO: series of interfaces that you can choose to implement DAOs. ORM: corresponding classes for integrating many ORM utilities to springframework. Web/Web MVC AOP: AOP function you [...]

(
(4.00 out of 5)