当前位置: 首页>>代码示例>>Java>>正文


Java LoggingFilter类代码示例

本文整理汇总了Java中com.sun.jersey.api.client.filter.LoggingFilter的典型用法代码示例。如果您正苦于以下问题:Java LoggingFilter类的具体用法?Java LoggingFilter怎么用?Java LoggingFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LoggingFilter类属于com.sun.jersey.api.client.filter包,在下文中一共展示了LoggingFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResource

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
@Override
public WebResource getResource() {
	WebResource webResource = null;
	ClientConfig config = new DefaultClientConfig();
	config.getClasses().add(GsonJerseyProvider.class);
	Client client = Client.create(config);
	OAuthParameters oaParams = new OAuthParameters().signatureMethod("HMAC-SHA1").consumerKey(consumerKey)
			.token(accessToken).version("1.0");
	OAuthSecrets oaSecrets = new OAuthSecrets().consumerSecret(consumerSecret).tokenSecret(accessTokenSecret);

	OAuthClientFilter oAuthFilter = new OAuthClientFilter(client.getProviders(), oaParams, oaSecrets);
	client.addFilter(oAuthFilter);

	if (this.sandbox) {
		webResource = client.resource(Constants.SANDBOX_BASE_API_URL);
	} else if (null!= this.domain){
		webResource = client.resource(this.domain);
	}
	else{
		webResource = client.resource(Constants.BASE_API_URL);
	}
	
	
	if (this.trace) {
		webResource.addFilter(new LoggingFilter());
	}
	return webResource;
}
 
开发者ID:mrisney,项目名称:twitter-java-ads-sdk,代码行数:29,代码来源:ClientServiceImpl.java

示例2: rebuildHttpClient

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
/**
 * Build the Client used to make HTTP requests with the latest settings,
 * i.e. objectMapper and debugging.
 * TODO: better to use the Builder Pattern?
 */
public ApiClient rebuildHttpClient() {
  // Add the JSON serialization support to Jersey
  JacksonJsonProvider jsonProvider = new JacksonJsonProvider(objectMapper);
  DefaultClientConfig conf = new DefaultClientConfig();
  conf.getSingletons().add(jsonProvider);
  Client client = Client.create(conf);
  if (debugging) {
    client.addFilter(new LoggingFilter());
  }
  
  //to solve the issue of GET:metadata/:guid with accepted encodeing is 'gzip' 
  //in the past, when clients use gzip header, actually it doesn't trigger a gzip encoding... So everything is fine 
  //After the release, the content is return in gzip, while the sdk doesn't handle it correctly
  client.addFilter(new GZIPContentEncodingFilter(false));

  this.httpClient = client;
  return this;
}
 
开发者ID:Autodesk-Forge,项目名称:forge-api-java-client,代码行数:24,代码来源:ApiClient.java

示例3: getEwayWebResource

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
/**
 * Fetches and configures a Web Resource to connect to eWAY
 *
 * @return A WebResource
 */
private WebResource getEwayWebResource() {
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    Client client = Client.create(clientConfig);
    client.addFilter(new HTTPBasicAuthFilter(APIKey, password));

    if (this.debug) {
        client.addFilter(new LoggingFilter(System.out));
    }

    // Set additional headers
    RapidClientFilter rapidFilter = new RapidClientFilter();
    rapidFilter.setVersion(apiVersion);
    client.addFilter(rapidFilter);

    WebResource resource = client.resource(webUrl);
    return resource;
}
 
开发者ID:eWAYPayment,项目名称:eway-rapid-java,代码行数:24,代码来源:RapidClientImpl.java

示例4: getClient

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
/**
 * Returns jersey client to make any call to webservice 
 * @return
 */
private Client getClient(boolean is_multipart) {
	if(m_client == null) {
		if(is_multipart) {
			ClientConfig config = new DefaultClientConfig();
			config.getClasses().add(MultiPartWriter.class);
			m_client = Client.create(config);
		} else {
			m_client = new Client();
		}
		
		if(!isTokenbasedAuth) {
			final HTTPBasicAuthFilter authFilter = new HTTPBasicAuthFilter(x_username, x_password);
			m_client.addFilter(authFilter);
			m_client.addFilter(new LoggingFilter());
		} else {
			//TODO for token based authentication
		}
	}

	return m_client;
}
 
开发者ID:awaazde,项目名称:awaazde-api-client-sdk,代码行数:26,代码来源:XACTRequester.java

示例5: login

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
/**
 * Logs in into the NEst service and captures session information
 *
 * @throws ConnectionException if the credentials are incorrect
 * @throws IOException if the response date cannot be parsed
 */
