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


Java Client类代码示例

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


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

示例1: XEStudentEnrollment

import org.restlet.Client; //导入依赖的package包/类
public XEStudentEnrollment() {
	List<Protocol> protocols = new ArrayList<Protocol>();
	protocols.add(Protocol.HTTP);
	protocols.add(Protocol.HTTPS);
	iClient = new Client(protocols);
	try {
		String clazz = ApplicationProperty.CustomizationExternalTerm.value();
		if (clazz == null || clazz.isEmpty())
			iExternalTermProvider = new BannerTermProvider();
		else
			iExternalTermProvider = (ExternalTermProvider)Class.forName(clazz).getConstructor().newInstance();
	} catch (Exception e) {
		sLog.error("Failed to create external term provider, using the default one instead.", e);
		iExternalTermProvider = new BannerTermProvider();
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:17,代码来源:XEStudentEnrollment.java

示例2: DegreeWorksCourseRequests

import org.restlet.Client; //导入依赖的package包/类
public DegreeWorksCourseRequests() {
	List<Protocol> protocols = new ArrayList<Protocol>();
	protocols.add(Protocol.HTTP);
	protocols.add(Protocol.HTTPS);
	iClient = new Client(protocols);
	try {
		String clazz = ApplicationProperty.CustomizationExternalTerm.value();
		if (clazz == null || clazz.isEmpty())
			iExternalTermProvider = new BannerTermProvider();
		else
			iExternalTermProvider = (ExternalTermProvider)Class.forName(clazz).getConstructor().newInstance();
	} catch (Exception e) {
		sLog.error("Failed to create external term provider, using the default one instead.", e);
		iExternalTermProvider = new BannerTermProvider();
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:17,代码来源:DegreeWorksCourseRequests.java

示例3: DegreeWorksPlanScraper

import org.restlet.Client; //导入依赖的package包/类
public DegreeWorksPlanScraper(Set<String> filter) {
	List<Protocol> protocols = new ArrayList<Protocol>();
	protocols.add(Protocol.HTTP);
	protocols.add(Protocol.HTTPS);
	iClient = new Client(protocols);
	iFilter = filter;
	try {
		String clazz = ApplicationProperty.CustomizationExternalTerm.value();
		if (clazz == null || clazz.isEmpty())
			iExternalTermProvider = new BannerTermProvider();
		else
			iExternalTermProvider = (ExternalTermProvider)Class.forName(clazz).getConstructor().newInstance();
	} catch (Exception e) {
		sLog.error("Failed to create external term provider, using the default one instead.", e);
		iExternalTermProvider = new BannerTermProvider();
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:18,代码来源:DegreeWorksPlanScraper.java

示例4: testListPaging

import org.restlet.Client; //导入依赖的package包/类
@Test
public void testListPaging() throws Exception {
	Component component = new Component();
	component.getServers().add(Protocol.HTTP, port);
	component.getDefaultHost().attach(setupAppPaging());
	component.start();

	try {
		Client client = new Client(Protocol.HTTP);

		long count = getCount(client, "READY");
		assertEquals(pagingTotal, count);

		Collection<FileTrackingStatus> statusObjColl = getStatusObject(
				client, "READY", 0, 30);

		assertEquals(30, statusObjColl.size());
	} finally {
		component.stop();
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:23,代码来源:TestFileTrackerStatusResource.java

示例5: getStatusObject

import org.restlet.Client; //导入依赖的package包/类
/**
 * Helper method. The method will call the client with the status parameter
 * provided and using json return a FileTrackingStatus as response
 * 
 * @param client
 * @param status
 * @return
 * @throws Exception
 */
@SuppressWarnings("unchecked")
private Collection<FileTrackingStatus> getStatusObject(Client client,
		String status, int from, int max) throws Exception {

	ByteArrayOutputStream out = new ByteArrayOutputStream();
	ClientResource clientResource = new ClientResource("http://localhost:"
			+ port + "/files/list/" + status);
	if (from > -1) {
		clientResource.setRanges(Arrays.asList(new Range(from, max)));
	}

	clientResource.get(MediaType.APPLICATION_JSON).write(out);

	ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
	ObjectMapper om = new ObjectMapper();

	return (Collection<FileTrackingStatus>) om.readValue(in,
			Collection.class);

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:30,代码来源:TestFileTrackerStatusResource.java

示例6: testGetsStatus

import org.restlet.Client; //导入依赖的package包/类
@Test
public void testGetsStatus() throws Exception {
	Component component = new Component();
	component.getServers().add(Protocol.HTTP, port);
	component.getDefaultHost().attach(setupApp());
	component.start();

	try {
		Client client = new Client(Protocol.HTTP);
		
		for(File file: Arrays.asList(new File("test1.txt"), new File("test2.txt"), new File("test3.txt"))){
		
			FileTrackingStatus status = getStatusObject(client, file.getAbsolutePath());
			
			assertNotNull(status);
			assertEquals(file.getAbsolutePath(), status.getPath());
			
		}
		
	} finally {
		component.stop();
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:25,代码来源:TestFileTrackerStatusPathResource.java

示例7: registerHelpers

import org.restlet.Client; //导入依赖的package包/类
/**
 * Registers the helpers for a given bundle.
 * 
 * @param bundle
 *            The bundle to inspect.
 */
private void registerHelpers(Bundle bundle) {
    // Register server helpers
    registerHelper(bundle, Engine.getInstance().getRegisteredServers(),
            Server.class, Engine.DESCRIPTOR_SERVER_PATH);

    // Register client helpers
    registerHelper(bundle, Engine.getInstance().getRegisteredClients(),
            Client.class, Engine.DESCRIPTOR_CLIENT_PATH);

    // Register authentication helpers
    registerHelper(bundle, Engine.getInstance()
            .getRegisteredAuthenticators(), null,
            Engine.DESCRIPTOR_AUTHENTICATOR_PATH);

    // Register converter helpers
    registerHelper(bundle, Engine.getInstance().getRegisteredConverters(),
            null, Engine.DESCRIPTOR_CONVERTER_PATH);
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:25,代码来源:Activator.java

示例8: pullData

import org.restlet.Client; //导入依赖的package包/类
/**
 * Pulls data from CloudStack API
 *
 * @return JSON string
 * @throws IOException
 */
private String pullData() throws IOException {
    logger.trace("Starting to pull data from provided URL");

    // create connection
    Client client = new Client(Protocol.HTTP);
    ClientResource cr = new ClientResource(url);
    Request req = cr.getRequest();

    // now header
    Series<Header> headerValue = new Series<Header>(Header.class);
    req.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, headerValue);
    headerValue.add("Accept", "application/json");
    headerValue.add("Content-Type", "application/json");

    // fire it up
    cr.get(MediaType.APPLICATION_JSON);
    Representation output = cr.getResponseEntity();

    logger.trace("Successfully pulled data from provided URL");

    // and return response data
    return output.getText();
}
 
开发者ID:icclab,项目名称:cyclops-udr,代码行数:30,代码来源:CloudStackDownloader.java

示例9: setUp

import org.restlet.Client; //导入依赖的package包/类
@Before
public void setUp() {
    ServerManager.getInstance().setServer(new StubMCServer());
    component = new Component();
    client =  new Client(Protocol.HTTP);
    // Add a new HTTP server listening on port 8182.
    component.getServers().add(Protocol.HTTP, port);
    // Attach the sample application.
    component.getDefaultHost().attach("/mcrest", new RestApplication());
    try {
        component.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
    serverUrl = "http://127.0.0.1:"+port+"/mcrest";
}
 
开发者ID:eternnoir,项目名称:MCRest,代码行数:17,代码来源:ServerStatusTest.java

示例10: list

import org.restlet.Client; //导入依赖的package包/类
@Override
public List<Car> list() {
    Client client = new Client(new Context(), Protocol.HTTPS);
    Series<Parameter> parameters = client.getContext().getParameters();
    parameters.add("truststorePath", System.getProperty("javax.net.ssl.trustStore"));

    ClientResource clientResource = new ClientResource("https://localhost:8043/api/cars/cars");
    clientResource.setNext(client);
    ChallengeResponse challenge = new ChallengeResponse(ChallengeScheme.HTTP_OAUTH_BEARER);
    challenge.setRawValue(Request.getCurrent().getAttributes().getOrDefault("token", "").toString());
    clientResource.setChallengeResponse(challenge);
    CarServiceInterface carServiceInterface = clientResource.wrap(CarServiceInterface.class);
    Car[] allCars = carServiceInterface.getAllCars();
    try {
        client.stop();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return asList(allCars);
}
 
开发者ID:cdelmas,项目名称:microservices-comparison,代码行数:21,代码来源:RemoteCarService.java

示例11: pullData

import org.restlet.Client; //导入依赖的package包/类
/**
 * Pull data from provided URL
 * @param url
 * @return output string or empty string
 */
private String pullData(String url) throws IOException {
    Client client = new Client(Protocol.HTTP);
    ClientResource cr = new ClientResource(url);
    Request req = cr.getRequest();

    // now header
    Series<Header> headerValue = new Series<Header>(Header.class);
    req.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, headerValue);
    headerValue.add("Accept", "application/json");
    headerValue.add("Content-Type", "application/json");

    // fire it up
    cr.get(MediaType.APPLICATION_JSON);
    Representation output = cr.getResponseEntity();

    // return null or received text
    return (output == null) ? "" : output.getText();
}
 
开发者ID:icclab,项目名称:cyclops-rc,代码行数:24,代码来源:McnPuller.java

示例12: pullData

import org.restlet.Client; //导入依赖的package包/类
/**
 * Pull data from provided URL
 *
 * @param url
 * @return output string
 */
private String pullData(String url) throws IOException {
    Client client = new Client(Protocol.HTTP);
    ClientResource cr = new ClientResource(url);
    Request req = cr.getRequest();

    // now header
    Series<Header> headerValue = new Series<Header>(Header.class);
    req.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, headerValue);
    headerValue.add("Accept", "application/json");
    headerValue.add("Content-Type", "application/json");

    // fire it up
    cr.get(MediaType.APPLICATION_JSON);
    Representation output = cr.getResponseEntity();

    // and return response data
    return output.getText();
}
 
开发者ID:icclab,项目名称:cyclops-rc,代码行数:25,代码来源:AccountingClient.java

示例13: LRSystemComponent

import org.restlet.Client; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @throws Exception
 */
public LRSystemComponent() throws Exception {
	// Set basic properties
	setName("License Recognition Server");
	setDescription("License Recognition");
	setOwner("Software college");
	setAuthor("Justin Yang");

	// Add connectors
	getClients().add(new Client(Protocol.CLAP));
	getClients().add(new Client(Protocol.FILE));

	Server server = new Server(new Context(), Protocol.HTTP, 8183);
	
	// Tracing
	getServers().add(server);

	LRSystemApplication app = new LRSystemApplication();
	
	// Configure the default virtual host
	VirtualHost host = getDefaultHost();

	// Attach the application to the default virtual host
	host.attachDefault(app);
}
 
开发者ID:yang2012,项目名称:LicenseRecognition,代码行数:30,代码来源:LRSystemComponent.java

示例14: get

import org.restlet.Client; //导入依赖的package包/类
public static ZNRecord get(Client client, String url) throws IOException {
  Reference resourceRef = new Reference(url);
  Request request = new Request(Method.GET, resourceRef);
  Response response = client.handle(request);
  Assert.assertEquals(response.getStatus(), Status.SUCCESS_OK);
  Representation result = response.getEntity();
  StringWriter sw = new StringWriter();
  result.write(sw);

  String responseStr = sw.toString();
  Assert.assertTrue(responseStr.toLowerCase().indexOf("error") == -1);
  Assert.assertTrue(responseStr.toLowerCase().indexOf("exception") == -1);
  ObjectMapper mapper = new ObjectMapper();
  ZNRecord record = mapper.readValue(new StringReader(responseStr), ZNRecord.class);
  return record;
}
 
开发者ID:apache,项目名称:helix,代码行数:17,代码来源:AdminTestHelper.java

示例15: post

import org.restlet.Client; //导入依赖的package包/类
public static ZNRecord post(Client client, String url, String body)
    throws IOException {
  Reference resourceRef = new Reference(url);
  Request request = new Request(Method.POST, resourceRef);

  request.setEntity(body, MediaType.APPLICATION_ALL);

  Response response = client.handle(request);
  Assert.assertEquals(response.getStatus(), Status.SUCCESS_OK);
  Representation result = response.getEntity();
  StringWriter sw = new StringWriter();

  if (result != null) {
    result.write(sw);
  }
  String responseStr = sw.toString();
  Assert.assertTrue(responseStr.toLowerCase().indexOf("error") == -1);
  Assert.assertTrue(responseStr.toLowerCase().indexOf("exception") == -1);

  ObjectMapper mapper = new ObjectMapper();
  ZNRecord record = mapper.readValue(new StringReader(responseStr), ZNRecord.class);
  return record;
}
 
开发者ID:apache,项目名称:helix,代码行数:24,代码来源:AdminTestHelper.java


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