KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > interceptor > NopInterceptor


1
2 /*
3  * Copyright 2002-2005 the original author or authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.springframework.aop.interceptor;
19
20 import org.aopalliance.intercept.MethodInterceptor;
21 import org.aopalliance.intercept.MethodInvocation;
22
23 /**
24  * Trivial interceptor that can be introduced in a chain to display it.
25  *
26  * @author Rod Johnson
27  */

28 public class NopInterceptor implements MethodInterceptor {
29     
30     private int count;
31
32     /**
33      * @see org.aopalliance.intercept.MethodInterceptor#invoke(MethodInvocation)
34      */

35     public Object JavaDoc invoke(MethodInvocation invocation) throws Throwable JavaDoc {
36         increment();
37         return invocation.proceed();
38     }
39     
40     public int getCount() {
41         return this.count;
42     }
43     
44     protected void increment() {
45         ++count;
46     }
47
48     public boolean equals(Object JavaDoc other) {
49         if (!(other instanceof NopInterceptor)) {
50             return false;
51         }
52         if (this == other) {
53             return true;
54         }
55         return this.count == ((NopInterceptor) other).count;
56     }
57
58 }
59
Popular Tags