Access your Java components from Ruby Actions.
Here we examine Ruby based controllers, and the invoking of Java
functionaility from them. Consider:
A
DAO, PersonDAOImpl, is registered under the name "person_dao" and we
have
one Ruby based controller available. Now its probably safe to assume
that this Ruby PersonController will need access to that DAO object.
Gaining
access to this DAO from the controller is easy in Waffle, just call the
locate method:
Notice
that we were able to retrieve the DAO by its interface. Additionally,
since this DAO was registered with a key you can use a convention to
retrieve the component. The convention is "locate_<component
key>", here is the same controller using the locate_ convention:
As
you can see this makes writing Ruby based Controllers/Actions with
Waffle really easy. In my next post I'll detail how to access request
parameter and context attributes with ease.