@Start
public void login() throws ConnectionException, IOException
{
    httpClient.addFilter(new LoggingFilter());
    MultivaluedMap<String, String> map = new MultivaluedMapImpl();
    map.putSingle("username", getUsername());
    map.putSingle("password", getPassword());


    WebResource webResource = httpClient.resource("https://home.nest.com/user/login");

    ClientResponse response = webResource.type("application/x-www-form-urlencoded")
            .post(ClientResponse.class, map);

    if (response.getStatus()> 399)
    {
        throw new ConnectionException(ConnectionExceptionCode.INCORRECT_CREDENTIALS, "unauthorized user", response.toString());
    }
    String res = response.getEntity(String.class);
    System.out.println("Login: " + res);
    login = mapper.readValue(res, Login.class);
    baseUri = login.getUrls().getTransportUrl();

    getMetaData();
}
 
开发者ID:mulesoft-labs,项目名称:nest-connector,代码行数:32,代码来源:NestConnector.java

示例6: RestClient

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
public RestClient (URI baseURI)
{
	ObjectMapper mapper = Jackson.newObjectMapper ()
	                             .registerModule (new SupernodeModule ());

	Validator validator = Validation.buildDefaultValidatorFactory ().getValidator ();

	ClientConfig cc = new DefaultClientConfig (JsonProcessingExceptionMapper.class);
	cc.getProperties ().put (ClientConfig.PROPERTY_CONNECT_TIMEOUT, 5000);
	cc.getProperties ().put (ClientConfig.PROPERTY_READ_TIMEOUT, 5000);
	cc.getSingletons ().add (new JacksonMessageBodyProvider (mapper, validator));

	Client client = Client.create (cc);
	client.addFilter (new LoggingFilter ());

	this.client = client;
	this.baseURI = baseURI;
}
 
开发者ID:bitsofproof,项目名称:btc1k,代码行数:19,代码来源:RestClient.java

