Skip to content
Snippets Groups Projects
Commit e9568b1e authored by Daniel Gerhardt's avatar Daniel Gerhardt Committed by Daniel Gerhardt
Browse files

Use AspectJ weaving instead of JDK/cglib proxies for AOP

This eliminates issues in edge cases like calling annotated methods from
inside the same class. The use of `AopContext.currentProxy()` and the
`exposeProxy` setting are no longer necessary for these cases.
parent 055db36d
1 merge request!66Use AspectJ weaving instead of JDK/cglib proxies for AOP
Pipeline #9177 passed with stages
in 3 minutes and 13 seconds
......@@ -172,11 +172,6 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
......@@ -254,10 +249,6 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
......@@ -324,6 +315,31 @@
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<showWeaveInfo>true</showWeaveInfo>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
......
......@@ -26,8 +26,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Configurable;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -40,9 +39,8 @@ import java.util.regex.Pattern;
* the response. It only applies to methods of {@link PaginationController}s annotated with
* {@link de.thm.arsnova.web.Pagination} which return a {@link List}.
*/
@Component
@Aspect
@Profile("!test")
@Configurable
public class RangeAspect {
@Autowired
......
......@@ -23,14 +23,14 @@ import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Configurable;
/**
* Assigns a session to the {@link de.thm.arsnova.services.UserSessionService} whenever a user joins a
* session.
*/
@Aspect
@Service
@Configurable
public class UserSessionAspect {
@Autowired
......
......@@ -34,12 +34,13 @@ import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.aspectj.EnableSpringConfigured;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
......@@ -81,10 +82,10 @@ import java.util.List;
"de.thm.arsnova.services",
"de.thm.arsnova.web"})
@Configuration
@EnableAspectJAutoProxy(exposeProxy = true)
@EnableAsync
@EnableCaching
@EnableCaching(mode = AdviceMode.ASPECTJ)
@EnableScheduling
@EnableSpringConfigured
@EnableWebMvc
@PropertySource(
value = {"classpath:arsnova.properties.example", "file:/etc/arsnova/arsnova.properties"},
......
<?xml version="1.0" encoding="UTF-8"?>
<aspectj>
<weaver options="-verbose -showWeaveInfo">
<!-- only weave classes in our application-specific packages -->
<include within="de.thm.arsnova..*"/>
</weaver>
<aspects>
<aspect name="de.thm.arsnova.aop.RangeAspect"/>
<aspect name="de.thm.arsnova.aop.UserSessionAspect"/>
</aspects>
</aspectj>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment