Skip to content

Instantly share code, notes, and snippets.

@danbev
Created November 1, 2012 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbev/3992808 to your computer and use it in GitHub Desktop.
Save danbev/3992808 to your computer and use it in GitHub Desktop.
JAX-RS Integration with AeroGear Controller

Integration point for a JAX-RS implementation in AeroGear Controller

This section will discuss how a JAX-RS implementation can be integrated and used with AeroGear Controller.

Background

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.

Integrating a JAX-RS implementation

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.

Deployment

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.

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