当前位置: 首页>>代码示例>>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;未经允许,请勿转载。