Search in sources :

Example 26 with ResteasyWebTarget

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);
        }
    }
}
Also used : RealmsResource(org.keycloak.admin.client.resource.RealmsResource) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)

Example 27 with ResteasyWebTarget

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;
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)

Example 28 with ResteasyWebTarget

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);
}
Also used : ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ResteasyProviderFactory(org.jboss.resteasy.spi.ResteasyProviderFactory) Client(javax.ws.rs.client.Client)

Example 29 with ResteasyWebTarget

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);
}
Also used : ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)

Example 30 with ResteasyWebTarget

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());
}
Also used : ProviderList(org.guvnor.ala.services.api.itemlist.ProviderList) MavenProjectConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl) ContextAwareDockerProvisioningConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerProvisioningConfig) DockerBuildConfigImpl(org.guvnor.ala.docker.config.impl.DockerBuildConfigImpl) ArrayList(java.util.ArrayList) DockerProviderConfig(org.guvnor.ala.docker.config.DockerProviderConfig) Input(org.guvnor.ala.pipeline.Input) PipelineConfigStage(org.guvnor.ala.pipeline.PipelineConfigStage) PipelineService(org.guvnor.ala.services.api.PipelineService) RuntimeList(org.guvnor.ala.services.api.itemlist.RuntimeList) PipelineConfigsList(org.guvnor.ala.services.api.itemlist.PipelineConfigsList) MavenBuildConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl) Client(javax.ws.rs.client.Client) ContextAwareDockerRuntimeExecConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerRuntimeExecConfig) DockerProvider(org.guvnor.ala.docker.model.DockerProvider) GitConfigImpl(org.guvnor.ala.source.git.config.impl.GitConfigImpl) DockerProviderConfigImpl(org.guvnor.ala.docker.config.impl.DockerProviderConfigImpl) ProviderTypeList(org.guvnor.ala.services.api.itemlist.ProviderTypeList) MavenBuildExecConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl) RuntimeProvisioningService(org.guvnor.ala.services.api.RuntimeProvisioningService) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) WebTarget(javax.ws.rs.client.WebTarget) PipelineConfigImpl(org.guvnor.ala.pipeline.impl.PipelineConfigImpl) Ignore(org.junit.Ignore)

Aggregations

ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)59 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)42 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)20 Response (javax.ws.rs.core.Response)13 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)10 Test (org.junit.Test)9 WebTarget (javax.ws.rs.client.WebTarget)8 Client (javax.ws.rs.client.Client)7 ServicesInterface (com.baeldung.client.ServicesInterface)6 IOException (java.io.IOException)6 ApacheHttpClient4Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine)5 ResteasyProviderFactory (org.jboss.resteasy.spi.ResteasyProviderFactory)5 TimeUnit (java.util.concurrent.TimeUnit)4 Invocation (javax.ws.rs.client.Invocation)4 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)4 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Locale (java.util.Locale)3 Map (java.util.Map)3