本文整理汇总了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();
}
}
示例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();
}
}
示例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());
}
示例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);
}
示例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());
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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());
}
示例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");
}
示例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"));
}