Examples of WebTarget


Examples of javax.ws.rs.client.WebTarget

    }

    public PoolStatistics getPoolStats(String application, String ejbName) {
        final String uri = getUri();
        System.out.println("Uri: " + uri);
        WebTarget target = this.client.target(uri);

        Response response = target.
                resolveTemplate("application", application).
                resolveTemplate("ejb", ejbName).
                request(MediaType.APPLICATION_JSON).get(Response.class);

        if (response.getStatus() == 404) {
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

    }

    public void retrieveSessionToken() {
        //TODO: support authentication with JAX-RS 2.0
        //authenticator.get().addAuthenticator(client, username.get(), password.get());
        WebTarget managementResource = this.client.target(getSessionsUri());
        JsonObject result = managementResource
                .path("sessions")
                .request(MediaType.APPLICATION_JSON)
                .header("X-Requested-By", "")
                .post(Entity.entity(Json.createObjectBuilder().build(), MediaType.APPLICATION_JSON), JsonObject.class);
        JsonObject extraProps = result.getJsonObject("extraProperties");
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

        return getResponse(uri, 0);
    }

    protected Response getResponse(String uri, int retries) {
        String fullUri = getBaseURI() + uri;
        WebTarget resource = client.target(fullUri);
        Invocation.Builder builder = resource.request(MediaType.APPLICATION_JSON);
        if (sessionToken != null && sessionToken.get() != null && !sessionToken.get().isEmpty()) {
            builder.cookie(new Cookie("gfresttoken", sessionToken.get()));
        }
        return builder.get(Response.class);
    }
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

        JsonObject applications = client.target(getUri()).path(applicationName).request(MediaType.APPLICATION_JSON).get(JsonObject.class);
        return preprocessChildResource(applications);
    }

    public JsonObject fetchMethods(String applicationName, String ejbName) {
        WebTarget target = client.target(getUri() + "{application}/{bean}/bean-methods/");
        Response response = target.resolveTemplate("application", applicationName).
                resolveTemplate("bean", ejbName).
                request(MediaType.APPLICATION_JSON).get(Response.class);
        if (response.getStatus() == 404) {
            return null;
        }
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

        JsonObject rawStatistics = response.readEntity(JsonObject.class);
        return preprocessChildResource(rawStatistics);
    }

    public JsonObject fetchApplicationStatistics(String applicationName) {
        WebTarget target = client.target(getUri() + "{application}/server/");
        Response response = target.resolveTemplate("application", applicationName).
                request(MediaType.APPLICATION_JSON).get(Response.class);
        if (response.getStatus() == 404) {
            return null;
        }
        JsonObject rawStatistics = response.readEntity(JsonObject.class);
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

        JsonObject rawStatistics = response.readEntity(JsonObject.class);
        return preprocessEntity(rawStatistics);
    }

    public JsonObject fetchMethodStatistics(String applicationName, String ejbName, String methodName) {
        WebTarget target = client.target(getUri() + "{application}/{bean}/bean-methods/{method}");
        Response response = target.resolveTemplate("application", applicationName).
                resolveTemplate("bean", ejbName).
                resolveTemplate("method", methodName).
                request(MediaType.APPLICATION_JSON).get(Response.class);
        if (response.getStatus() == 404) {
            return null;
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

        JsonObject rawStatistics = response.readEntity(JsonObject.class);
        return preprocessEntity(rawStatistics);
    }

    public JsonObject fetchBeanPoolStatistics(String applicationName, String ejbName) {
        WebTarget target = client.target(getUri() + "{application}/{bean}/bean-pool");
        Response response = target.resolveTemplate("application", applicationName).
                resolveTemplate("bean", ejbName).
                request(MediaType.APPLICATION_JSON).get(Response.class);
        if (response.getStatus() == 404) {
            return null;
        }
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

  @Test
  public void shouldCheckForH2G2Verbose() throws URISyntaxException {

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.TEXT_PLAIN).get().getStatus());
    URI uri = new URI("http://localhost:8282/03/book");
    target = client.target(uri);
    assertEquals(Response.Status.OK.getStatusCode(), target.request(MediaType.TEXT_PLAIN).get().getStatus());
  }
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

  @Test
  public void shouldCheckForH2G2WithWebTarget() {

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    Invocation.Builder builder = target.request(MediaType.TEXT_PLAIN);
    Response response = builder.get();
    String entity = response.readEntity(String.class);

    assertEquals("H2G2", entity);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
View Full Code Here

Examples of javax.ws.rs.client.WebTarget

  @Test
  public void shouldCheckForH2G2WithInvocation() {

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    Invocation invocation = target.request(MediaType.TEXT_PLAIN).buildGet();
    Response response = invocation.invoke();
    String entity = response.readEntity(String.class);

    assertEquals("H2G2", entity);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.