aspectj

How do I use an ajc build parameter inside an aspect?

让人想犯罪 __ 提交于 2019-12-31 04:22:47
问题 I need to know the name of my .jar inside the aspect so I can create a string field with it via @DeclareParents. I know I can pass things to the ajc compiler, but is it actually possible to use the passed arguments from the aspect? The end result should be classes with an additional field containing as value the name of my .jar. UPDATE: Test of suggestion. Gson.jar is a .jar on the classpath InputStream r = Gson.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF"); String x =

AspectJ: custom *.aj file is ignored

我们两清 提交于 2019-12-31 03:29:04
问题 Why aspectj-maven-plugin ignore my AnnotationInheritor.aj file? Am I configured something wrong? I want to advice ItemRepository#getById with custom annotation: @Repository public interface ItemRepository extends JpaRepository<Item, Long> { // AOP does not work, since autogenerated ItemRepositoryImpl#getById // won't have @MyAnnotation annotation @MyAnnotation public Item getById(Long id); } @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface

How to define an aspectj pointcut that picks out all constructors of a class that has a specific annotation?

老子叫甜甜 提交于 2019-12-31 02:14:06
问题 Here is the annotation: @Target(value = ElementType.TYPE) @Retention(value = RetentionPolicy.RUNTIME) @Inherited public @interface MyAnnotation { String name(); } Here is one annotated class: @MyAnnotation(name="foo") public class ClassA { public ClassA() { // Do something } } Here is a second annotated class: @MyAnnotation(name="bar") public class ClassB { public ClassB(String aString) { // Do something } } I am looking for an aspectj pointcut that correctly matches the constructors for

Difference between call and execution in AOP

醉酒当歌 提交于 2019-12-31 01:46:25
问题 I'm trying to understand the difference between execution and call in AOP as simply as possible. From what I gather, execution() will add a join point in the executing code, so HelloWorldSayer.sayHello() in this case, but if the pointcut was call() , then the join point will be HelloWorldSayer.main() . Is this correct? public class HelloWorldSayer { public static void main (String[] args) { sayHello(); } public static void sayHello() { System.out.println("Hello"); } } public aspect World {

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable

ぃ、小莉子 提交于 2019-12-30 18:07:46
问题 I am using Spring 4.2.4.RELEASE in my web application and I would like to remove the dependency on aspectjweaver.jar from it. I don't use AOP directly and I certainly don't use AspectJ. But my application fails with the following exception: java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable

≡放荡痞女 提交于 2019-12-30 18:07:17
问题 I am using Spring 4.2.4.RELEASE in my web application and I would like to remove the dependency on aspectjweaver.jar from it. I don't use AOP directly and I certainly don't use AspectJ. But my application fails with the following exception: java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable

你离开我真会死。 提交于 2019-12-30 18:07:06
问题 I am using Spring 4.2.4.RELEASE in my web application and I would like to remove the dependency on aspectjweaver.jar from it. I don't use AOP directly and I certainly don't use AspectJ. But my application fails with the following exception: java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357

Spring传播行为内部方法不起作用(2)

落爺英雄遲暮 提交于 2019-12-30 17:35:52
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 在使用Spring的注解事务时候,我们发现内部方法声明的事务不起作用,而是决定于外部方法注解的事务。到底是真不起作用,还是我们Spring的事务注解机制理解错了,导致误用了。下面我们看两个例子: 测试类: package com.aop; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.thread.service.IBaseFacadeService; //@RunWith(SpringJUnit4ClassRunner.class) //@ContextConfiguration(locations = { "classpath:/spring-ibatis.xml", "classpath:/spring-jdbctemplate.xml" }) public class TestStudentDao { public static void main(String[] args) { try { BeanFactory factory = new

AspectJ JoinPoint question

此生再无相见时 提交于 2019-12-30 06:09:12
问题 I am currently using JoinPoint to capture the parameters passed to service methods at runtime. Though JoinPoint helps me retrieve the parameter values, I see that it doesn't provide any good API to retrieve the names of the parameters, parameter types, individual parameter values when the parameter passed is an array etc. Here's an example: public void doIt(String user, Attribute[] attr, Integer[] i, boolean bool, List<Attribute> list){.....} For the above method, when I use JoinPoint.getArgs

Spring AOP: exclude avoid final classes and enums from pointcut

左心房为你撑大大i 提交于 2019-12-30 05:00:05
问题 I am using try to implement Logging using Spring AOP. I have defined the @Pointcut("execution(* com.mycom..*(..))") private void framework() {} @Around("framework()") public Object aroundAdviceFramework(ProceedingJoinPoint jp) throws Throwable { if (logger.isDebugEnabled()) logger.debug("DEBUG:: {} {} Enter", jp.getTarget().getClass().getName(), jp.getSignature().getName()); Object returnVal = jp.proceed(jp.getArgs()); if (logger.isDebugEnabled()) logger.debug("DEBUG:: {} {} Out", jp