當前位置: 首頁>>代碼示例>>Java>>正文


Java ExecuteRequest類代碼示例

本文整理匯總了Java中org.eclipse.leshan.core.request.ExecuteRequest的典型用法代碼示例。如果您正苦於以下問題:Java ExecuteRequest類的具體用法?Java ExecuteRequest怎麽用?Java ExecuteRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ExecuteRequest類屬於org.eclipse.leshan.core.request包,在下文中一共展示了ExecuteRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: excutionOperation

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
private void excutionOperation(String path){
	try{
 	String[] path_ary = path.split("/");
 	if(path_ary.length == 5){
 	
 		String epName = path_ary[1];
 		String target = path.substring(epName.length() + 1, path.length());
 		//int rsID = Integer.parseInt(path_ary[4]);
  	
  	Registration registration = lwServer.getRegistrationService().getByEndpoint(epName);
  	//ContentFormat contentFormat = ContentFormat.fromName("TLV");
	
          // create & process request
            ExecuteRequest request = new ExecuteRequest(target, "");
            ExecuteResponse cResponse = lwServer.send(registration, request, 5000);
 	}
	}catch(Exception exp){
		exp.printStackTrace();
	}
}
 
開發者ID:IoTKETI,項目名稱:IPE-LWM2M,代碼行數:21,代碼來源:SimpleLwm2mServer.java

示例2: execute

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
private synchronized void execute(HttpServletRequest req, HttpServletResponse resp, JSONObject msg, String endPoint) throws JSONException, InterruptedException, IOException{
  	
String target = msg.getString("n");
  	Client client = server.getClientRegistry().get(endPoint);
  	
      if (client != null) {

          ExecuteRequest request = new ExecuteRequest(target, IOUtils.toString(req.getInputStream()));
          ExecuteResponse cResponse = server.send(client, request, TIMEOUT);
          processDeviceResponse(req, resp, cResponse);
      } else {
      	resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
          resp.getWriter().format("no registered client with id '%s'", endPoint).flush();
      }
      
  }
 
開發者ID:iotoasis,項目名稱:SI,代碼行數:17,代碼來源:ApiServlet.java

