@Test void injectWithProxy() throws Exception { final Map<Class<?>, Object> services = new HashMap<>(1); LocalCache localCache = new LocalCacheService("LocalCacheServiceTest", System::currentTimeMillis, this.executor); services.put(LocalCache.class, localCache); final InjectedCache instance = new InjectedCache(); ProxyGenerator proxyGenerator = new ProxyGenerator(); final Class<?> proxyClass = proxyGenerator .generateProxy(Thread.currentThread().getContextClassLoader(), InjectedCache.class, "injector", InjectedCache.class.getName()); final InjectedCache proxy = InjectedCache.class.cast(proxyClass.getConstructor().newInstance()); proxyGenerator.initialize(proxy, new InterceptorHandlerFacade(instance, services)); injector.inject(proxy); assertEquals("false", proxy.getString()); assertTrue(proxy.getClass().getName().endsWith("$TalendServiceProxy")); }
@Override public <T> T inject(final T instance) { if (instance == null) { return null; } doInject(instance.getClass(), unwrap(instance)); return instance; }
InjectorImpl implements Serializable, Injector { @Override public <T> T inject(final T instance) { if (instance == null) { return null; } doInject(instance.getClass(), unwrap(instance)); return instance; } }
InjectorImpl implements Serializable, Injector { @Override public <T> T inject(final T instance) { if (instance == null) { return null; } doInject(instance.getClass(), unwrap(instance)); return instance; }  }
InjectorImpl implements Serializable, Injector { @Override public <T> T inject(final T instance) { if (instance == null) { return null; } doInject(instance.getClass(), unwrap(instance)); return instance; }  @Override T inject(final T instance); }
InjectorImpl implements Serializable, Injector { @Override public <T> T inject(final T instance) { if (instance == null) { return null; } doInject(instance.getClass(), unwrap(instance)); return instance; }  @Override T inject(final T instance);  }