aspectj

Intercept private methods with Spring and AspectJ

本秂侑毒 提交于 2019-12-13 02:38:08
问题 I am trying to execute code before a private method using AspectJ's load-time-weaving with Spring-Boot and annotation-based configuration and I'm pulling my hair out trying to figure out why my aspect is not being invoked. My simple aspect is as follows: @Aspect public class LoggingAspect { private static Logger log = LoggerFactory.getLogger(LoggingAspect.class); @Before("execution(private * com.mycompany.MyServiceWithPrivateMethods.*(..))") public void privateAspect() { log.warn("####

Performance: using AspectJ to log run time of all methods

微笑、不失礼 提交于 2019-12-13 02:28:04
问题 I have a requirement to log the run time of every single method in the application to the DB using logback and AspectJ. It's an enterprise application with roughly a few thousand classes and on average about 10 methods inside each class. Am I walking into major performance issues here ? I know it's over the top to log every single method, but let's look past that for now. 回答1: Thousands of classes with about ten methods per class and you have to implement trace logging for all of them? Short

AspectJ LTW (weaving) not working with Spring Boot

谁说我不能喝 提交于 2019-12-13 02:25:26
问题 I'm on Spring Boot 2.1.2.RELEASE - Java 11 - Fat JAR Following the documentation, I have: added the required dependencies to the Gradle build implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'org.aspectj:aspectjrt:1.9.2' implementation 'org.aspectj:aspectjweaver:1.9.2' enabled LoadTimeWeaving @SpringBootApplication @EnableLoadTimeWeaving public class MyApplication { ... } provided the aop.xml under META-INF <!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http:/

Can't login while using MultiReadHttpServletRequest with Spring security UsernameAndPasswordAuthFilter

橙三吉。 提交于 2019-12-13 02:14:07
问题 I'm trying to build a simple logging tool that using AspectJ can print the HttpServletRequest body. For this I created a simple PointCut that catches all executions of javax Filter.doFilter, HttpServlet doPost, doGet, service etc. I then replace the HttpServletRequest with my own request wrapper that copies the request's body so it can be called more than once so I'll be able to log it. See - https://github.com/Alotor/test-binding/blob/master/src/java/grails/util/http

AspectJ writing 2 separate pointcuts one for onCreate() and other for rest of methods

混江龙づ霸主 提交于 2019-12-13 01:28:39
问题 I am using AspectJ for Android and I am having a requirement of writing 2 pointcuts one which does pointcut execution for onCreate() and other for rest of the methods in the Android app that excludes onCreate() . Currently my pointcut for methods is also injecting onCreate() which I dont want to happen. It is like this - pointcut methodCalls(): execution(* com.hello..*(..)) && !within(com.retro.Tester); Tester.aj is my Aspect file 回答1: Assuming you have 2 pointcuts, one for onCreate() method

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

Making Aspectj work on a Spring servlet bean

£可爱£侵袭症+ 提交于 2019-12-13 01:05:33
问题 I am trying to get an aspectprofiler working on a Jersey servlet registered in a spring project. The aspectprofiler is loaded, but don't notice when methods within the Jersey servlet are run. @EnableAutoConfiguration @Configuration @EnableAspectJAutoProxy(proxyTargetClass = true) public class App { public static void main(final String[] args) { final SpringApplicationBuilder sab = new SpringApplicationBuilder(ConsolidatedCustomerMasterApp.class); sab.run(args); } @Bean public

ClassLoader does NOT provide an 'addTransformer(ClassFileTransformer)' method

拥有回忆 提交于 2019-12-12 15:08:12
问题 I'm using Spring and AspectJ to do some nice weaving and I just ran into this issue after inserting <context:load-time-weaver/> into my application context: Caused by: java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar at org.springframework.context.weaving

Injecting spring bean in a JPA Entity Listener

随声附和 提交于 2019-12-12 14:38:42
问题 Am trying to make a JPA Entity Listener aware of the spring context by marking it as @Configurable. But the injected spring beans are null. Am able to make JPA entities aware of the Spring context using the same technique. Am using Spring(core and data-jpa) as infrastructure. Any ideas on how to acheive this using JPA Entity Listeners or spring data-jpa? @Configurable @Scope("singleton") public class AggregateRootListener { private static Logger log = LoggerFactory.getLogger

Error creating bean with name : Scope 'request' is not active for the current thread

无人久伴 提交于 2019-12-12 14:34:21
问题 I have integrated SWF 2.2.1,Primefaces 2.2.1,JSF 2,Spring Security 3,Spring 3.1.0M1I and EhCache and AspectJ and Castor. I have defined beans for castor in my app-config.xml like <bean id="oXMapper" class="com.abc.xyz.util.OXMapper"> <property name="unmarshaller" ref="unmarshaller" /> <property name="marshaller" ref="marshaller" /> <property name="acordRequest" ref="acordRequest" /> <property name="acordResponse" ref="acordResponse" /> </bean> <bean id="unmarshaller" class="org