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.bm.ejb3guice.inject;
16:
17: import com.bm.ejb3guice.internal.Objects;
18: import com.bm.ejb3guice.matcher.Matcher;
19:
20: import java.lang.reflect.Method;
21: import java.util.Arrays;
22: import java.util.List;
23: import org.aopalliance.intercept.MethodInterceptor;
24:
25: /**
26: * Ties a matcher to a method interceptor.
27: *
28: * @author crazybob@google.com (Bob Lee)
29: */
30: class MethodAspect {
31:
32: final Matcher<? super Class<?>> classMatcher;
33: final Matcher<? super Method> methodMatcher;
34: final List<MethodInterceptor> interceptors;
35:
36: MethodAspect(Matcher<? super Class<?>> classMatcher,
37: Matcher<? super Method> methodMatcher,
38: MethodInterceptor... interceptors) {
39: this .classMatcher = Objects.nonNull(classMatcher,
40: "class matcher");
41: this .methodMatcher = Objects.nonNull(methodMatcher,
42: "method matcher");
43: this .interceptors = Arrays.asList(Objects.nonNull(interceptors,
44: "interceptors"));
45: }
46:
47: boolean matches(Class<?> clazz) {
48: return classMatcher.matches(clazz);
49: }
50:
51: boolean matches(Method method) {
52: return methodMatcher.matches(method);
53: }
54:
55: List<MethodInterceptor> interceptors() {
56: return interceptors;
57: }
58: }
|