2

I cannot figure how should interceptor works as I have some MadvocAction with an @Intercepted annotation but the interceptor stack does not seems to be accessed.

@MadvocAction("index")
public class IndexAction extends AppAction {

@PetiteInject
private TemperatureService temperatureService;

@Action
@InterceptedBy(AppInterceptorStack.class)
public void view() {
    // body here ....
}

and the interceptor stack:

package ro.videanuadrian.smartHome.web.interceptors;

import jodd.joy.madvoc.interceptor.DefaultInterceptorStack;
import jodd.madvoc.interceptor.ActionInterceptorStack;
import jodd.madvoc.interceptor.EchoInterceptor;

public class AppInterceptorStack extends ActionInterceptorStack {

public AppInterceptorStack() {

    super(
        AppAuthenticationInterceptor.class,
        EchoInterceptor.class,
        DefaultInterceptorStack.class
    );
}
}

any idea ?

updated with madvoc config: so this is in my web.xml:

  <filter>
    <filter-name>madvoc</filter-name>
    <filter-class>jodd.madvoc.MadvocServletFilter</filter-class>        
    <init-param>
        <param-name>madvoc.webapp</param-name>
        <param-value>ro.videanuadrian.smartHome.config.SmartHomeWebApplication</param-value>
    </init-param>
     <init-param>
        <param-name>madvoc.params</param-name>
        <param-value>/madvoc.props</param-value>
    </init-param>         
</filter>  

and this is how my Madvoc it1s initialized:

public class SmartHomeWebApplication extends PetiteWebApplication {

final SmartHomeServiceCore serviceCore;

public SmartHomeWebApplication() {
    serviceCore = new SmartHomeServiceCore();
    serviceCore.start();     
}


/**
 * Adds configurator to Madvoc container and invokes configuration.
 */
@Override
public void configure(MadvocConfigurator configurator) {

    if (configurator instanceof AutomagicMadvocConfigurator){
        AutomagicMadvocConfigurator amc = (AutomagicMadvocConfigurator) configurator;
        amc.setExcludeAllEntries(true);
        amc.setIncludedEntries("ro.videanuadrian.*");

        registerComponent(amc);
        amc.configure();
    }
}  

also the madvoc.props:

 madvocConfig.defaultInterceptors=ro.videanuadrian.smartHome.web.interceptors.AppInterceptorStack

 madvocConfig.fileUploadFactory.maxFileSize=-1  

after your answer I have commented madvocConfig.defaultInterceptors but the result was the same.

igr
  • 10,199
  • 13
  • 65
  • 111
Videanu Adrian
  • 972
  • 3
  • 16
  • 41

1 Answers1

0

What you did here seems perfectly fine. However, there is one reason why annotations may NOT work: do you maybe use madvoc-routes.txt?

As explained here, an alternative way for defining actions and interceptors is using this configuration file with routes. If this is enabled, you may experience ignorance of annotations.

Please check if this is true, and if so:

  • either define interceptors in the routes file
  • or remove routes and go annotation-only configuration.

If this is not a case, then you find out something specific (bug, in other words;), although this functionality is very basic - still, feel free to fire issue on github if so :)

EDIT

I have made the webapp example that seems to mimic everything what you did. My intreceptor gets called. Would you be kind to check it?

igr
  • 10,199
  • 13
  • 65
  • 111
  • @VideanuAdrian Ive just mad an example on github. Everything seems fine from what you wrote. Would you be so kind to check my example? – igr Mar 29 '16 at 20:18