aspectj

Aspect around call on annotated field

﹥>﹥吖頭↗ 提交于 2019-12-11 04:34:22
问题 I want AspectJ to inject the measuring code around all invocations of any method, on fields annotated with @Measured and capture the method's name. This is what I have: @Pointcut("get(@my.annotation.Measured * *) && @annotation(measured)") public void fieldAnnotatedWithMeasured(Measured measured) {} @Around(value = "fieldAnnotatedWithMeasured(measured)", argNames = "joinPoint,measured") public Object measureField(ProceedingJoinPoint joinPoint, Measured measured) throws Throwable {...} Use

Transaction doesn't work in aspectj

耗尽温柔 提交于 2019-12-11 04:06:23
问题 I have the aspect(see below) which should log actions(create, update, delete) in db. Depends on action logging happens in a preProcess or postProcess method. I shouldn't log anything if some fail happens through these actions. I.e. if create didn't happened, then there is no need to logging it. I tried to tested it. I throw RunTimeException in the join point and expect that there is no new log in db. Unfortunately, new log is saved in spite of exception in the join point. Aspect: @Component

Spring AOP: How exclude an unnecessary @Pointcut (@Around advice) execution due the execution from others @Pointcuts/advices

旧时模样 提交于 2019-12-11 04:02:22
问题 I am working with: Spring Framework 4.3.3 AspectJ 1.8.9 I have the following normal process: @Controller -> @Service -> @Repository I have the following pair about AOP : PersonaServicePointcut PersonaServiceAspect The scenario is the following: The @Service class has some methods such as: delete , save , update and findOneById . They are declared together within the same class. For the methods such as delete and update through AOP I am using a @Before or @Around advice to call the findOneById

Is there any tool or technique to identify opened ResultSet

会有一股神秘感。 提交于 2019-12-11 03:52:56
问题 In the context of a java application using SQLIte to persist data I am using the Zentus JDBC driver. Thus I am using the java.sql package to acces my database. I am facing some strange (in a an environment with several Connection objects on the same database) issues and I am pretty sure my problems come from non closed ResultSet. Is there any tool or technique allowing me to spot where to look in my source code to find these non closed objects ? Edit May be using AspectJ ?? 回答1: It seems like

aspectj: why advice cannot be applied?

a 夏天 提交于 2019-12-11 03:38:25
问题 I've created very basic aspectJ project. I have no idea why advice cannot be applied. annotation import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @Documented public @interface Conditional { String value(); } and aspectJ class: @Aspect public class AspectE { @Around("call(@Conditional * *.*(..)) && @annotation(conditional)" ) public Object condition(ProceedingJoinPoint joinPoint, Conditional conditional) throws Throwable { System.out.println("entry

Load time weaving for non-spring beans in a spring application

帅比萌擦擦* 提交于 2019-12-11 03:34:49
问题 I have a spring boot application with some REST controllers, service classes and helper classes. The controllers and service classes are spring managed while helper classes are not spring managed and mostly contain static methods. The AspectJ configuration is present in java configuration as follows @Configuration @EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.ENABLED) public class AspectConfig { @Bean public LoggingAspect loggingAspect() { return new LoggingAspect(); } } The

UnsupportedPointcutPrimitiveException on simple AOP example

…衆ロ難τιáo~ 提交于 2019-12-11 03:27:25
问题 I try to run a simple aop example in this site. I have spring aop and aspectj, aspectjweaver jars: @Aspect public class StringAspect { @Pointcut("call(* String.toLowerCase())") public void toLowerCasePointcut() {} @Around("toLowerCasePointcut()") public String toLowerCaseAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable { String text = ((String) joinPoint.getTarget()).toUpperCase(); return text; } } When I run this example in Test.java like "AaBbCc".toLowerCase(), I get this

About Policy Enforcement with AspectJ

倾然丶 夕夏残阳落幕 提交于 2019-12-11 03:13:16
问题 I am using Aspectj for project-wide policy enforcement. One thing I am trying to implement now is that there should be no logic in any setter methods except simple validation with Guava's Preconditions.check* methods. public pointcut withinSetter() : withincode(public void set*(*)); public pointcut inputValidation() : call(public void Preconditions.check*(*)); public pointcut setFieldValue() : set(* *); public pointcut entity() : within(com.mycompany.BaseEntity+); declare warning : entity() &

AspectJ / Generate methods using compile-time reflection

白昼怎懂夜的黑 提交于 2019-12-11 02:56:49
问题 I just heard of AspectJ and it doesn't look too easy to understand, so I want to know beforehand if it (or anything else) will help me with my problem or not. I have bunch of simple POJO classes and want to write binary serializers for them but without writing Write/Read methods by hand for each class. I could've done so with help of reflection but that will affect runtime performance. I believe I need something similar to Macroses in Scala with compile-time reflection and quasiquotes. Update

org.aspectj.lang.NoAspectBoundException - method <init>()V not found

房东的猫 提交于 2019-12-11 02:56:11
问题 I had same problem as vanhre asked in Spring forum, but in my case I couldn't change the constructor. I'm using Spring java configuration, so it was initializing ok during jetty start, but in runtime, when I executed the functionality with my aspect it failed with exactly the same exception from the forum. 回答1: I found later, that I need aspectjrt dependency in my pom. <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.6.12</version> </dependency> edit: