spring-aop

Does AOP with AspectJ works with method from Managed Bean called from the view in JSF2?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 03:52:46
问题 I’m currently facing a Problem using a combination of JSF 2 and AOP with AspectJ annotation. I don't know if Spring AOP is playing a role here...(I didn't well understand difference between SPRING AOP, ASPECTJ, GOOGLE GUICE...that's an another question) I'm trying to send an e-mail after i added some values in my database via click on a form in jsf view. I have a managedBean AddPartipant handled by JSF (linked to a view) to add participant via a form. I want to intercept the method who makes

Spring AOP - Properly Configuring Retry Advice

为君一笑 提交于 2019-12-12 03:27:38
问题 I am new to Spring AOP and have been experimenting a bit. I am trying to setup Retry & Rate Limiter through Spring AOP for one of my project. The use case is like this:- Check if TPS is available. If not, throw ThrottledException If a ThrottledException is thrown, Retry . The issue I am running into is: This throttling & retry combo is running into an infinite loop (if TPS = 0). That is, retry is not stopping after 'x' attempts. My Throttling Interceptor is (at a high level) like this:

how to apply spring aop for legacy code by taking pointcut as input from user

南笙酒味 提交于 2019-12-12 03:20:12
问题 I have to apply Spring AOP for legacy code without changing anything in the existing code. There is no bean concept and the objects are created using new keyword, so no scope of using applicationContext.getBean("beanName"). Also the pointcuts will be taken as input from end user and there will be a common aspect class. For eg. package package1; public class Demo1 { public void method1() { System.out.println("From method1"); } public void method2() { System.out.println("From method2"); } }

How to pointcut hibernate when i use spring aop?

浪子不回头ぞ 提交于 2019-12-12 03:04:19
问题 I think as an entry point to the session, but seems to have failed. Whether my configuration? Here is my spring config. <bean id="aspect" class="org.bigbean.common.aop.DaoAspect" /> <aop:config> <aop:aspect ref="aspect"> <aop:around pointcut="execution(* org.hibernate.SharedSessionContract.createQuery(java.lang.String))" method="aroundAdvice" /> </aop:aspect> </aop:config> follow is my class public Object aroundAdvice(ProceedingJoinPoint pjp) throws Throwable { System.out.println(

how to get the object returned from joinPoint.proceed() with Spring AOP and WebFlux

泪湿孤枕 提交于 2019-12-12 01:16:50
问题 I have a simple aspect (see below) with @Around annotation. This aspect works when the the application don't use reactive paradigm. But when the application returns Mono or Flux doesn't works properly. I need to get the object returned from the method to generate a JSON object to use as log, generate events, etc. Here is my code that works in a non reactive classes: @Around("@annotation(simpleEvent)") public Object logExecutionTime(ProceedingJoinPoint joinPoint, SimpleEvent simpleEvent)

Why Spring AOP is not working for method call inside another method?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 01:12:10
问题 Why Spring AOP is not working for method call inside another method? public class TestAOPService { public String getSum(int val1) { System.out.println(val1); calculateSum(val1, 12); } public void calculateSum(int val1, int val2){ System.out.println("Sum" + (val1 + val2)); } } can anyone explain how to achieve this? 回答1: Because of how proxying works. For example, Spring creates a bean, an instance of type TestAOPService . Then it realizes it needs to proxy it to add aspect advice. It will

@Autowired doesn't work with interceptor

廉价感情. 提交于 2019-12-12 00:50:43
问题 I'm working on REST service which is developed using Apache-CXF. I'm using Spring 3.1 annotations for wiring the bean. I have written an interceptor which intercepts my REST method for monitoring purposes. To do this, i have to autowire my Monitor class which is added as library in my project. @Autowired doesn't seems to be working in this case and results into NPE. Am i doing anything wrong here ? @Aspect @Component public class ApplicationMonitoring { Logger logger = LoggerFactory.getLogger

Extracting the annotation value using java reflection?

邮差的信 提交于 2019-12-11 22:06:37
问题 I have below classes. I autowired someDao in service class as @Autowired SomeDao someDao . I call the logic in service as someDao.getName(2); SomeServiceImpl.java public class SomeServiceImpl{ @Autowired SomeDao someDao //call dao methods using someDao } SomeDao.java public interface SomeDao{ String getName(Int id); } SomeDaoImpl.java public class SomeDaoImpl implements SomeDao{ @CustomAnnotation("somevalue") public String getName(int id){ //logic } } SomeAspect.java @Around("execution(public

Exclude a specific method call (inside another method) from aspectj

谁说我不能喝 提交于 2019-12-11 18:55:24
问题 I'm trying to exclude a specific method call inside another method from being intercepted: public Class A { public void foo1() {...} public void foo2() { foo1(); } } I only want to exclude the foo1 calls made from foo2, and not the other calls: someAObject.foo1() & someAobject.foo2() should be included. Does anyone know how to do this using spring aop? Thanks! 回答1: This should work: execution(* A.*(..)) && !execution(* A.foo2(..)) 回答2: I would recommend you stop using spring, barring that, if

spring @Transactional JDBC Template MySQL DB not rolling back

孤街醉人 提交于 2019-12-11 17:52:52
问题 I am trying to implement the Spring @transactional with jdbc templates from the service layer calling 2 insert methods in a DAOImpl and using simplejdbctemplate to the insert and i see in the logs that spring creates a new transaction on my service method and my first insert suceeds and the second insert fails and even though it says it is rolling back on the same connection the first insert never get rolled back from my Mysql DB.(i am using innodb engine). Here is my service method. @Service