01: /**
02: * Copyright (C) 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */package com.google.inject;
16:
17: import com.google.inject.matcher.Matcher;
18: import com.google.inject.util.Objects;
19: import java.lang.reflect.Method;
20: import java.util.Arrays;
21: import java.util.List;
22: import org.aopalliance.intercept.MethodInterceptor;
23:
24: /**
25: * Ties a matcher to a method interceptor.
26: *
27: * @author crazybob@google.com (Bob Lee)
28: */
29: class MethodAspect {
30:
31: final Matcher<? super Class<?>> classMatcher;
32: final Matcher<? super Method> methodMatcher;
33: final List<MethodInterceptor> interceptors;
34:
35: MethodAspect(Matcher<? super Class<?>> classMatcher,
36: Matcher<? super Method> methodMatcher,
37: MethodInterceptor... interceptors) {
38: this .classMatcher = Objects.nonNull(classMatcher,
39: "class matcher");
40: this .methodMatcher = Objects.nonNull(methodMatcher,
41: "method matcher");
42: this .interceptors = Arrays.asList(Objects.nonNull(interceptors,
43: "interceptors"));
44: }
45:
46: boolean matches(Class<?> clazz) {
47: return classMatcher.matches(clazz);
48: }
49:
50: boolean matches(Method method) {
51: return methodMatcher.matches(method);
52: }
53:
54: List<MethodInterceptor> interceptors() {
55: return interceptors;
56: }
57: }
|