spring-aop

AfterReturning annotation not working for specific method structure

风格不统一 提交于 2019-12-13 04:36:18
问题 I am trying to use @AfterReturning of AspectJ to get return value of a specific function call. Not sure why @AfterReturning not working for the following method call. Though I am trying to use @AfterReturning on 2 methods of same class, 1 works when another didn't. Only difference between two methods are number of arguments, where @AfterReturning working for method with one argument. Working @AfterReturning( pointcut = "execution(org.springframework.http.ResponseEntity com.service

Spring AOP with AspectJ - Load time weaving doubts

孤街醉人 提交于 2019-12-13 04:04:52
问题 Reading the Spring AOP documentation (link), I'm having a hard time (maybe also because english is not my native language) understanding these paragraphs. First, I read Further, in certain environments, this support enables load-time weaving without making any modifications to the application server’s launch script that is needed to add -javaagent:path/to/aspectjweaver.jar or (as we describe later in this section) -javaagent:path/to/org.springframework.instrument-{version}.jar (previously

Pointcut confusion with inheritance

房东的猫 提交于 2019-12-13 03:37:13
问题 I am confused by writing a pointcut that matches all executions of a method. I tried the pointcut that should match all method-executions of class Alpha : execution(* Alpha.*(..)) with the following class-hierachy public class Alpha { public void alphaMethod() {...} } public class Beta extends Alpha { public void betaMethod() { alphaMethod(); } } If the Main-program calls alphaMethod on an Beta -instance my advice is called like expected but the Main-program calls betaMethod that also calls

Aspect on super interface method implemented in abstract super class

冷暖自知 提交于 2019-12-13 02:59:44
问题 I have a problem quite similar to: How to create an aspect on an Interface Method that extends from A "Super" Interface, but my save method is in an abstract super class. The structure is as follows - Interfaces: public interface SuperServiceInterface { ReturnObj save(ParamObj); } public interface ServiceInterface extends SuperServiceInterface { ... } Implementations: public abstract class SuperServiceImpl implements SuperServiceInterface { public ReturnObj save(ParamObj) { ... } } public

spring jetty UriInfo inject is null

女生的网名这么多〃 提交于 2019-12-13 01:17:54
问题 we are using spring jetty for rest call. we are injecting context as follows @Context private UriInfo uriInfo; we have inject the uri info in many services. It is working fine for all, except one where it is injected as null. After analyzing log i found for null injected class the type is printed as proxy object as shown in below Jan 18, 2013 4:32:07 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans INFO: Registering Spring bean,

How configure aspectj compilation in playframework 2.1.1

吃可爱长大的小学妹 提交于 2019-12-13 01:09:12
问题 I have added to plugins.sbt this declaration addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.0") Now I would like to configure this plugin to compile my java controller classes using aspect library org.springframework:spring-aspects:3.1.4 as with aspectj-maven-plugin I have set this configuration : import sbt._ import Keys._ import play.Project._ import com.typesafe.sbt.SbtAspectj._ import com.typesafe.sbt.SbtAspectj.AspectjKeys._ object ApplicationBuild extends Build { val

Spring AOP pass argument of a controller method

我怕爱的太早我们不能终老 提交于 2019-12-13 00:54:35
问题 I have a controller as follows @Controller @RequestMapping(value = "/") public class HomeController { @RequestMapping("/") public String home(Map<String,Object> map) { map.put("val2","val2"); return "mainpage"; //it is the jsp file name } } Now In my aspect class method I want to put another value in this map variable defined in the controller method @Aspect public class UserInfo { @Before("execution(* org.controller.HomeController(..)) ") public void m1(){ //Map<String,Object> map // get the

Spring @Transactional - javax.persistence.TransactionRequiredException

纵然是瞬间 提交于 2019-12-12 20:41:16
问题 In the following schema Controller -> Service -> DAO I'm trying to make Service operations @Transactional in my UserService.fooFunction() i call Entity e = dao.find(key) e.setProperty(something) dao.update(e) in dao.update(e) at the end there is em.flush() //EntityManager obtained by @PersistenceContext annotation (injected by spring IoC) Calling flush() throws a persistenceException: javax.persistence.TransactionRequiredException No externally managed transaction is currently active for this

AspectJ designator @args() not working in Spring AOP

[亡魂溺海] 提交于 2019-12-12 18:30:05
问题 I am learning Spring and I searched a lot about how to properly use @args() AspectJ designator but I am still not clear completely. What I know about it is that it limits joint-point matches to the execution of methods whose arguments are annoted with the given annotation types. This does not seem to work in my case. So here goes my files: Human.java @Component public class Human { int sleepHours; public int sleep(String sleepHours) { this.sleepHours = Integer.parseInt(sleepHours); System.out

Why does self-invocation not work for Spring proxies (e.g. with AOP)?

醉酒当歌 提交于 2019-12-12 18:25:48
问题 Please explain, why self invocation on proxy performed on target but not proxy? If that made on purpose, then why? If proxies created by subclassing, it's possible to have some code executed before each method call, even on self invocation. I tried, and I have proxy on self invocation public class DummyPrinter { public void print1() { System.out.println("print1"); } public void print2() { System.out.println("print2"); } public void printBoth() { print1(); print2(); } } public class