use of org.talend.sdk.component.runtime.manager.service.HttpClientFactoryImpl in project component-runtime by Talend.
the class ReflectionServiceTest method copiable.
@Test
void copiable() throws NoSuchMethodException {
final HashMap<Class<?>, Object> precomputed = new HashMap<>();
precomputed.put(UserHttpClient.class, new HttpClientFactoryImpl("test", new ReflectionService(new ParameterModelService()), JsonbBuilder.create(), emptyMap()).create(UserHttpClient.class, "http://foo"));
final Method httpMtd = TableOwner.class.getMethod("http", UserHttpClient.class);
final HttpClient client1 = HttpClient.class.cast(reflectionService.parameterFactory(httpMtd, precomputed).apply(emptyMap())[0]);
final HttpClient client2 = HttpClient.class.cast(reflectionService.parameterFactory(httpMtd, precomputed).apply(emptyMap())[0]);
assertNotSame(client1, client2);
final InvocationHandler handler1 = Proxy.getInvocationHandler(client1);
final InvocationHandler handler2 = Proxy.getInvocationHandler(client2);
assertNotSame(handler1, handler2);
assertEquals(handler1.toString(), handler2.toString());
}
use of org.talend.sdk.component.runtime.manager.service.HttpClientFactoryImpl in project component-runtime by Talend.
the class ComponentManager method containerServices.
protected void containerServices(final Container container, final Map<Class<?>, Object> services) {
// note: we can move it to manager instances at some point
final JsonProvider jsonpProvider = new PreComputedJsonpProvider(container.getId(), this.jsonpProvider, jsonpParserFactory, jsonpWriterFactory, jsonpBuilderFactory, jsonpGeneratorFactory, jsonpReaderFactory);
services.put(JsonProvider.class, jsonpProvider);
services.put(JsonBuilderFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonBuilderFactory.class.getName(), jsonpBuilderFactory));
services.put(JsonParserFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonParserFactory.class.getName(), jsonpParserFactory));
services.put(JsonReaderFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonReaderFactory.class.getName(), jsonpReaderFactory));
services.put(JsonWriterFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonWriterFactory.class.getName(), jsonpWriterFactory));
services.put(JsonGeneratorFactory.class, javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), JsonGeneratorFactory.class.getName(), jsonpGeneratorFactory));
final Jsonb jsonb = jsonbProvider.create().withProvider(// reuses the same memory buffering
jsonpProvider).withConfig(new JsonbConfig().setProperty("johnzon.cdi.activated", false)).build();
final Jsonb serializableJsonb = Jsonb.class.cast(javaProxyEnricherFactory.asSerializable(container.getLoader(), container.getId(), Jsonb.class.getName(), jsonb));
services.put(Jsonb.class, serializableJsonb);
// not JSON services
services.put(HttpClientFactory.class, new HttpClientFactoryImpl(container.getId(), reflections, serializableJsonb, services));
services.put(LocalCache.class, new LocalCacheService(container.getId()));
services.put(LocalConfiguration.class, new LocalConfigurationService(createRawLocalConfigurations(), container.getId()));
services.put(ProxyGenerator.class, proxyGenerator);
services.put(Resolver.class, new ResolverImpl(container.getId(), container.getLocalDependencyRelativeResolver()));
}
Aggregations