Git Product home page Git Product logo

iogi's Introduction

What is Iogi

Iogi is a small library for instantiating objects (and graphs therof) in Java. It's primary motivation is to help with unmarshalling request parameters in Web applications.

The project was born as a spin-off of the VRaptor Web Framework. Many frameworks use OGLN to construct objects, but, as it's name atests, OGNL is most useful as a language for navigating object graphs. As such, it is oriented around properties as getter/setter pairs. Iogi, on the other hand, is able to instantiate objects through constructor parameters or setters. Iogi also supports dependency injection, so you can inject arbitrary objects (perhaps with the help of a DI framework) into your domain objects as they are instantiated.

Sample code

Here are some sample classes that you might want to instantiate:

public static class House {
    private Cat cat;

    public void setCat(final Cat cat) {
        this.cat = cat;
    }

    public Cat getCat() {
        return cat;
    }
}

public static class Cat {
    private Leg firstLeg;

    public void setFirstLeg(final Leg firstLeg) {
        this.firstLeg = firstLeg;
    }

    public Leg getFirstLeg() {
        return firstLeg;
    }
}

public static class Leg {
    private Integer id;

    public void setId(final Integer id) {
        this.id = id;
    }

}

And here is how you can instantiate them with Iogi:

final Target<House> target = Target.create(House.class, "house");
final Parameter parameter = new Parameter("house.cat.firstLeg.id", "42");
final House house = iogi.instantiate(target, parameter);
assertThat(house.cat.firstLeg.id, is(equalTo(42)));

Installing with Maven

Altough some old versions can be found in mvnrepository, Iogi is currently distributed through sonatype repositories. So, if you are using maven, you can simply add the following dependency to your pom.xml:

<dependency>
	<groupId>br.com.caelum</groupId>
	<artifactId>iogi</artifactId>
	<version>0.9.2</version>
</dependency>

And add sonatype repository:

<repository>
	<id>sonatype-oss-public</id>
	<url>http://oss.sonatype.org/content/groups/public/</url>
	<releases>
		<enabled>true</enabled>
	</releases>
	<snapshots>
		<enabled>true</enabled>
	</snapshots>
</repository>

iogi's People

Contributors

ceci avatar csokol avatar danbev avatar dtelaroli avatar garcia-jj avatar lucascs avatar rafaeldff avatar sergiolopes 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.