package org.mockejb.interceptor;
class InterceptorContainerAspect implements Aspect {
private Pointcut pointcut;
private Interceptor interceptor;
public InterceptorContainerAspect( Pointcut pointcut, Interceptor interceptor ) {
if ( pointcut==null )
throw new IllegalArgumentException("Interceptor can't be null");
if ( interceptor==null )
throw new IllegalArgumentException("Pointcut can't be null");
this.pointcut = pointcut;
this.interceptor = interceptor;
}
public Pointcut getPointcut() {
return pointcut;
}
public void intercept( InvocationContext invocationContext ) throws Exception {
interceptor.intercept( invocationContext );
}
public Interceptor getInterceptor() {
return interceptor;
}
public boolean equals( Object obj ){
if ( ! (obj instanceof InterceptorContainerAspect) )
return false;
InterceptorContainerAspect aspect = (InterceptorContainerAspect ) obj;
return ( pointcut.equals( aspect.pointcut ) && interceptor.equals( aspect.interceptor) );
}
public int hashCode() {
int result = 17;
result = 37*result+pointcut.hashCode();
result = 37*result+interceptor.hashCode();
return result;
}
}