Spring AOP with only context dependency!

No AspectJ Weaver or any other AspectJ dependency!

pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
 
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>biz.tugay</groupId>
    <artifactId>spashe</artifactId>
    <packaging>jar</packaging>
 
    <version>1.0-SNAPSHOT</version>
 
    <name>bare-maven-project</name>
    <url>http://www.tugay.biz</url>
 
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.3.12.RELEASE</version>
        </dependency>
    </dependencies>
 
    <build>
        <finalName>spashe</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>biz.tugay.spashe.App</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
 
    <properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

Foo.java
package biz.tugay.spashe;
 
public interface Foo {
    void foo();
}

FooImpl.java
package biz.tugay.spashe;
 
import org.springframework.stereotype.Component;
 
@Component(value = "foo")
public class FooImpl implements Foo {
    public void foo() {
        System.out.println("Foo!");
    }
}

BarImpl.java
package biz.tugay.spashe.aspect;
 
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
 
public class BarImpl implements MethodInterceptor {
 
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        System.out.println("Before!!!");
        final Object proceed = methodInvocation.proceed();
        return proceed;
    }
}

beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">
    <!-- Business Logic -->
    <bean id="foo" class="biz.tugay.spashe.FooImpl"/>
 
    <!-- Aspect -->
    <bean id="aspectBar" class="biz.tugay.spashe.aspect.BarImpl"/>
 
    <bean id="fooProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="target" ref="foo"/>
        <property name="interceptorNames">
            <list>
                <value>buServAdvisor</value>
            </list>
        </property>
    </bean>
 
    <bean id="buServAdvisor"
          class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
        <property name="patterns">
            <list>
                <value>.*Foo.*</value>
            </list>
        </property>
        <property name="advice" ref="aspectBar"/>
    </bean>
</beans>

App.java
package biz.tugay.spashe;
 
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
 
public class App {
    public static void main(String[] args) {
        final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
        final Foo foo = applicationContext.getBean("fooProxy", Foo.class);
        foo.foo();
    }
}