| 140 | } |
| 141 | |
| 142 | @Override |
| 143 | public ConstructionProxy<T> create() throws ErrorsException { |
| 144 | if (interceptors.isEmpty()) { |
| 145 | return new DefaultConstructionProxyFactory<T>(injectionPoint).create(); |
| 146 | } |
| 147 | |
| 148 | // Create the proxied class. We're careful to ensure that interceptor state is not-specific |
| 149 | // to this injector. Otherwise, the proxies for each injector will waste PermGen memory |
| 150 | try { |
| 151 | return new ProxyConstructor<>(injectionPoint, enhancer, interceptors, callbacks); |
| 152 | } catch (Throwable e) { |
| 153 | throw new Errors() |
| 154 | .errorEnhancingClass(injectionPoint.getMember().getDeclaringClass(), e) |
| 155 | .toException(); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | /** Constructs instances that participate in AOP. */ |
| 160 | private static class ProxyConstructor<T> implements ConstructionProxy<T> { |