Advise the call to the constructor of DefaultCacheResolverFactory with around 
advice, catch the exception, then return what you want to.  Note: don't use an 
"execution" pointcut expression -- you want a "call".

> On Aug 8, 2019, at 9:20 AM, Eric B <ebenza...@gmail.com> wrote:
> 
> I'm using the JCache API, in which a design decision made by the JSR-107 team 
> in implementing the Reference Implementation is causing me a significant 
> headache.  The class in question is: 
> org.jsr107.ri.annotations.cdi.CacheLookupUtil from package 
> org.jsr107.ri:cache-annotations-ri-cdi:1.1.0.  
> 
> This is the layout of the class:
> 
> public class CacheLookupUtil extends 
> AbstractCacheLookupUtil<InvocationContext> {
>   @Inject
>   private BeanManagerUtil beanManagerUtil;
> 
>   private CacheKeyGenerator defaultCacheKeyGenerator = new 
> DefaultCacheKeyGenerator();
>   private CacheResolverFactory defaultCacheResolverFactory = new 
> DefaultCacheResolverFactory();
> 
>   ...
>   ...
> }
> 
> My problem is the assignment of the defaultCacheResolverFactory, or to be 
> even more specific the construction of the DefaultCacheResolverFactory() 
> without arguments when initializing the object.  The default constructor used 
> throws an exception which is extremely difficult to catch given that the DI 
> framework is instantiating the object.
> 
> Is there anyway I can use AspectJ to modify that assignment?  Ideally, I 
> would like to prevent the construction of the DefaultCacheResolverFactory 
> with no args, and replace it with a call to new 
> DefaultCacheResolverFactory(CacheManager) instead.
> 
> So my issue is not just being able to assign the field (which I would be able 
> to do in a CacheLookupUtil constructor advice, but also prevent the 
> construction of the DefaultCacheResolverFactory().   
> 
> Can you think of any kind of pointcut(s) that I could use to catch that 
> condition?  I figure I need an Around advice against a pointcut which picks 
> up the constructor of the DefaultCacheResolverFactory (so I can return my own 
> object instead), but from what I understand I cannot use around with the 
> initialization pointcut.
> 
> Any suggestions what I can try?
> 
> Thanks,
> 
> Eric
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@eclipse.org
> To change your delivery options, retrieve your password, or unsubscribe from 
> this list, visit
> https://www.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://www.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to