<dependency>
<groupId>org.aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency>
public interface MyLibraryExtension {
void extend();
}
public class MyLibraryAspect implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
System.out.println("Before extending MyLibrary...");
Object result = invocation.proceed();
System.out.println("After extending MyLibrary...");
return result;
}
}
<bean id="myLibraryAspect" class="com.example.MyLibraryAspect" />
<aop:config>
<aop:aspect id="myLibraryAspect" ref="myLibraryAspect">
<aop:pointcut id="myLibraryExtensionPoint"
expression="execution(* com.example.MyLibrary.*(..))" />
<aop:before pointcut-ref="myLibraryExtensionPoint" method="invoke" />
</aop:aspect>
</aop:config>
public class MyLibrary implements MyLibraryExtension {
public void doSomething() {
System.out.println("Doing something...");
}
@Override
public void extend() {
System.out.println("Extending MyLibrary...");
}
}