aspectj

AspectJ with weblogic

為{幸葍}努か 提交于 2019-12-06 10:53:04
问题 I am trying to run AspectJ on Weblogic with LTW. My pointcut is for public constructor and methods, and advices are for Before, AfterReturning and AfterThrowing. I am getting following error when I access a simple "Hello World" jsp: javax.servlet.ServletException: Servlet class: 'jsp_servlet.__index' doesn't have a default constructor at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:315) at weblogic.servlet.internal.StubSecurityHelper

How can I log private methods via Spring AOP?

╄→尐↘猪︶ㄣ 提交于 2019-12-06 10:34:41
问题 I am not able to log the private methods using spring aop performance logging. Below is the configuration I am using below configuration <aop:config proxy-target-class="true"> <aop:pointcut id="allServiceMethods" expression="execution(* com.mycom.app.abc..*.*(..))"/> <aop:advisor pointcut-ref="allServiceMethods" advice-ref="performanceMonitor" order="2"/> </aop:config> I am having cglib jar on my class path. 回答1: You have to use compile time weaving instead of the proxy usage for Spring AOP.

AspectJ EDT-Checker Code Question

可紊 提交于 2019-12-06 08:33:21
问题 I am currently using Alexander Potochkin's AspectJ EDTChecker code (relevant code at bottom of post). This code (from what little I understand of AspectJ) complains on any JComponent method call or constructor call that does not occur within the Swing EDT. However, the following only complains on the JList constructor, NOT the JFrame constructor. Can anyone tell me why? Thanks! package testEDT; import javax.swing.DefaultListModel; import javax.swing.JFrame; import javax.swing.JList; public

Spring MVC + Before Advice check security

Deadly 提交于 2019-12-06 08:33:17
I'm testing Spring AOP framework and have the following question. I have the following code: package danny.test.controllers; @Controller public class MyController{ @Autowired private DaoService service; @RequestMapping(value="/save",method = RequestMethod.POST) public String addUser(@Valid MyClass myClass, BindingResult result){ service.save(myClass); return "Ok"; } I would like to create before Advice aspect to check user security in user session. @Aspect public class Profiler { @Pointcut("execution(* danny.test.services.DaoServices.*.*(..))") public void methods(){} @Before("methods()")

JAVA编译时期和运行时期的区别

一世执手 提交于 2019-12-06 07:50:28
编译时期:检查是否有语法错误,如果没有就将其翻译为字节码文件,.class 运行时期:java虚拟机分配内存,解释执行字节码文件。 java编译时期会做一些优化操作。 1、方法重载 在编译时执行;方法重写 在运行时执行。 2、泛型(类型检测),在编译时。 3、注解,有的在编译时,有的在运行时。 @Override注解就是典型的编译时注解,他会在编译时会检查一些简单的如拼写的错误(与父类方法不相同)等 同样的@Test注解是junit框架的注解,他是一个运行时注解,他可以在运行时动态的配置相关信息如timeout等。 4、AOP 可以在编译时,预编译时以及运行时使用。编译时:当你有源码的时候,AOP编译器(AspectJ编译器)可以编译源码并且生成编译后的class;预编译时:织入过程有时候也叫作二进制织入,用来织入到 已经存在的class文件;运行时:当被织入的对象已经被加载到JVM中后,可以动态的织入到这些类中的一些信息。 5、继承是在编译时期运行的 6、代理,也成为动态代理,在运行时期执行。 7、 来源: https://my.oschina.net/u/2870118/blog/3136283

Spring: register advice programmatically at runtime

会有一股神秘感。 提交于 2019-12-06 07:28:04
问题 Is it possible to register AOP advices programmatically, after the application has booted and the context has been initialized? When I tried, the advices didn't work, supposedly because they need to wrap the bean BEFORE it gets available in the context. Something like this (it doesn't work): @Bean private AspectJExpressionPointcutAdvisor createPointcutAdvisor(AWSXRayRecorder awsxRayRecorder, String name, String pointcut) { AspectJExpressionPointcutAdvisor advisor = new

Getting a Template/Generic java.lang.reflect.Method object from org.aspectj.lang.ProceedingJoinPoint

会有一股神秘感。 提交于 2019-12-06 07:10:44
This question would not have existed if AspectJ worked the same way as EJB interceptors work. Consider basic scenario the EJB-interceptor way: @AroundInvoke public Object log(final InvocationContext ctx) throws Exception { // do stuff before final Object result = ctx.proceed(); // do stuff after return result; } Now I need the Method object that's being intercepted. Here I can simply do this: Method method = ctx.getMethod(); And that's it, after this I will be inspecting intercepted method's annotations. Now I'm working with application which is deployed to servlet container (Tomcat) and hence

How to disable Spring's JpaExceptionTranslatorAspect

烂漫一生 提交于 2019-12-06 05:39:29
I'm migrating from Spring 2.5.6 to 3.2.5. The jar spring-aspects-3.2.5 contains the new aspect JpaExceptionTranslatorAspect which translates standard JPA exceptions into Spring exceptions. It seems to be a Roo-specific aspect . This aspect gets automatically weaved into repositories (annotated with @Repository). Consequently, standard JPA exceptions are not caught anymore and the application is broken. How can I exclude JpaExceptionTranslatorAspect from being weaved? If it can't be done, is there any other workaround? Or am I missing some piece of configuration? I'm using AspectJ 1.7.4 and

@AspectJ Class level Annotation Advice with Annotation as method argument

不问归期 提交于 2019-12-06 03:59:34
问题 How can I get the annotation to be passed as the argument for the Advice defined for class-level annotation? Is it possible? From the post here I am able to get the point cut that identifies all the public method in the class which is marked by a specific Annotation. I am able to get the advice applied as well. However, I don’t know how to get the annotation variable passed as argument in above case. For a method-level annotation, I am able to get the pointcut and advice in which I can get

Reading annotation property in aspect

匆匆过客 提交于 2019-12-06 03:57:40
问题 How to read annotation property value in aspect? I want my Around advice to be executed for all joint points annotated with @Transactional(readonly=false) . @Around("execution(* com.mycompany.services.*.*(..)) " + "&& @annotation(org.springframework.transaction.annotation.Transactional)") public Object myMethod(ProceedingJoinPoint pjp) throws Throwable { } 回答1: You can do it without manual processing of signature, this way ( argNames is used to keep argument names when compiled without debug