Skip to content

Commit

Permalink
Use ajc to compile aspects
Browse files Browse the repository at this point in the history
The AspectJ language is cleaner than the annotation based style. This
patch adds an invocation of the AspectJ compile to the build process.
The patch also changes EofExceptionAspect from the annotation style to
the AspectJ language.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/6380/
  • Loading branch information
gbehrmann committed Jan 18, 2014
1 parent 50084af commit 827b2f8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
11 changes: 10 additions & 1 deletion modules/srm-server/pom.xml
Expand Up @@ -116,10 +116,19 @@

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<artifactId>aspectjrt</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
Expand Down
@@ -1,28 +1,27 @@
package org.dcache.srm.aspects;

import java.io.EOFException;
import java.io.OutputStream;

import org.apache.axis.Message;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.apache.axis.SOAPPart;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.EOFException;

/**
* Advices Axis 1 to not log a stack trace when the client disconnects before a reply
* was sent.
*/
@Aspect
public class EofExceptionAspect
aspect EofExceptionAspect
{
private static final Logger LOGGER = LoggerFactory.getLogger(Message.class);

@Around("withincode(void org.apache.axis.Message.writeTo(java.io.OutputStream)) && call(void org.apache.axis.SOAPPart.writeTo(java.io.OutputStream))")
public void swallowEofException(ProceedingJoinPoint thisJoinPoint) throws Throwable
{
pointcut writeToCalls() :
withincode(void Message.writeTo(OutputStream)) && call(void SOAPPart.writeTo(OutputStream));

void around() : writeToCalls() {
try {
thisJoinPoint.proceed();
proceed();
} catch (EOFException e) {
LOGGER.warn("Client disconnected before SRM response was sent.");
}
Expand Down
33 changes: 30 additions & 3 deletions pom.xml
Expand Up @@ -24,6 +24,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<source.version>1.7</source.version>
<target.version>1.7</target.version>

<version.slf4j>1.7.5</version.slf4j>
<version.milton>2.3.0.7</version.milton>
<version.spring>4.0.0.RELEASE</version.spring>
Expand Down Expand Up @@ -494,7 +497,6 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${version.aspectj}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
Expand Down Expand Up @@ -877,6 +879,31 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${version.aspectj}</version>
</dependency>
</dependencies>
<configuration>
<XterminateAfterCompilation>true</XterminateAfterCompilation>
<source>${source.version}</source>
<target>${target.version}</target>
<complianceLevel>${source.version}</complianceLevel>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
Expand Down Expand Up @@ -995,8 +1022,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>${source.version}</source>
<target>${target.version}</target>
</configuration>
</plugin>

Expand Down

0 comments on commit 827b2f8

Please sign in to comment.