This section will discuss how a JAX-RS implementation can be integrated and used with AeroGear Controller.
An application that uses AeroGear Controller is deployed as a web application archive (WAR), with the aerogear-controller.jar in the WEB-INF/lib directory. Upon deploying the WAR, the servlet container will scan the deployment for @WebFilter annotation (among other things). AeroGear Controller contains such a servlet filter named AeroGear. All request to the web application will go through the AeroGear filter. AeroGear gets injected with a Router instance which is able to dispatch to the routes that the end users has configured.
A JAX-RS provider needs to provide an implementation of the AbstractRestRouter class:
public abstract class AbstractRestRouter extends Router {
public abstract void init(FilterConfig filterConfig);
public abstract void registerRoutes();
public abstract void unregisterRoutes();
}
init()
method gives a router implementation access to the FilterConfig instance if it needs some configuration data to exist in web.xml for example.
registerRoutes()
is where the RestRouter implementation would register the configured routes with its runtime engine.
unregisterRoutes()
is where the RestRouter implementation would unregister the configured routes with its runtime engine.
The RestRouter implementation should be packaged as a jar, and made available in the WEB-INF/lib directory of the deployment. The CDI container will inject the RestRouter implementation into AeroGear Controller.