spring-aop

nullpointer exception in aspectJ example

我只是一个虾纸丫 提交于 2019-12-10 15:25:25
问题 I am trying to implement one of the suggestion given by our stackoverflow member here Logging entry, exit and exceptions for methods in java using aspects . Since this is different question in itself, posting here again. I have tried to search but looks like different versions have different ways of doing it and unable to figure out an example online. I have tried the following simple example since I am new to aspect oriented programming and couldn't figure out how to implement. This example

Spring Boot AOP load time weaving

China☆狼群 提交于 2019-12-10 14:54:19
问题 Not sure what is going wrong, but AOP just doesn't seem to be working in my setup with spring boot (v1.1.6). @Configuration @ComponentScan @EnableJpaRepositories @EnableTransactionManagement @EnableAutoConfiguration @EnableCaching @EnableLoadTimeWeaving public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } And in the aspect class @Aspect public class MyAspect { @AfterReturning(pointcut = "execution(private * com.myapp.service

using Spring @Profile in @Aspect

风流意气都作罢 提交于 2019-12-10 13:33:23
问题 So what i want is to apply an specific Spring Aspect to my classes when an profile is active, but i can't find a solution, i try the way proposed in http://city81.blogspot.com/2012/05/using-spring-profile-with.html but is quite old and don't work in my case, i have a Spring Started project for testing and i do the following based on the link: configuring the Application: @Configuration @ComponentScan(basePackages= { "demo", "demo.aspect" }) @EnableAutoConfiguration(exclude

what is the difference between @within and @annotation in AOP

↘锁芯ラ 提交于 2019-12-10 11:40:22
问题 @within This PCD limits matching to join points within types that have the given annotation: @Pointcut("@within(org.springframework.stereotype.Repository)") @annotation This PCD limits matching to join points where the subject of the join point has the given annotation. For example we may create a @Loggable annotation: @Pointcut("@annotation(org.baeldung.aop.annotations.Loggable)") public void loggableMethods() {} So does it mean that @annotation only applies for user defined or custom

Spring SOAP webservice endpoint with Spring AOP

回眸只為那壹抹淺笑 提交于 2019-12-10 11:16:44
问题 I am developing a webservice using spring soap implementation and hence my service class is annotated with @Endpoint annotation. Now, I want to use SPRING AOP for application logging which I have already implemented. However, as I have noticed, until I execlude my service class from the pointcut expression, I get no endpoint mapping found exception when my webservice is invoked. When I exclude the service classes from AOP's scope, things work fine again. Any idea on this? UPDATE: My logger

how to do logging of method chaining using spring aop

◇◆丶佛笑我妖孽 提交于 2019-12-10 07:43:23
问题 I am using slf4j with Spring AOP for logging and Exception purpose.there are some methods in some classes which formed a method chaining. I am able to log at first method's entry and exit point but when this method called another method then AOP is logging only first method's entry and exit point.I want to log every method's entry and and exit point using @Around annotation here is Pseudo code to explain what i want package com.sample; public class Test implements T{ @Override public void

How to pool objects in Spring?

烈酒焚心 提交于 2019-12-09 18:14:36
问题 I'm following this tutorial regarding how to pool objects in Spring. I've followed the instruction written on the tutorial but when I run my application, it always generates a new instance of the object. I'm expecting that since I'm pooling the objects, existing objects will be reuse. As such, no new instances should be created. Also, when I access of the getter method of the bean, a new instance of the bean is created again. What could have I done wrong? Did I misunderstood the concept of

Spring Batch @StepScope cannot generate CGLIB subclass

你说的曾经没有我的故事 提交于 2019-12-09 13:46:26
问题 EDIT I created a test project that replicates the issue. It can be found at https://github.com/tomverelst/test-batch. First run the maven command exec:java to start a HSQL database. Then you can run the JUnit test MigrationJobConfigurationTest to load the Spring application context. Original question When starting my Spring Batch application, I get the following exception when Spring is loading my job's configuration: Caused by: org.springframework.aop.framework.AopConfigException: Could not

Spring AOP Pointcut syntax for AND, OR and NOT

你。 提交于 2019-12-09 08:26:25
问题 I'm having trouble with a pointcut definition in Spring (version 2.5.6). I'm trying to intercept all method calls to a class, except for a given method (someMethod in the example below). <aop:config> <aop:advisor pointcut="execution(* x.y.z.ClassName.*(..)) AND NOT execution(* x.y.x.ClassName.someMethod(..))" /> </aop:config> However, the interceptor is invoked for someMethod as well. Then I tried this: <aop:config> <aop:advisor pointcut="execution(* x.y.z.ClassName.(* AND NOT someMethod)(..)

injecting mock beans into spring context for testing

落花浮王杯 提交于 2019-12-08 23:10:19
问题 I know similar questions have been asked, e.g. here, but having done a search, I've come upon a solution I'm much happier with here My only problem however, is that I'm not sure how to implement this solution. What I want to be able to do is via the HotswappableTargetSource override the bean definitions of select beans in my application context with my test versions and then run the test. Then for each test case I'd like to specify which beans I want to be hot swappable and then each test