[infinispan-issues] [JBoss JIRA] (ISPN-6496) Custom interceptor's start method not called if interceptor added via AdvancedCache

Dan Berindei (Jira) issues at jboss.org
Fri Mar 13 04:32:05 EDT 2020


     [ https://issues.redhat.com/browse/ISPN-6496?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Berindei closed ISPN-6496.
------------------------------
    Resolution: Won't Do


The reason the interceptor is not started is not because it's added after the cache has started, but because it is not registered in the component registry.

You can use {{cache.getAdvancedCache().getComponentRegistry().registerComponent(new LocalIndexInterceptor(), LocalIndexInterceptor.class)}}, and both the injection and lifecycle methods will be invoked.

> Custom interceptor's start method not called if interceptor added via AdvancedCache
> -----------------------------------------------------------------------------------
>
>                 Key: ISPN-6496
>                 URL: https://issues.redhat.com/browse/ISPN-6496
>             Project: Infinispan
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 8.1.2.Final
>            Reporter: Jiří Holuša
>            Priority: Major
>
> Suppose I want to add trivial custom interceptor like this:
> {code}
> public class LocalIndexInterceptor extends BaseCustomInterceptor {
>     @Override
>     protected void start() {
>         System.out.println("Start method executed");
>     }
>   // override some command methods here   
> }
> {code}
> When I attach the interceptor via: 
> {code}
> cache.getAdvancedCache().addInterceptor(new LocalIndexInterceptor(), 0);
> {code}
> the start method never gets called and nothing is printed. When I add the interceptor during the cache configuration (via ConfigurationBuilder.customInterceptor().addInterceptor().interceptor()), everything works fine and the start method is executed.
> I noticed at the @Start annotation Javadoc: "Method level annotation that indicates a (no-param) method to be called on a component registered in the ComponentRegistry when the cache starts.", so I get it that it's not executed since the cache is already started. However, without the start() method being executed, I cannot access cache additional object (DistributionManager, RpcManager) in the interceptor, which might be needed (and I needed it :) ).



--
This message was sent by Atlassian Jira
(v7.13.8#713008)



More information about the infinispan-issues mailing list