001/*
002 * Copyright 2011-2016 UnboundID Corp.
003 *
004 * This program is free software; you can redistribute it and/or modify
005 * it under the terms of the GNU General Public License (GPLv2 only)
006 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
007 * as published by the Free Software Foundation.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, see <http://www.gnu.org/licenses>.
016 */
017
018package org.apache.wink.client;
019
020import org.glassfish.jersey.client.JerseyClientBuilder;
021
022import javax.ws.rs.client.Client;
023import java.net.URI;
024import java.net.URISyntaxException;
025
026/**
027 *  Wink compatibility layer class - see Wink docs.
028 */
029public class RestClient
030{
031  private Client client;
032
033  /**
034   *  Wink compatibility layer class - see Wink docs.
035   * @param clientConfig Wink compatibility layer class - see Wink docs.
036   */
037  public RestClient(final org.glassfish.jersey.client.ClientConfig clientConfig)
038  {
039    client = JerseyClientBuilder.newClient(clientConfig);
040  }
041
042  /**
043   *  Wink compatibility layer class - see Wink docs.
044   * @param uriString Wink compatibility layer class - see Wink docs.
045   * @return Wink compatibility layer class - see Wink docs.
046   * @throws URISyntaxException Wink compatibility layer class - see Wink docs.
047   */
048  public Resource resource(final String uriString) throws URISyntaxException
049  {
050    URI uri = new URI(uriString);
051    return new Resource(this, uri);
052  }
053
054  /**
055   *  Wink compatibility layer class - see Wink docs.
056   * @param uri Wink compatibility layer class - see Wink docs.
057   * @return Wink compatibility layer class - see Wink docs.
058   */
059  public Resource resource(final URI uri)
060  {
061    return new Resource(this, uri);
062  }
063
064  /**
065   *  Wink compatibility layer class - see Wink docs.
066   * @return Wink compatibility layer class - see Wink docs.
067   */
068  public Client getClient()
069  {
070    return client;
071  }
072}