Code Monkey home page Code Monkey logo

simba's Introduction

#simba#

Simba is dependency injection framework for Java

  • Easy to integrated to Java application
  • Dependency Injection by XML
  • Aspect-Oriented Programming

Installation

Direct Download (2015/7/23)

The lastest stable is simba-1.2.tar.gz (release notes)

Maven

<dependency>
    <groupId>org.pinae</groupId>
    <artifactId>simba</artifactId>
    <version>1.1</version>
</dependency>

Getting Start

demo for Simba:

XML File:

<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>[email protected]</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 logger = 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;
		}
	}
}

Java Program:

public class DemoTestManager {

	private static Logger logger = 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());
	}
}

Documentation

Full documentation is hosted on HERE. Sources are available in the docs/ directory.

License

simba is licensed under the Apache License, Version 2.0 See LICENSE for full license text

simba's People

Contributors

interhui avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.