Skip to content

Instantly share code, notes, and snippets.

@danbev
Created September 12, 2012 13:21
Show Gist options
  • Save danbev/3706552 to your computer and use it in GitHub Desktop.
Save danbev/3706552 to your computer and use it in GitHub Desktop.
What is Iogi used for in AeroGear Controller?

Iogi is used to unmarshall the HTTP Request and create a instance of a class, and populate that instance using values from the request parameters.

For example, when using the aerogear-controller-demo and entering the color and model of the car, the following parameters will be passed in the HTTP POST as form data:

car.color:red
car.brand:BMW

AeroGear Controller knows the type of the parameter for the target method, which it has gathered from the route configuration. By utilizing Iogi, it is very easy to create an instance of Car and populate its members color and brand:

LinkedList<Parameter> requestParameters = new LinkedList<Parameter>();
// populate the list with the request parameters/values

Target<?> target = Target.create(org.jboss.aerogear.controller.demo.model.Car.class, "car");
Car car = iogi.instantiate(target, requestParameters.toArray(new Parameter[]{}));

The actual code in AeroGear Controller does not look like this but hopefully this makes it easier to see what is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment