SimbaJava 依赖注入框架
Simba是基于Java的依赖注入和AOP框架
轻量级的依赖注入和AOP框架
使用XML方式定义依赖注入
支持面向切面的编程方式
安装方式
<dependency> <groupId>org.pinae</groupId> <artifactId>simba</artifactId> <version>1.1</version> </dependency>
XML定义方式
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../bean.xsd"> <bean name="PersonFactory" class="org.pinae.simba.context.resource.Person" factory-bean="org.pinae.simba.context.resource.PersonFactory" factory-method="getPerson" create="create" run="run" singleton="true" timeout="3" destroy="destroy"> <property name="name"> <reflection>Name</reflection> </property> <property name="age"> <value>27</value> </property> <property name="email"> <value>interhui@21cn.com</value> </property> <property name="admin"> <value>true</value> </property> </bean> <bean name="Name" class="org.pinae.simba.context.resource.Person.Name"> <constructor> <value>hui</value> <value>yugeng</value> </constructor> </bean> </beans>
Java Bean
public class Person { private static Logger log = Logger.getLogger(Person.class); private Name name; private int age; private String email; private boolean admin; public Name getName() { return name; } public void setName(Name name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public boolean isAdmin() { return admin; } public void setAdmin(boolean admin) { this.admin = admin; } public void create(){ log.debug("Create Person Bean"); } public void run(){ this.age ++; } public void destroy(){ log.debug("Destory Person Bean"); } public class Name { private String firstName; private String lastName; public Name(String lastName, String firstName){ this.lastName = lastName; this.firstName = firstName; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } }
实例程序
public class DemoTestManager { private static Logger log = Logger.getLogger(DemoTestManager.class); public static void main(String arg[]) throws Exception { ResourceContext bean = new FileSystemResourceContext("Person.xml"); Person person = (Person)bean.getBean("PersonFactory"); logger.debug(person.getName().getLastName() + ":" + person.getEmail()); } }
评论
FruitC++ 依赖注入框架
Fruit是C++依赖注入框架。其灵感来自Java的Guice框架。它使用C++元编程以及一些C++11功能,以在编译时检测大多数注入问题。它允许将实现代码拆分为“组件”(也称为模块),这些组件可以组
FruitC++ 依赖注入框架
0
NanoContainerJava 依赖注入框架
NanoContainer对PicoContainer容器作了一些扩充的包装,它提供了用多种脚本(groovy,.bsh,.js,.pyor.xml等)配置容器管理的对象的功能,同时提供了对web容器
NanoContainerJava 依赖注入框架
0