|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ImplementationHidingComponentFactory.java | - | 100% | 100% | 100% |
|
1 |
package picocontainer.hierarchical;
|
|
2 |
|
|
3 |
import picocontainer.defaults.DefaultComponentFactory;
|
|
4 |
import picocontainer.PicoInvocationTargetInitailizationException;
|
|
5 |
|
|
6 |
import java.lang.reflect.Constructor;
|
|
7 |
import java.lang.reflect.Proxy;
|
|
8 |
import java.lang.reflect.InvocationHandler;
|
|
9 |
import java.lang.reflect.Method;
|
|
10 |
|
|
11 |
|
|
12 |
public class ImplementationHidingComponentFactory extends DefaultComponentFactory { |
|
13 |
|
|
14 | 2 |
public Object createComponent(Class compType, Constructor constructor, Object[] args) throws PicoInvocationTargetInitailizationException { |
15 | 2 |
Object component = super.createComponent(compType, constructor, args);
|
16 | 1 |
return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {compType}, new ImplementationHidingProxy(component)); |
17 |
} |
|
18 |
|
|
19 |
private class ImplementationHidingProxy implements InvocationHandler { |
|
20 |
private Object componentInstance;
|
|
21 |
|
|
22 | 1 |
public ImplementationHidingProxy(Object componentInstance) {
|
23 | 1 |
this.componentInstance = componentInstance;
|
24 |
} |
|
25 |
|
|
26 | 1 |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
27 | 1 |
return method.invoke(componentInstance, args);
|
28 |
} |
|
29 |
} |
|
30 |
} |
|
31 |
|
|