use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project openremote by openremote.
the class KeycloakIdentityProvider method getRealms.
public final synchronized <T> T getRealms(Function<RealmsResource, T> consumer) {
RealmsResource realmsResource;
// Track this in case active credentials updated
ResteasyWebTarget target = keycloakTarget;
if ((realmsResource = realmsResourcePool.poll()) == null) {
realmsResource = keycloakTarget.proxy(RealmsResource.class);
}
try {
return consumer.apply(realmsResource);
} finally {
if (target == this.keycloakTarget) {
realmsResourcePool.offer(realmsResource);
}
}
}
use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project openremote by openremote.
the class WebTargetBuilder method build.
public ResteasyWebTarget build() {
ResteasyWebTarget target = client.target(baseUri);
target.register(QueryParameterInjectorFilter.class);
if (!failureResponses.isEmpty()) {
// Put a filter with max priority in the filter chain
target.register(new PermanentFailureFilter(failureResponses), 1);
}
if (oAuthGrant != null) {
OAuthFilter oAuthFilter = new OAuthFilter(client, oAuthGrant);
target.register(oAuthFilter, Priorities.AUTHENTICATION);
} else if (basicAuthentication != null) {
target.register(basicAuthentication, Priorities.AUTHENTICATION);
}
if (injectHeaders != null) {
target.register(new HeaderInjectorFilter(injectHeaders));
}
if (injectQueryParameters != null) {
target.property(QueryParameterInjectorFilter.QUERY_PARAMETERS_PROPERTY, mapToMultivaluedMap(injectQueryParameters, new MultivaluedHashMap<>()));
}
if (followRedirects) {
target.register(new FollowRedirectFilter());
}
return target;
}
use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project fabric8 by jboss-fuse.
the class ResteasyGitRepoClient method createWebClient.
/**
* Creates a JAXRS web client for the given JAXRS client
*/
protected <T> T createWebClient(Class<T> clientType) {
String address = getAddress();
ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
providerFactory.register(ResteasyJackson2Provider.class);
providerFactory.register(Jackson2JsonpInterceptor.class);
providerFactory.register(StringTextStar.class);
providerFactory.register(DefaultTextPlain.class);
providerFactory.register(FileProvider.class);
providerFactory.register(InputStreamProvider.class);
providerFactory.register(new Authenticator());
providerFactory.register(clientType);
ResteasyClientBuilder builder = new ResteasyClientBuilder();
builder.providerFactory(providerFactory);
builder.connectionPoolSize(3);
Client client = builder.build();
ResteasyWebTarget target = (ResteasyWebTarget) client.target(address);
return target.proxy(clientType);
}
use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project java by wavefrontHQ.
the class APIContainer method createService.
/**
* Create RESTeasy proxies for remote calls via HTTP.
*/
private <T> T createService(String serverEndpointUrl, Class<T> apiClass) {
ResteasyClient client = new ResteasyClientBuilder().httpEngine(clientHttpEngine).providerFactory(resteasyProviderFactory).build();
ResteasyWebTarget target = client.target(serverEndpointUrl);
return target.proxy(apiClass);
}
use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project kie-wb-common by kiegroup.
the class PipelineEndpointsTestIT method checkService.
@Ignore
public void checkService() {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(APP_URL);
ResteasyWebTarget restEasyTarget = (ResteasyWebTarget) target;
PipelineService proxyPipeline = restEasyTarget.proxy(PipelineService.class);
RuntimeProvisioningService proxyRuntime = restEasyTarget.proxy(RuntimeProvisioningService.class);
ProviderTypeList allProviderTypes = proxyRuntime.getProviderTypes(0, 10, "", true);
assertNotNull(allProviderTypes);
assertEquals(3, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfigImpl();
proxyRuntime.registerProvider(dockerProviderConfig);
ProviderList allProviders = proxyRuntime.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
assertTrue(allProviders.getItems().get(0) instanceof DockerProvider);
PipelineConfigsList allPipelines = proxyPipeline.getPipelineConfigs(0, 10, "", true);
assertNotNull(allPipelines);
assertEquals(0, allPipelines.getItems().size());
List<PipelineConfigStage> configs = new ArrayList<>();
configs.add(new PipelineConfigStage("GitConfig", new GitConfigImpl()));
configs.add(new PipelineConfigStage("MavenProjectConfig", new MavenProjectConfigImpl()));
configs.add(new PipelineConfigStage("MavenBuildConfig", new MavenBuildConfigImpl()));
configs.add(new PipelineConfigStage("DockerBuildConfig", new DockerBuildConfigImpl()));
configs.add(new PipelineConfigStage("MavenBuildExecConfig", new MavenBuildExecConfigImpl()));
configs.add(new PipelineConfigStage("DockerProviderConfig", new DockerProviderConfigImpl()));
configs.add(new PipelineConfigStage("ContextAwareDockerProvisioning", new ContextAwareDockerProvisioningConfig()));
configs.add(new PipelineConfigStage("ContextAwareDockerRuntimeExec", new ContextAwareDockerRuntimeExecConfig()));
String newPipeline = proxyPipeline.newPipeline(new PipelineConfigImpl("mypipe", configs));
Input input = new Input();
input.put("repo-name", "drools-workshop");
input.put("create-repo", "true");
input.put("branch", "master");
input.put("out-dir", tempPath.getAbsolutePath());
input.put("origin", gitUrl);
proxyPipeline.runPipeline("mypipe", input, false);
RuntimeList allRuntimes = proxyRuntime.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
proxyRuntime.destroyRuntime(allRuntimes.getItems().get(0).getId(), true);
allRuntimes = proxyRuntime.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
}
Aggregations