spring-aop

Spring factory-method=“aspectOf” is not working when we deploy the application from RAD

偶尔善良 提交于 2019-12-11 12:08:39
问题 We are using AspectJ with Spring support. I have declared my aspect in my ApplicationContext.xml as below. <context:annotation-config /> <context:spring-configured /> <context:component-scan base-package="com,com.util"> <context:exclude-filter type="regex" expression="com.xyz*.*" /> </context:component-scan> <bean id="xyz" class="com.util.XyzAspect" factory-method="aspectOf"/> Aspect Class: @Configurable @Aspect public class XyzAspect { @Autowired private XyzUtil xyzUtil; @After("showPoint()

Pointcut is malformed: Class must not be null

自闭症网瘾萝莉.ら 提交于 2019-12-11 11:59:18
问题 Out of a blue I'm getting " Pointcut is malformed: Class must not be null " error in Eclipse with a couple of Aspects classes. The code works fine but, without a change in those classes, Eclipse suddenly started reporting the error. I'm trying to track down if the source of the problem is a eclipse platform/plugin update or a project's dependency update. I'm using Spring Tool Suite Version: 3.7.1.RELEASE Build Id: 201510041213 Platform: Eclipse Mars.1 (4.5.1) and Spring IO Platform 2.0.0.

Spring autowired bean for @Aspect aspect is null

こ雲淡風輕ζ 提交于 2019-12-11 10:44:17
问题 I have the following spring configuration: <context:component-scan base-package="uk.co.mysite.googlecontactsync.aop"/> <bean name="simpleEmailSender" class="uk.co.mysite.util.email.simple.SimpleEmailSenderImplementation"/> <aop:aspectj-autoproxy/> Then I have an aspect: @Aspect public class SyncLoggingAspect { @Autowired private SimpleEmailSender simpleEmailSender @AfterReturning(value="execution(* uk.co.mysite.datasync.polling.Poller+.doPoll())", returning="pusher") public void afterPoll

Executing PointCut depending on Environment variable or property

若如初见. 提交于 2019-12-11 10:36:04
问题 I've developed a nice Spring Aspect which I can use to monitor my service operations performance. If some operations are taking a long time to execute, it logs them. @Aspect public class PerformanceMonitorAspect { private Logger logger = LoggerFactory.getLogger("performance"); @Pointcut("execution(* com.company.MyService+.*(..))") public void pointCut(){ } @Around("pointCut()") public Object profileServiceMethods(ProceedingJoinPoint thisJoinPoint) throws Throwable { MethodSignature ms =

Surefire way of checking whether aspectJ mode is working for spring transaction management

China☆狼群 提交于 2019-12-11 07:34:42
问题 I am working on a spring boot application. I have tried to enable AspectJ mode for transaction management as follows: @EnableTransactionManagement(mode = AdviceMode.ASPECTJ) I am suspecting the aspectJ mode is not working and I would like to know whether or not AspectJ mode is indeed enabled for my application. Can someone please provide a way to check that (e.g. through enabling a logger or debugging)? 来源: https://stackoverflow.com/questions/44115996/surefire-way-of-checking-whether-aspectj

How to get method execution flow in spring mvc interceptor

两盒软妹~` 提交于 2019-12-11 05:13:28
问题 I want to get the complete execution flow along with their execution time in spring mvc project. public class MetricsInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (handler instanceof HandlerMethod) { HandlerMethod hm = (HandlerMethod) handler; Method method = hm.getMethod(); if (method.getDeclaringClass().isAnnotationPresent(Controller.class)) { if (method

Spring introduction accessing original introduced class

[亡魂溺海] 提交于 2019-12-11 05:06:00
问题 I am trying to use Spring framework AOP to extend some class AImpl (which implements interface A) to be able to implement also new interface B. I am using @DeclareParents and implementing Aspect. Unfortunatelly I need to access some methods of A to be able to implement business logic within it. Does anyone knows better solution than adding A as a parameter to interface B method ? Does anybody used successfully Spring AOP introductions to extend class in such a way I need to ? All the samples

Spring MVC and AOP: @Pointcuts only apply for Rest Controllers and not for common Web Controllers

主宰稳场 提交于 2019-12-11 04:38:39
问题 I am working with Spring Framework 4.3.3 in a web environment. I have a @Controller used for Web requests through a Web Browser that uses how dependency other @Controller but for Rest purposes. It latter mentioned uses a @Service etc... This approach about a 'Web' using a 'Rest' how a dependency is explained in Content Negotiation using Spring MVC for the Combining Data and Presentation Formats section. Until here for development/testing and production works fine. It is a valuable approach.

Use Spring AOP in OSGi bundle

 ̄綄美尐妖づ 提交于 2019-12-11 04:19:09
问题 I am trying to use the Spring AOP for logging purposes. I have set up the logging bundle, and the OSGi service in it. I have other OSGi bundle which uses the service from logging bundle as a OSGi reference. The logging bundle is deployed into Apache Karaf and running. I can not get my other bundle deployed. The spring configuration in my bundle is like that: <osgi:reference id="loggingIterceptor" interface="com.groupgti.commons.log.LoggingInterceptorAdvice"/> <aop:config> <aop:pointcut id=

How to define rollback transactions which are called inside of a loop with spring aop?

百般思念 提交于 2019-12-11 04:09:38
问题 Previously I have created a method updateRecord() in com.TestTransaction class. The updateRecord() method has a for loop to insert values into database. If there is any exception thrown inside the loop all the inserted values will rollback. This works fine and code is like below: Inside the java class file public class com.TestTransaction{ ... //this is a big transaction public void updateRecord(){ for(int i=0;i<5;i++){ //insert value to database... //...if a runtime exception thrown here, /