Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating Spring Batch Admin into an existing application

I have an application which uses Spring Batch and Spring MVC. I am able to deploy Spring Batch Admin as a separate war and use it against the same DB my application uses, though I would like to integrate it into my own application, possibly modify some of the views as well.

Is there an easy way to do this or do I have to fork it and go from there?

like image 436
abalogh Avatar asked Jun 22 '11 10:06

abalogh


2 Answers

There is an easy way apparently according to this thread;

  • Define a DispatcherServlet for Batch Admin in web.xml:

    <servlet>
        <servlet-name>Batch Servlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>Batch Servlet</servlet-name>
        <url-pattern>/batch/*</url-pattern>
    </servlet-mapping>
    
  • Add an override for resourceService in the root appContext:

    <bean id="resourceService"
    class="org.springframework.batch.admin.web.resources.DefaultResourceService">
        <property name="servletPath" value="/batch" />
    </bean> 
    
  • Modify standard.ftl in spring-batch-admin-resources-1.2.0-RELEASE.jar to reflect the URL:

    <#assign url><@spring.url relativeUrl="${servletPath}/resources/styles/main.css"/></#assign>

like image 190
abalogh Avatar answered Oct 19 '22 02:10

abalogh


If you are using Spring-batch-admin 1.2.1, you don't have to modify standard.ftl file. And you should add both servlet-config.xml and webapp-config.xml files from org/springframework/batch/admin/web/resources. Here are the steps (repeated again):

    <servlet>
        <servlet-name>Batch Servlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml,classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

Add resourceService bean in your applicationContext:

<bean id="resourceService"
class="org.springframework.batch.admin.web.resources.DefaultResourceService">
    <property name="servletPath" value="/batch" />
</bean>
like image 26
Keerthiram Murugesan Avatar answered Oct 19 '22 01:10

Keerthiram Murugesan