示例3: build_execute_request

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void build_execute_request() throws Exception {
    Registration reg = newRegistration();

    // test
    CoapRequestBuilder builder = new CoapRequestBuilder(reg.getIdentity(), reg.getRootPath(), reg.getId(),
            reg.getEndpoint(), model, encoder);
    ExecuteRequest request = new ExecuteRequest(3, 0, 12, "params");
    builder.visit(request);

    // verify
    Request coapRequest = builder.getRequest();
    assertEquals(CoAP.Code.POST, coapRequest.getCode());
    assertEquals("127.0.0.1", coapRequest.getDestinationContext().getPeerAddress().getAddress().getHostAddress());
    assertEquals(12354, coapRequest.getDestinationContext().getPeerAddress().getPort());
    assertEquals("coap://127.0.0.1:12354/3/0/12", coapRequest.getURI());
    assertEquals("params", coapRequest.getPayloadString());
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:19,代碼來源:CoapRequestBuilderTest.java

示例4: execute

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Override
public synchronized ExecuteResponse execute(ServerIdentity identity, ExecuteRequest request) {
    LwM2mPath path = request.getPath();

    // execute is not supported for bootstrap
    if (identity.isLwm2mBootstrapServer()) {
        return ExecuteResponse.methodNotAllowed();
    }

    // execute on security object is forbidden
    if (id == LwM2mId.SECURITY) {
        return ExecuteResponse.notFound();
    }

    // only resource could be executed
    if (!path.isResource()) {
        return ExecuteResponse.badRequest(null);
    }

    // check if the resource is writable
    ResourceModel resourceModel = objectModel.resources.get(path.getResourceId());
    if (resourceModel != null && !resourceModel.operations.isExecutable()) {
        return ExecuteResponse.methodNotAllowed();
    }

    return doExecute(request);
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:28,代碼來源:BaseObjectEnabler.java

示例5: doExecute

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Override
protected ExecuteResponse doExecute(ExecuteRequest request) {
    LwM2mPath path = request.getPath();
    LwM2mInstanceEnabler instance = instances.get(path.getObjectInstanceId());
    if (instance == null) {
        return ExecuteResponse.notFound();
    }
    return instance.execute(path.getResourceId(), request.getParameters());
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:10,代碼來源:ObjectEnabler.java

示例6: cannot_execute_read_only_resource

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void cannot_execute_read_only_resource() throws InterruptedException {
    // execute manufacturer resource on device
    ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(3, 0, 0));

    // verify result
    assertEquals(ResponseCode.METHOD_NOT_ALLOWED, response.getCode());
    assertNotNull(response.getCoapResponse());
    assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:11,代碼來源:ExecuteTest.java

示例7: cannot_execute_read_write_resource

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void cannot_execute_read_write_resource() throws InterruptedException {
    // execute current time resource on device
    ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(3, 0, 13));

    // verify result
    assertEquals(ResponseCode.METHOD_NOT_ALLOWED, response.getCode());
    assertNotNull(response.getCoapResponse());
    assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:11,代碼來源:ExecuteTest.java

示例8: cannot_execute_nonexisting_resource_on_existing_object

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void cannot_execute_nonexisting_resource_on_existing_object() throws InterruptedException {
    int nonExistingResourceId = 9999;
    // execute non existing resource on device
    ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(),
            new ExecuteRequest(3, 0, nonExistingResourceId));

    // verify result
    assertEquals(ResponseCode.NOT_FOUND, response.getCode());
    assertNotNull(response.getCoapResponse());
    assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:13,代碼來源:ExecuteTest.java

示例9: cannot_execute_nonexisting_resource_on_non_existing_object

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void cannot_execute_nonexisting_resource_on_non_existing_object() throws InterruptedException {
    int nonExistingObjectId = 9999;
    ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(),
            new ExecuteRequest(nonExistingObjectId, 0, 0));

    // verify result
    assertEquals(ResponseCode.NOT_FOUND, response.getCode());
    assertNotNull(response.getCoapResponse());
    assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:12,代碼來源:ExecuteTest.java

示例10: cannot_execute_security_object

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void cannot_execute_security_object() throws InterruptedException {
    ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(0, 0, 0));

    // verify result
    assertEquals(ResponseCode.NOT_FOUND, response.getCode());
    assertNotNull(response.getCoapResponse());
    assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:10,代碼來源:ExecuteTest.java

示例11: can_execute_resource

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void can_execute_resource() throws InterruptedException {
    // execute reboot resource on device
    ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(3, 0, 4));

    // verify result
    assertEquals(ResponseCode.CHANGED, response.getCode());
    assertNotNull(response.getCoapResponse());
    assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:11,代碼來源:ExecuteTest.java

示例12: can_execute_resource_with_parameters

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void can_execute_resource_with_parameters() throws InterruptedException {
    // execute reboot after 60 seconds on device
    ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(),
            new ExecuteRequest(3, 0, 4, "60"));

    // verify result
    assertEquals(ResponseCode.CHANGED, response.getCode());
    assertNotNull(response.getCoapResponse());
    assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:12,代碼來源:ExecuteTest.java

示例13: visit

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Override
public void visit(ExecuteRequest request) {
    coapRequest = Request.newPost();
    setTarget(coapRequest, request.getPath());
    coapRequest.setPayload(request.getParameters());
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:7,代碼來源:CoapRequestBuilder.java

示例14: doExecute

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
protected ExecuteResponse doExecute(ExecuteRequest request) {
    // This should be a not implemented error, but this is not defined in the spec.
    return ExecuteResponse.internalServerError("not implemented");
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:5,代碼來源:BaseObjectEnabler.java

示例15: ser_and_des_execute_request

import org.eclipse.leshan.core.request.ExecuteRequest; //導入依賴的package包/類
@Test
public void ser_and_des_execute_request() throws Exception {
    ser_and_des_are_equals(new ExecuteRequest(3, 0, 1, "params"));
}
 
開發者ID:eclipse,項目名稱:leshan,代碼行數:5,代碼來源:DownlinkRequestSerDesTest.java


注:本文中的org.eclipse.leshan.core.request.ExecuteRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。