spring-aop

Exception handling through spring AOP + Aspectj

早过忘川 提交于 2019-12-30 03:25:10
问题 In my project I have a domain layer which is basically POJO and a Spring controller / service layer that is sitting on top of the domain layer. I also have an AOP layer which is sitting between the service and domain. My domain layer is throwing business exceptions which are now being handled in the service layer. However I want to change it so that exception thrown from domain layer will be handled in the AOP layer. AOP layer will some kind of error response and send it back to spring

Basic AOP program throws BeanCurrentlyInCreationException

偶尔善良 提交于 2019-12-29 08:52:09
问题 I am creating a simple AOP program and starting getting BeanCurrentlyInCreationException exception with it. Here is my code: MyAspect.java package aspect; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; @Aspect //@Component public class MyAspect { @Pointcut("execution(public * *(..))") private void anyPublicOperation() { } @Before("anyPublicOperation()") private

Spring AOP - Invoking advice from catch block

橙三吉。 提交于 2019-12-29 07:58:11
问题 Purpose: Send an email to admin every time an exception occurs while executing business logic. Till now I have come across "throwing advice" which is fine and gets executed when an exception is raised from the target method. This could have worked well for me but I have to do some additional processing in terms of setting request attribute and next page. I don't think it would be a good idea to share the objects from target class with advice by making those objects static. The code scenario

The Old “@Transactional from within the same class” Situation

送分小仙女□ 提交于 2019-12-29 04:44:06
问题 Synopsis of the original question: Using standard Spring Transactions with AOP proxying, it is not possible to call an @Transactional-marked method from a non-@Transactional-marked method in the same class and be within a transaction (specifically due to the aforementioned proxy). This is supposedly possible with Spring Transactions in AspectJ mode, but how is it done? Edit: The full rundown for Spring Transactions in AspectJ mode using Load-Time Weaving: Add the following to META-INF/spring

AOP MethodInterceptor breaks struts2 Action/page

谁都会走 提交于 2019-12-25 17:01:45
问题 I am having a wierd issue with struts2 and aop. I need to intercept certain struts2 actions for checking some custom settings. The actions are getting intercepted but it breaks all page parameters/form values etc: The AOP configuration is: <aop:advisor id="associateModuleCheck" advice-ref="associateModuleAdvice" pointcut="execution(* uk.co.company.package.webapp.action.*.ModuleA*.*(..))" order="1"/> And the method Interceptor public Object invoke(MethodInvocation invocation) throws Throwable

Pointcuts are not triggered

元气小坏坏 提交于 2019-12-25 16:58:12
问题 I have a Spring 3.2.4 MVC application and I want to use Spring AOP. Hence, I have created a config file with an <aop:aspectj-autoproxy /> . I also have written an Aspect (adopted to code found in the web): @Component @Aspect public class PerformanceMonitoring { private static final Logger logger = Logger.getLogger(PerformanceMonitoring.class); public PerformanceMonitoring() { System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++"); } // @Around("execution(* com.silabs.moka.*(..

Pointcuts are not triggered

大兔子大兔子 提交于 2019-12-25 16:57:12
问题 I have a Spring 3.2.4 MVC application and I want to use Spring AOP. Hence, I have created a config file with an <aop:aspectj-autoproxy /> . I also have written an Aspect (adopted to code found in the web): @Component @Aspect public class PerformanceMonitoring { private static final Logger logger = Logger.getLogger(PerformanceMonitoring.class); public PerformanceMonitoring() { System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++"); } // @Around("execution(* com.silabs.moka.*(..

Combining two pointcuts but with parameters (if is possible)

徘徊边缘 提交于 2019-12-25 09:08:44
问题 For a Spring application project, before to delete or update something (an entity) I want before check if that object exists. I have the following: @Pointcut("execution(* com.manuel.jordan.service.impl.PersonaServiceImpl.deleteOne(String)) && args(id)") public void deleteOnePointcut(String id){} @Pointcut("execution(* com.manuel.jordan.service.impl.PersonaServiceImpl.updateOne(com.manuel.jordan.domain.Persona)) && args(persona)") public void updateOnePointcut(Persona persona){} If I use:

Advise method error in Spring AOP

别等时光非礼了梦想. 提交于 2019-12-25 08:57:38
问题 I'm trying to run an advise in a Spring AOP program but I keep getting this error: Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.sun.javafx.application.LauncherImpl

Spring aspect call on custom annotation on interface method

a 夏天 提交于 2019-12-25 08:48:38
问题 I have this interface: public interface FakeTemplate { @CustomAnnotation void foo() { } } And this implementation of the interface: @Component public FakeImpl implements FakeTemplate { @Override public void foo() { //Do Stuff } } And this aspect: @Aspect @Component public class CustomAspect { @Before(value = "@annotation(com.fake.CustomAnnotation)") public void doStuffBefore(JoinPoint joinPoint} { } } I'm using spring with AspectJ enabled using: @EnableAspectJAutoProxy(proxyTargetClass = true