All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zeroturnaround.javarebel.integration.spring.SpringMvcPlugin Maven / Gradle / Ivy

package org.zeroturnaround.javarebel.integration.spring;

import org.zeroturnaround.javarebel.ClassResourceSource;
import org.zeroturnaround.javarebel.IntegrationFactory;
import org.zeroturnaround.javarebel.Plugin;
import org.zeroturnaround.javarebel.integration.spring.cbp.AbstractDetectingUrlHandlerMappingCBP;
import org.zeroturnaround.javarebel.integration.spring.cbp.AnnotationMethodHandlerAdapterCBP;
import org.zeroturnaround.javarebel.integration.spring.cbp.DefaultAnnotationHandlerMappingCBP;
import org.zeroturnaround.javarebel.integration.spring.cbp.DispatcherServletCBP;

/**
 * JavaRebel Spring plugin that manages Spring metadata reloading.
 * 
 * @author Jevgeni Kabanov
 */
public class SpringMvcPlugin implements Plugin{
  
  public void preinit() {
    ClassLoader cl = SpringMvcPlugin.class.getClassLoader();

    /*
     * Refreshes Handler list on every request. 
     */
    IntegrationFactory.getInstance()
    .addIntegrationProcessor(
        cl,
        "org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping", 
        new AbstractDetectingUrlHandlerMappingCBP());

    /*
     * Reloads Spring Bean definitions on every request (including rescanning classpath for new components).
     */
    IntegrationFactory.getInstance()
    .addIntegrationProcessor(
        cl,
        "org.springframework.web.servlet.DispatcherServlet", 
        new DispatcherServletCBP());
    
    /*
     * Disables @RequestMapping type-level handler cache.
     */
    IntegrationFactory.getInstance()
    .addIntegrationProcessor(
        cl,
        "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping", 
        new DefaultAnnotationHandlerMappingCBP());   


    /*
     * Disables @RequestMapping method-level handler cache.
     */
    IntegrationFactory.getInstance()
    .addIntegrationProcessor(
        cl,
        "org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter", 
        new AnnotationMethodHandlerAdapterCBP());   
  }
  
  public boolean checkDependencies(ClassLoader cl, ClassResourceSource crs) {
    return crs.getClassResource("org.springframework.web.servlet.DispatcherServlet") != null;
  }

  public String getId() {
    return "spring_plugin";
  }

  public String getName() {
    return "Spring Framework Plugin";
  }
  
  public String getDescription() {
    return "Supports adding new beans and adding new bean dependencies using annotations or XML. " +
           "Singletons will be reconfigured after the change. " +
           "It also supports adding or changing Spring MVC controllers or handlers.";
  }
  

  public String getAuthor() {
    return null;
  }

  public String getWebsite() {
    return null;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy