Announcement Announcement Module
Collapse
No announcement yet.
Hot plug rescan context to search "@RequestMapping" annotations. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hot plug rescan context to search "@RequestMapping" annotations.

    Hi all,
    I try to solve my problem for weeks but still i did not succeed. I am here to seek help.

    I would like to have a plugins architecture.
    Loading at runtime "controller" class (uploading a zip file) I would make Spring rescan the context in search of the "@RequestMapping" annotations .

    In my x-servlet.xml i've:
    Code:
        <context:component-scan base-package="org.chakra" >
    	    //core controllers
            <context:include-filter type="regex" expression="org.site.core.controller.*"/>
    		//hot plugged plugins
            <context:include-filter type="regex" expression="org.site.apps.*.controller.*"/>
        </context:component-scan>
    I use a custom classloader to "addCustomRepositoryOrLocation" the new package to classpath and it works.

    This is the result of my recent experiments for add to the context new Controller:
    Code:
             //I recover webAppContext and applicationContext from my CustomContextListener 
             //MyContextListener extends ContextLoaderListener implements ServletContextListener
    
            AutowireCapableBeanFactory factory = ((XmlWebApplicationContext) webAppContext).getAutowireCapableBeanFactory();
            //AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory();
            BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
    
            ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(registry);
            scanner.scan("org.site.apps.MyFirstApp.controller");
            ((XmlWebApplicationContext) webAppContext).refresh();
    Nothing seems to work.

    I would be very grateful for any help.

    Thanks,
    Gabriele

  • #2
    OK, there is a linked hashmap in the DefaultAnnotationHandlerMapping(AbstractUrlHandler Mapping) class.

    Now, how to get the bean for AbstractUrlHandlerMapping? With a instance, i could call the registerHandler method.

    Thanks,
    Gabriele

    Comment

    Working...
    X