aspectj

Spring @Transactional is applied both as a dynamic Jdk proxy and an aspectj aspect

I am in the process of adding Spring declarative transactions via the @Transactional annotation to an existing Java project. When I ran into a problem (unrelated to this question), I turned on full debug logging. Curiously, I noticed the following: 17:47:27,834 DEBUG HibernateTransactionManager:437 - Found thread-bound Session [org.hi...

AspectJ Load time weaver doesn't detect all classes

Hi, I am using Spring's declarative transactions (the @Transactional annotation) in "aspectj" mode. It works in most cases exactly like it should, but for one it doesn't. We can call it Lang (because that's what it's actually called). I have been able to pinpoint the problem to the load time weaver. By turning on debug and verbose logg...

Which maven plugin do I use for AspectJ?

I am trying to add aspectj to a maven project using java 6.0. Browsing around I found 2 maven plugins, none of which works the way I would expect. The first one http://mojo.codehaus.org/aspectj-maven-plugin did not work at first through netbeans because I could not get the code to compile 5.0 or later source (it complained about annotat...

AOP or APT for overriding methods from super classes

I have a large library of wicket components that are annotated with a custom annotation @ReferencedResource or another annotation @ReferencedResources, that has a ReferencedResouce[] value() parameter to allow multiple annotations. Here is a sample code snippet: @ReferencedResources({ @ReferencedResource(value = Libraries.MOO_TOOLS...

AspectJ, general pointcuts without constructors

Hi guys, I've made a profiling method: @Around("tld.mycompany.business.aspects.SystemArchitecture.inServiceLayer() && !tld.mycompany.business.aspects.SystemArchitecture.publicConstructor()") public Object profileBusiness(ProceedingJoinPoint pjp) throws Throwable { try { long start = System.currentTimeMillis(); String name = pj...

APT and AOP in the same project, using Maven

I have to use Annotation Processing (apt) and AspectJ in the same Maven project. Both work for themselves, but I need to create aspects based on code created by apt. So I would need binary weaving (the original source files are extended by apt). How can I enable binary weaving within a maven project? I know the only standard option is ...

AspectJ: How to get pointcuts to advise classes located in other projects

This should be simple. Question How do you get a pointcut in one project to advise the code/classes within another project? Context I'm working in eclipse with two projects. For ease of explanation, let's call one science project and the other math project and say the science project relies on the math project and I'm developing in bo...

How to package roo project without aspectj files into a jar.

Hi I am using Spring Roo to create a service to access the data base, just that. so, when I try to export to a jar using eclipse, the jar not contain one java class, but these files: Contact.class Contact_Roo_Configurable.class Contact_Roo_Entity.class Contact_Roo_ToString.class Contact_Roo_JavaBean.class I know these was AspectJ files...

How to automatically set date_created using spring aop

Hello Gurus !!! i've been working on a project in java+maven+spring+hibernate and i wanted to automatically assign the current date to the POJOs before the calling of saveorupdate. i wouldn't mind creating new Date() for all the date_created of all the classes but they are just plenty. I've just discovered that spring aop is good at tho...

aop.xml name and location?

Is there a way to specify the name of the aop.xml file with LTW? or define another name and location? I have several software modules that I use and that all use META-INF/aop.xml with different settings. I include these modules in a web application and then it all dependens how it's deployed/unpacked, which aop.xml file is used .. So I d...

Aspectj. Creating innter type methods in multiple classes

Hello there! If I put: public CountryState CountryState.find(long id) { return (CountryState) findById(CountryState.class, id); } I'm creating a method find in the class CountryState. Is there a way to create a method in several classes? Do I need to repeat the code for each class I want to create? I know that with aspect I...

AspectJ with Spring misses something

Hi all! I'm just playing with AspectJ (1.6) with Spring (2.5), but it seems not to work in the proper way. I set up my "beans.xml" using: <aop:aspectj-autoproxy/> <bean id="testBean1" class="apackage.MyClass"> <bean id="aopBean1" class="apackage.AfterReturningExample"/> with the correct namespaces set and some other beans with no impo...

Compile-time weaving configuration

I am trying to convert my load-time-woven aspectj to compile-time-woven. So I removed <context:load-time-weaver/> from my spring config, and added an aspectj compiler to my pom.xml. But I don't know how to convert the info in META-INF/aop.xml. I have something like this in there: <!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" ...

Weaving production classes with AspectJ aspects in Maven for tests execution only

I have a project with Maven build and need to add some basic performance tracing to methods. I decided to use AspectJ for this. Main requirement is to weave tracing aspect into production classes but only for unit tests execution phase. I was able to configure weaving in Maven however after execution of tests same production classes wi...

How to get web session on Spring AspectJ

Hi all,I have a question for using Spring AspectJ.I want to create audit log when user do something and get user information from web session to create audit log. Can anyone provide examples of how to do this? ...

spring 3.0 aop Pointcut is not well-formed: expecting 'name pattern' error

The following is my pointcut and advise declaration //PointCut on A method which takes two parameters and is in a DAO @Pointcut("execution(backend.repository.QuestionsRepository.AnswerQuestion (..))") public void answerQuestionPointCut() {} @Around( value="web.activity.advisors.UserActivityAdvisor.answerQuestionPointCut()", arg...

Eclipse warnings using the iajc ant task

We are currently using the Aspect J ant compiler iajc to compile our code. Now we want to get the Eclipse warnings when compiling with ant but we don't want to change away from using the iajc ant task. Is there a possible way to achieve this? Currently our compile iajc task looks like this: <iajc outJar="${dist}/${dist.jar}" source="1....

AspectJ confusion with pointcut

How can I express a point cut that finds methods only when being called from within another method, but not directly? For example: Foo() calls Bar() calls object.Method() also NotFoo() calls Bar() calls object.Method() I only want the pointcut to work for within Foo() I tried "withincode," but that seems to only work directly. Tha...

Spring in Action 3 example of AOP causing problems

I am working my way through Spring in Action 3 and there is an example in there of using AOP with the around aspect. This is the Aspect class: package com.xetius.springIdol; import org.aspectj.lang.ProceedingJoinPoint; public class Audience { public void watchPerformance(ProceedingJoinPoint joinpoint) { try { System.out....

Intercepting only void return calls using AspectJ

I have a trace aspect that should log: Entering Exiting (return type is void) Returning [returned object] Throwinig [Exception message] I am having problems with the second. How do I create an advice for this case without double-logging all exits that also return something as is the case now when I have one @After advice and one @Aft...