Working with a Spring enabled Controller

Creating a controller

The philosphy of Brico is of open collaboration between other projects, that is why it includes a way for configuring a Controller using the Spring Framework, support for other containers may be avilable in the future. As demosntrated in the first tutorial, you need to configure the Controller with a group of Commands, Forms and FilterInjectors (if any). The folowing set of xml files will show the basic configuration: The first XML file defines a Controller and a MorpherRegistry (used by the default implementation of RequestHandler).

The second XML file defines the available commands.

The third and last XML file defines the forms used by the commands.

Configuring the controller

You may configure a group of properties for your controller, taking into account that if one of them is left, a default option would be used. This gives you the freedom of configuring what you need instead of what the component needs. The following is a list of configurable properties of the MapBackedController and their default values:
Property Default value
name name give to bean.

You should name your controllers if you intend to use more than one in the same JVM process.
contextFactory net.sf.brico.cmd.base.DefaultContextFactory
responseFactory net.sf.brico.cmd.base.DefaultResponseFactory
requestHandler net.sf.brico.cmd.RequestHandler
exceptionConfig

exceptionConfigs
*EMPTY*

Using the controller

To use your newly configurated controller you need a RequestFactory that will let you create Request instances, configure it with the desired command to be execute along with any properties that may be used in its Form and then call the process() method of your controller, like the following example: