spring-aop

Using @Before aspect on @Controller methods with Spring doesn't work

喜你入骨 提交于 2019-12-11 04:06:56
问题 I have a web-app using Spring 3, where controllers are annotated with @Controller. The public methods of the controllers are annotated with @RequestMapping. This works perfectly fine. Now I want to do a check before invoking any of the public methods in the controllers. I've created a @Before aspect using a Pointcut expression that selects all controller methods annotated with @RequestMapping. I've registered the aspect using <aop:aspectj-autoproxy> <aop:include name="myAspect"/> </aop

Spring AOP: How exclude an unnecessary @Pointcut (@Around advice) execution due the execution from others @Pointcuts/advices

旧时模样 提交于 2019-12-11 04:02:22
问题 I am working with: Spring Framework 4.3.3 AspectJ 1.8.9 I have the following normal process: @Controller -> @Service -> @Repository I have the following pair about AOP : PersonaServicePointcut PersonaServiceAspect The scenario is the following: The @Service class has some methods such as: delete , save , update and findOneById . They are declared together within the same class. For the methods such as delete and update through AOP I am using a @Before or @Around advice to call the findOneById

Load time weaving for non-spring beans in a spring application

帅比萌擦擦* 提交于 2019-12-11 03:34:49
问题 I have a spring boot application with some REST controllers, service classes and helper classes. The controllers and service classes are spring managed while helper classes are not spring managed and mostly contain static methods. The AspectJ configuration is present in java configuration as follows @Configuration @EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.ENABLED) public class AspectConfig { @Bean public LoggingAspect loggingAspect() { return new LoggingAspect(); } } The

UnsupportedPointcutPrimitiveException on simple AOP example

…衆ロ難τιáo~ 提交于 2019-12-11 03:27:25
问题 I try to run a simple aop example in this site. I have spring aop and aspectj, aspectjweaver jars: @Aspect public class StringAspect { @Pointcut("call(* String.toLowerCase())") public void toLowerCasePointcut() {} @Around("toLowerCasePointcut()") public String toLowerCaseAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable { String text = ((String) joinPoint.getTarget()).toUpperCase(); return text; } } When I run this example in Test.java like "AaBbCc".toLowerCase(), I get this

Spring AOP and apache shiro configuration.Annotations not been scanned

喜夏-厌秋 提交于 2019-12-11 03:13:22
问题 I've been struggling with a configuration which requires a knowledge in AOP. i must admit that AOP is that part i'm trying to get for a while without success. It seems that my shiro annotations are not scanned and thus are ignored. i've tried using shiro 1.1.0+ maven3+spring 3.0.5.RELEASE, hibernate 3.6.1.Final with ZK 5.0.6. i got my hibernaterealm working , talking to database, i got the authentication working, i successfully(i believe) get the roles and permission loaded. so to test the

Spring MVC and AOP: @Pointcuts for @Controllers only works in Testing and not for Production

无人久伴 提交于 2019-12-11 03:09:23
问题 I am working with Spring Framework 4.3.3 in a Web Environment: I have two contexts: RootApplicationContext ServletApplicationContext I know the ServletApplicationContext contains all the beans about the web side, for example @Controller . Furthermore ServletApplicationContext is able to access all the context or beans from the RootApplicationContext for example @Service, @Repository etc. Until here I am fine. Note it applies for @Configuration classes too. (Infrastructure) Therefore with the

How to ignore default exception handling advice when it is already handled by another advice

时光毁灭记忆、已成空白 提交于 2019-12-11 01:36:47
问题 I currently have a ExceptionAdvice class where it handles all the basic (400, 405, 404 and Other) Exceptions. For example I have a default advice where it handles all MethodArgumentNotValidExceptions and returns 400 Bad Request Error. For example @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(MethodArgumentNotValidException.class) public Error handleBadRequestException(Exception exception) { return buildError(extractTriggerElement(exception), exception); } I also have a different

can @Order be applied on @Transactional?

混江龙づ霸主 提交于 2019-12-10 17:24:19
问题 I have a method which is annotated with @Transactional and another custom annotation @Custom. This custom annotation is wrapped around an advice. The sequence of operation is like below: 1.Transactional method gets called 2.Sees @Transactional and @Custom 3.As @Custom is intercepted by around advice, it first executes code before invocation of method 4.invocationContext.proceed() 5.Transaction gets created 6.Actual method runs 7.Back to around advice and executes code after method invocation

Can't find referenced pointcut

风格不统一 提交于 2019-12-10 17:17:14
问题 I'm developing my first aspect and I'm encountering the following trouble. MyAspect class: @Component @Aspect public class MyAspect{ @Pointcut("execution(* com.mypackage.MyClass.method(..))") public void sendComunication(){} @AfterReturning("sendComunication()") public void sendComunicationMail() { //TODO somethings } } Then i added "aop:aspectj-autoproxy" and aop namespace in the applicationContext. Now when i try to build my application, i get this error: Caused by: org.springframework

How to set Spring weaver options in Java config class?

做~自己de王妃 提交于 2019-12-10 17:09:36
问题 I am using Spring AOP with the provided default DefaultContextLoadTimeWeaver . I would like to be able to weave persisted entities and I know I have to set a weaver option (warning from console): warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified My search only found examples for the configuration in a .xml file, but I would really prefer this to be in my Java configuration class, where all my configurations are. Is there