示例7: testGetNewApplication

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
@Test
public void testGetNewApplication() throws Exception {
  client().addFilter(new LoggingFilter(System.out));
  rm.start();
  String mediaTypes[] =
      { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML };
  for (String acceptMedia : mediaTypes) {
    testGetNewApplication(acceptMedia);
  }
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestRMWebServicesAppsModification.java

示例8: testGetAppQueue

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
@Test
public void testGetAppQueue() throws Exception {
  client().addFilter(new LoggingFilter(System.out));
  boolean isCapacityScheduler =
      rm.getResourceScheduler() instanceof CapacityScheduler;
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  String[] contentTypes =
      { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML };
  for (String contentType : contentTypes) {
    RMApp app = rm.submitApp(CONTAINER_MB, "", webserviceUserName);
    amNodeManager.nodeHeartbeat(true);
    ClientResponse response =
        this
          .constructWebResource("apps", app.getApplicationId().toString(),
            "queue").accept(contentType).get(ClientResponse.class);
    assertEquals(Status.OK, response.getClientResponseStatus());
    String expectedQueue = "default";
    if(!isCapacityScheduler) {
      expectedQueue = "root." + webserviceUserName;
    }
    if (contentType.equals(MediaType.APPLICATION_JSON)) {
      verifyAppQueueJson(response, expectedQueue);
    } else {
      verifyAppQueueXML(response, expectedQueue);
    }
  }
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestRMWebServicesAppsModification.java

示例9: testCreateDelegationToken

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
@Test
public void testCreateDelegationToken() throws Exception {
  rm.start();
  this.client().addFilter(new LoggingFilter(System.out));
  final String renewer = "test-renewer";
  String jsonBody = "{ \"renewer\" : \"" + renewer + "\" }";
  String xmlBody =
      "<delegation-token><renewer>" + renewer
          + "</renewer></delegation-token>";
  String[] mediaTypes =
      { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML };
  Map<String, String> bodyMap = new HashMap<String, String>();
  bodyMap.put(MediaType.APPLICATION_JSON, jsonBody);
  bodyMap.put(MediaType.APPLICATION_XML, xmlBody);
  for (final String mediaType : mediaTypes) {
    final String body = bodyMap.get(mediaType);
    for (final String contentType : mediaTypes) {
      if (isKerberosAuth == true) {
        verifyKerberosAuthCreate(mediaType, contentType, body, renewer);
      } else {
        verifySimpleAuthCreate(mediaType, contentType, body);
      }
    }
  }

  rm.stop();
  return;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestRMWebServicesDelegationTokens.java

示例10: testNodeHelper

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
public void testNodeHelper(String path, String media) throws JSONException,
    Exception {
  WebResource r = resource();
  Application app = new MockApp(1);
  nmContext.getApplications().put(app.getAppId(), app);
  addAppContainers(app);
  Application app2 = new MockApp(2);
  nmContext.getApplications().put(app2.getAppId(), app2);
  addAppContainers(app2);
  client().addFilter(new LoggingFilter());

  ClientResponse response = r.path("ws").path("v1").path("node").path(path)
      .accept(media).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  JSONObject info = json.getJSONObject("containers");
  assertEquals("incorrect number of elements", 1, info.length());
  JSONArray conInfo = info.getJSONArray("container");
  assertEquals("incorrect number of elements", 4, conInfo.length());

  for (int i = 0; i < conInfo.length(); i++) {
    verifyNodeContainerInfo(
        conInfo.getJSONObject(i),
        nmContext.getContainers().get(
            ConverterUtils.toContainerId(conInfo.getJSONObject(i).getString(
                "id"))));
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:29,代码来源:TestNMWebServicesContainers.java

示例11: testNodeSingleContainerXML

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
@Test
public void testNodeSingleContainerXML() throws JSONException, Exception {
  WebResource r = resource();
  Application app = new MockApp(1);
  nmContext.getApplications().put(app.getAppId(), app);
  HashMap<String, String> hash = addAppContainers(app);
  Application app2 = new MockApp(2);
  nmContext.getApplications().put(app2.getAppId(), app2);
  addAppContainers(app2);
  client().addFilter(new LoggingFilter(System.out));

  for (String id : hash.keySet()) {
    ClientResponse response = r.path("ws").path("v1").path("node")
        .path("containers").path(id).accept(MediaType.APPLICATION_XML)
        .get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
    String xml = response.getEntity(String.class);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource is = new InputSource();
    is.setCharacterStream(new StringReader(xml));
    Document dom = db.parse(is);
    NodeList nodes = dom.getElementsByTagName("container");
    assertEquals("incorrect number of elements", 1, nodes.getLength());
    verifyContainersInfoXML(nodes,
        nmContext.getContainers().get(ConverterUtils.toContainerId(id)));

  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:30,代码来源:TestNMWebServicesContainers.java

示例12: rebuildHttpClient

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
/**
 * Build the Client used to make HTTP requests with the latest settings,
 * i.e. objectMapper and debugging.
 */
public ApiClient rebuildHttpClient() {
    // Add the JSON serialization support to Jersey
    JacksonJsonProvider jsonProvider = new JacksonJsonProvider(objectMapper);
    DefaultClientConfig conf = new DefaultClientConfig();
    conf.getSingletons().add(jsonProvider);
    Client client = Client.create(conf);
    if (debugging) {
        client.addFilter(new LoggingFilter());
    }
    this.httpClient = client;
    return this;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:17,代码来源:ApiClient.java

示例13: getClient

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
/**
 * Get an existing client or create a new client to handle HTTP request.
 */
private Client getClient() {
  if(!hostMap.containsKey(basePath)) {
    Client client = Client.create();
    if (debugging)
      client.addFilter(new LoggingFilter());
    hostMap.put(basePath, client);
  }
  return hostMap.get(basePath);
}
 
开发者ID:normalian,项目名称:BotDirectlineApp-Java,代码行数:13,代码来源:ApiClient.java

示例14: main

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		TwitterAdsClient.setTrace(true);
		TwitterAdsClient.setSandbox(false);
		String domain = "https://ads-api.twitter.com";

		TwitterAdsClient.setDomain(domain);

		WebResource webResource = Resource.getResource();
		webResource.addFilter(new LoggingFilter());

		String resourcePath = "/0/accounts/" + ACCOUNT_ID + "/promoted_tweets";

		MultivaluedMap<String, String> params = new MultivaluedMapImpl();
		params.add("with_deleted", "true");

		List<PromotedTweet> promotedTweets = webResource
				.queryParams(params)
				.path(resourcePath)
				.accept(MediaType.APPLICATION_JSON_TYPE)
				.get(new GenericType<List<PromotedTweet>>() {});
		
		
		for (PromotedTweet promotedTweet : promotedTweets) {
			//System.out.println(promotedTweet.toString());
			Long tweetIdL =  Long.parseLong(promotedTweet.getTweet_id());
			System.out.println(tweetIdL);
			Tweet.destroy(tweetIdL);
		}

	}
 
开发者ID:mrisney,项目名称:twitter-java-ads-sdk,代码行数:32,代码来源:StatusUtils.java

示例15: getClient

import com.sun.jersey.api.client.filter.LoggingFilter; //导入依赖的package包/类
/**
 * Get an existing client or create a new client to handle HTTP request.
 */
private Client getClient(String baseUrl) {
  if (!hostMap.containsKey(baseUrl)) {
    Client client = Client.create();
    if (debugging)
      client.addFilter(new LoggingFilter());
    hostMap.put(baseUrl,
        client);
  }
  return hostMap.get(baseUrl);
}
 
开发者ID:adobe-sign,项目名称:AdobeSignJavaSdk,代码行数:14,代码来源:ApiClient.java


注:本文中的com.sun.jersey.api.client.filter.LoggingFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。