I have a maven Java EE 6 project and I have into every methods a Logger information to show in the console the beginning with parameters and the end too.
In some methods i forgot the make that so i want to use aspectJ to manage the beginning and the end to every called methods.
I use Jboss EAP6 as server and Jboss developper Studio as IDE and i found some tuturials on the net but always it talkes about spring or java aspactJ project. I installed the pluging aspectJ on my IDE and i try to add an aspect it told me that my maven project is not an aspectJ project so how can solve that?
this my maven pom.xml
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>snapshots</id>
<name>repo1-maven</name>
<url>http://central.maven.org/maven2</url>
</repository>
<repository>
<id>JBoss repository</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
this my interface:
public interface IClient {
void addClient(ClientBean clt);
}
this is the implementation:
public class ClientImpl implements IClient {
private List<ClientBean> ListOfCustomers;
public ClientImpl() {
setListOfCustomers(new ArrayList<ClientBean>());
}
public void addClient(ClientBean clt) {
ListOfCustomers.add(clt);
}
public List<ClientBean> getListOfCustomers() {
return ListOfCustomers;
}
public void setListOfCustomers(List<ClientBean> listOfCustomers) {
ListOfCustomers = listOfCustomers;
}
}
this is a class whitch i try to make my aspectJ:
@Aspect
public class ClientAspect {
@Pointcut("execution(* *.*(..))")
void anyCallMethod() {}
@Before(value = "anyCallMethod()")
public void befor(JoinPoint joinPoint) {
System.out.println("Before, class: "
+ joinPoint.getSignature().getDeclaringType().getSimpleName()
+ ", method: " + joinPoint.getSignature().getName());
}
@After(value = "anyCallMethod()")
public void after(JoinPoint joinPoint) {
System.out.println("After, class: "
+ joinPoint.getSignature().getDeclaringType().getSimpleName()
+ ", method: " + joinPoint.getSignature().getName());
}
}
i have a man class to test and when i run my project it gives me nos log on the console