|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| InterceptorStackCallback | Line # 31 | 3 | 2 | 0 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| InterceptorStackCallback.InterceptedMethodInvocation | Line # 47 | 11 | 6 | 6 | 68.4% |
0.68421054
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (16) | |||
| Result | |||
|
0.75
|
com.google.inject.MethodInterceptionTest.testGetThis
com.google.inject.MethodInterceptionTest.testGetThis
|
1 PASS | |
|
0.6666667
|
com.google.inject.ProxyFactoryTest.testMultipleInterceptors
com.google.inject.ProxyFactoryTest.testMultipleInterceptors
|
1 PASS | |
|
0.6666667
|
com.googlecode.guice.BytecodeGenTest.testProxyingPackagePrivateMethods
com.googlecode.guice.BytecodeGenTest.testProxyingPackagePrivateMethods
|
1 PASS | |
|
0.6666667
|
com.google.inject.ProxyFactoryTest.testSimpleCase
com.google.inject.ProxyFactoryTest.testSimpleCase
|
1 PASS | |
|
0.6666667
|
com.google.inject.ProxyFactoryTest.testInterceptOneMethod
com.google.inject.ProxyFactoryTest.testInterceptOneMethod
|
1 PASS | |
|
0.6666667
|
com.google.inject.IntegrationTest.testIntegration
com.google.inject.IntegrationTest.testIntegration
|
1 PASS | |
|
0.6666667
|
com.googlecode.guice.BytecodeGenTest.testInterceptedPackageVisibility
com.googlecode.guice.BytecodeGenTest.testInterceptedPackageVisibility
|
1 PASS | |
|
0.6666667
|
com.googlecode.guice.BytecodeGenTest.testProxyClassLoading
com.googlecode.guice.BytecodeGenTest.testProxyClassLoading
|
1 PASS | |
|
0.6666667
|
com.google.inject.ProxyFactoryTest.testWithConstructorArguments
com.google.inject.ProxyFactoryTest.testWithConstructorArguments
|
1 PASS | |
|
0.625
|
com.google.inject.ParentInjectorTest.testInterceptorsInherited
com.google.inject.ParentInjectorTest.testInterceptorsInherited
|
1 PASS | |
|
0.625
|
com.google.inject.MethodInterceptionTest.testSpiAccessToInterceptors
com.google.inject.MethodInterceptionTest.testSpiAccessToInterceptors
|
1 PASS | |
|
0.625
|
com.googlecode.guice.BytecodeGenTest.testProxyClassUnloading
com.googlecode.guice.BytecodeGenTest.testProxyClassUnloading
|
3 FAIL | |
|
0.625
|
com.google.inject.ReflectionTest.testLinkedBinding
com.google.inject.ReflectionTest.testLinkedBinding
|
1 PASS | |
|
0.625
|
com.google.inject.MethodInterceptionTest.testSharedProxyClasses
com.google.inject.MethodInterceptionTest.testSharedProxyClasses
|
1 PASS | |
|
0.125
|
com.googlecode.guice.BytecodeGenTest.testSystemClassLoaderIsUsedIfProxiedClassUsesIt
com.googlecode.guice.BytecodeGenTest.testSystemClassLoaderIsUsedIfProxiedClassUsesIt
|
1 PASS | |
|
0.125
|
com.google.inject.internal.LineNumbersTest.testCanHandleLineNumbersForGuiceGeneratedClasses
com.google.inject.internal.LineNumbersTest.testCanHandleLineNumbersForGuiceGeneratedClasses
|
1 PASS | |
| 1 | /** | |
| 2 | * Copyright (C) 2006 Google Inc. | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 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 | */ | |
| 16 | ||
| 17 | package com.google.inject; | |
| 18 | ||
| 19 | import java.lang.reflect.AccessibleObject; | |
| 20 | import java.lang.reflect.Method; | |
| 21 | import java.util.List; | |
| 22 | import net.sf.cglib.proxy.MethodProxy; | |
| 23 | import org.aopalliance.intercept.MethodInterceptor; | |
| 24 | import org.aopalliance.intercept.MethodInvocation; | |
| 25 | ||
| 26 | /** | |
| 27 | * Intercepts a method with a stack of interceptors. | |
| 28 | * | |
| 29 | * @author crazybob@google.com (Bob Lee) | |
| 30 | */ | |
| 31 | class InterceptorStackCallback implements net.sf.cglib.proxy.MethodInterceptor { | |
| 32 | ||
| 33 | final MethodInterceptor[] interceptors; | |
| 34 | final Method method; | |
| 35 | ||
| 36 | 90 |
public InterceptorStackCallback(Method method, |
| 37 | List<MethodInterceptor> interceptors) { | |
| 38 | 90 | this.method = method; |
| 39 | 90 | this.interceptors = interceptors.toArray(new MethodInterceptor[interceptors.size()]); |
| 40 | } | |
| 41 | ||
| 42 | 29 |
public Object intercept(Object proxy, Method method, Object[] arguments, |
| 43 | MethodProxy methodProxy) throws Throwable { | |
| 44 | 29 | return new InterceptedMethodInvocation(proxy, methodProxy, arguments).proceed(); |
| 45 | } | |
| 46 | ||
| 47 | class InterceptedMethodInvocation implements MethodInvocation { | |
| 48 | ||
| 49 | final Object proxy; | |
| 50 | final Object[] arguments; | |
| 51 | final MethodProxy methodProxy; | |
| 52 | int index = -1; | |
| 53 | ||
| 54 | 29 |
public InterceptedMethodInvocation(Object proxy, MethodProxy methodProxy, |
| 55 | Object[] arguments) { | |
| 56 | 29 | this.proxy = proxy; |
| 57 | 29 | this.methodProxy = methodProxy; |
| 58 | 29 | this.arguments = arguments; |
| 59 | } | |
| 60 | ||
| 61 | 60 |
public Object proceed() throws Throwable { |
| 62 | 60 | try { |
| 63 | 60 | index++; |
| 64 | 60 | return index == interceptors.length |
| 65 | ? methodProxy.invokeSuper(proxy, arguments) | |
| 66 | : interceptors[index].invoke(this); | |
| 67 | } | |
| 68 | finally { | |
| 69 | 60 | index--; |
| 70 | } | |
| 71 | } | |
| 72 | ||
| 73 | 0 |
public Method getMethod() { |
| 74 | 0 | return method; |
| 75 | } | |
| 76 | ||
| 77 | 0 |
public Object[] getArguments() { |
| 78 | 0 | return arguments; |
| 79 | } | |
| 80 | ||
| 81 | 2 |
public Object getThis() { |
| 82 | 2 | return proxy; |
| 83 | } | |
| 84 | ||
| 85 | 0 |
public AccessibleObject getStaticPart() { |
| 86 | 0 | return getMethod(); |
| 87 | } | |
| 88 | } | |
| 89 | } | |
|
|||||||||||