-
Notifications
You must be signed in to change notification settings - Fork 11
Spring Integration Guide
germanescobar edited this page Jul 6, 2012
·
10 revisions
Integrating Jogger with Spring is really easy. Just add the following dependency to your pom.xml file:
<dependency>
<groupId>org.jogger</groupId>
<artifactId>jogger-spring</artifactId>
<version>0.3.0</version>
</dependency>
That's it! Now, define your controllers in your Spring configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="pages" class="com.mycompany.controllers.Pages" scope="prototype">
...
</bean>
<!-- define other controllers and beans -->
</beans>
Now, use the bean id as the name of the controller in the WEB-INF/routes.config
file:
GET / pages#index
GET /about pages#about
...
##Interceptors
You can also define your interceptors in the Spring configuration file. To configure them just create a class that extends org.jogger.config.spring.SpringInterceptors
and register it in the web.xml
file. For example:
public class AppInterceptors extends SpringInterceptors {
@Override
public void initialize() {
// add interceptors using the Spring bean id
add("securityInterceptor");
add("loggingInterceptor");
}
}
Now, configure the class in the JoggerServlet
definition of the web.xml
file:
<servlet>
<servlet-name>JoggerServlet</servlet-name>
<servlet-class>org.jogger.JoggerServlet</servlet-class>
<init-param>
<param-name>interceptorsClass</param-name>
<param-value>com.mycompany.interceptors.AppInterceptors</param-value>
</init-param>
</servlet>
That's it.