spring-aop

Exception handling and after advice

不想你离开。 提交于 2019-12-02 09:30:56
I am using AOP with spring boot. After some method execution successfully I am using @After advice in AOP to do some data base insertion. There is one case if the method throw an exception somewhere then I don't want to execute my @After advice call. I don't have any idea if I catch exception in AOP also my after advise method will going to execute. @After(value = "execution(* saveUpdateMeasures(..)) and args(addMeasure)") public void afterAdviseMeasure(JoinPoint joinPoint,AddMeasures addMeasure) throws Exception { logger.info("url is " + request.getRequestURL() + "?" + request.getQueryString(

Spring AOP: How to read path variable value from URI template in aspect?

大兔子大兔子 提交于 2019-12-02 08:09:21
问题 I want to create Spring aspect which would set method parameter, annotated by custom annotation, to an instance of a particular class identified by an id from URI template. Path variable name is parameter of the annotation. Very similar to what Spring @PathVariable does. So that controller method would look like: @RestController @RequestMapping("/testController") public class TestController { @RequestMapping(value = "/order/{orderId}/delete", method = RequestMethod.GET) public ResponseEntity<

Error: java.lang.NoSuchMethodError: org/springframework/asm/ClassVisitor.<init>(I)V

梦想的初衷 提交于 2019-12-02 07:39:26
I have these two dependencies in my POM which are i think creating this issue but i have tried many different ways and updated versions but nothing worked for me. Can someone please help. POM.XML <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>4.2.0.RELEASE</version> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.2</version> </dependency> Solution to your Question It seems there is a JAR conflict while managing your dependencies. In Spring 4.2.0, the ClassVisitor class have been included in Spring

Aspect for method annotated with annotation which are annotated with another annotation

左心房为你撑大大i 提交于 2019-12-02 05:52:53
Is it possible to make pointcut using Spring AOP for methods and type having annotation which was annotated with some annotation. Here's my custom annotation: @AccessRestriction @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface HasPermission { } It annotated with this annotation: @Target({ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface AccessRestriction { } So is it possible to create point cut which will handle all methods which are annotated with any annotation annotated with AccessRestriction. I found

@AspectJ Based AOP with Spring 3.1

只愿长相守 提交于 2019-12-02 05:18:41
问题 I am trying to run a @AspectJ Based AOP with Spring 3.1 & not able to configure pointcut properly Pointcut and advice methods are : Pointcuts: @Pointcut("execution(* point.*.*(..))") public void selectAll() {} after advice: @After("selectAll()") public void afterAdvice() { System.out.println("profile has been setup."); } before advice: @Before("selectAll()") public void beforeAdvice() { System.out.println("Going to setup profile."); } & run main program i got Exception: Exception in thread

Spring AOP: How to read path variable value from URI template in aspect?

大憨熊 提交于 2019-12-02 03:08:46
I want to create Spring aspect which would set method parameter, annotated by custom annotation, to an instance of a particular class identified by an id from URI template. Path variable name is parameter of the annotation. Very similar to what Spring @PathVariable does. So that controller method would look like: @RestController @RequestMapping("/testController") public class TestController { @RequestMapping(value = "/order/{orderId}/delete", method = RequestMethod.GET) public ResponseEntity<?> doSomething( @GetOrder("orderId") Order order) { // do something with order } } Instead of classic:

Using Ajc compiler with Spring problem AspectJ

寵の児 提交于 2019-12-02 03:08:40
when i am trying to aspectj with spring using ajc compiler ,i am getting following errror.when i am removing aspectj then code is working fine is there anything with the compile time weaving which is causing problem caused by: java.lang.ExceptionInInitializerError at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java

Clarification around Spring-AOP pointcuts and inheritance

回眸只為那壹抹淺笑 提交于 2019-12-02 03:05:27
问题 Given the following example classes in my.package ... public class Foo { public void logicNotInBar() {/*code*/} public void logicBarOverrides() {/*code*/} } public class Bar extends Foo { public void logicBarOverrides() {/*code*/} } and the following Spring-AOP pointcuts... <aop:pointcut id="myPointcutAll" expression="execution(* my.package.*.*(..))" /> <aop:pointcut id="myPointcutFoo" expression="execution(* my.package.Foo.*(..))" /> <aop:pointcut id="myPointcutBar" expression="execution(*

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

空扰寡人 提交于 2019-12-02 02:08:37
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 corresponding LoggingAspect class is as follows, @Aspect public class LoggingAspect { @Before(

Clarification around Spring-AOP pointcuts and inheritance

ぐ巨炮叔叔 提交于 2019-12-02 00:48:03
Given the following example classes in my.package ... public class Foo { public void logicNotInBar() {/*code*/} public void logicBarOverrides() {/*code*/} } public class Bar extends Foo { public void logicBarOverrides() {/*code*/} } and the following Spring-AOP pointcuts... <aop:pointcut id="myPointcutAll" expression="execution(* my.package.*.*(..))" /> <aop:pointcut id="myPointcutFoo" expression="execution(* my.package.Foo.*(..))" /> <aop:pointcut id="myPointcutBar" expression="execution(* my.package.Bar.*(..))" /> What is the result of advice applied to the above pointcuts on instances of