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


Java Operation类代码示例

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


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

示例1: testGatewayServiceStop

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
/**
 * This test verifies that the gateway service will reject a
 * DELETE request on the gateway service self-link.
 */
@Test
public void testGatewayServiceStop() throws Throwable {
    makeRequest(Action.DELETE,
            getDispatchUri(GatewayService.SELF_LINK), null,
            ServiceErrorResponse.class, Operation.STATUS_CODE_BAD_METHOD);

    // Host stops should still work.
    TestContext ctx = this.host.testCreate(1);
    Operation
            .createDelete(getDispatchUri(GatewayService.SELF_LINK))
            .setReferer(this.host.getUri())
            .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_NO_INDEX_UPDATE)
            .setCompletion(ctx.getCompletion())
            .sendWith(this.host);
    ctx.await();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:21,代码来源:TestGatewayService.java

示例2: makeRequest

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T, S> T makeRequest(Action action, URI serviceUri,
                             S body, Class<T> clazz,
                             int statusCode) {
    T[] response = (T[]) Array.newInstance(clazz, 1);
    TestContext ctx = this.host.testCreate(1);
    Operation op = Operation.createPost(serviceUri)
            .setBody(body)
            .setReferer(this.host.getUri())
            .setCompletion((o, e) -> {
                if (o.getStatusCode() != statusCode) {
                    Exception ex = new IllegalStateException(
                            "Expected statusCode: " + statusCode +
                                    ", returned statusCode: " + o.getStatusCode());
                    ctx.failIteration(ex);
                    return;
                }
                response[0] = o.getBody(clazz);
                ctx.completeIteration();
            });
    op.setAction(action);
    this.host.sendRequest(op);
    ctx.await();

    return response[0];
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:27,代码来源:TestGatewayService.java

示例3: addPaths

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
public Set<String> addPaths(String pathTemplate, int count, EnumSet<Action> actions) {
    ServiceHost configHost = this.gatewayHost.getConfigHost();

    Set<String> returnVal = new HashSet<>(count);
    List<Operation> ops = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        GatewayPathService.State state = new GatewayPathService.State();
        state.path = String.format(pathTemplate, i);
        state.actions = actions;
        ops.add(Operation
                .createPost(configHost, GatewayPathFactoryService.SELF_LINK)
                .setBody(state));
    }
    List<GatewayPathService.State> responses = this.sender
            .sendAndWait(ops, GatewayPathService.State.class);

    responses.forEach(r -> {
        returnVal.add(r.documentSelfLink);
        this.paths.put(r.documentSelfLink, r);
    });

    return returnVal;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:24,代码来源:TestGatewayManager.java

示例4: updatePaths

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
public void updatePaths(Set<String> pathLinks, EnumSet<Action> actions) {
    ServiceHost configHost = this.gatewayHost.getConfigHost();

    List<Operation> ops = new ArrayList<>(pathLinks.size());
    for (String pathLink : pathLinks) {
        GatewayPathService.State state = this.paths.get(pathLink);
        if (state == null) {
            throw new IllegalArgumentException("Unknown path");
        }
        state.actions = actions;
        ops.add(Operation
                .createPut(configHost, pathLink)
                .setBody(state));
    }
    List<GatewayPathService.State> responses = this.sender
            .sendAndWait(ops, GatewayPathService.State.class);
    responses.forEach(r -> this.paths.put(r.documentSelfLink, r));
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:19,代码来源:TestGatewayManager.java

示例5: handleGet

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
@Override
public void handleGet(Operation get) {
    /* TODO: enable tracing outbound requests here.
     * doing so requires that ServiceHost.queueOrScheduleRequestInternal - which does OperationContext switching,
     * capture and activate the SpanContext.
     */
    get.addRequestHeader(
            Operation.CONTENT_TYPE_HEADER,
            Operation.MEDIA_TYPE_APPLICATION_JSON);
    Operation getState = Operation.createGet(getHost(), "/stateful/foo")
            .setCompletion((operation, error) -> {
                get.setBody(operation.getBody(TestStatefulService.State.class));
                get.complete();
            });
    this.sendRequest(getState);
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:17,代码来源:TestStatelessService.java

示例6: path2UtilSubscriptions

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
private Path path2UtilSubscriptions(Parameter idParam) {
    Path path = new Path();
    if (idParam != null) {
        path.setParameters(Collections.singletonList(paramId()));
    }

    ServiceDocument subscriptionState = template(ServiceSubscriptionState.class);
    path.setGet(opDefault(subscriptionState));

    io.swagger.models.Operation deleteOrPost = new io.swagger.models.Operation();
    deleteOrPost.addParameter(paramBody(template(ServiceSubscriber.class)));
    deleteOrPost.addTag(this.currentTag.getName());
    deleteOrPost.setResponses(responseMap(
            Operation.STATUS_CODE_OK, responseOk(subscriptionState)));
    path.setDelete(deleteOrPost);
    path.setPost(deleteOrPost);
    return path;

}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:20,代码来源:SwaggerAssembler.java

示例7: path2UtilConfig

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
private Path path2UtilConfig(Parameter idParam) {
    Path path = new Path();
    if (idParam != null) {
        path.setParameters(Collections.singletonList(paramId()));
    }
    io.swagger.models.Operation op = new io.swagger.models.Operation();
    op.addTag(this.currentTag.getName());

    op.setResponses(responseMap(
            Operation.STATUS_CODE_OK, responseOk(template(ServiceConfiguration.class)),
            Operation.STATUS_CODE_NOT_FOUND, responseGenericError()));
    path.setGet(op);

    op = new io.swagger.models.Operation();
    op.addTag(this.currentTag.getName());
    op.setParameters(
            Collections.singletonList(paramBody(ServiceConfigUpdateRequest.class)));
    op.setResponses(responseMap(
            Operation.STATUS_CODE_OK, responseOk(template(ServiceConfiguration.class)),
            Operation.STATUS_CODE_NOT_FOUND, responseGenericError()));
    path.setPatch(op);

    return path;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:25,代码来源:SwaggerAssembler.java

示例8: path2Instance

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
private Map<String, Path> path2Instance(ServiceDocument doc) {
    if (doc.documentDescription != null
            && doc.documentDescription.serviceRequestRoutes != null
            && !doc.documentDescription.serviceRequestRoutes.isEmpty()) {
        return pathByRoutes(doc.documentDescription.serviceRequestRoutes.values(),
                this::defaultInstancePath);
    } else {
        io.swagger.models.Operation op = new io.swagger.models.Operation();
        op.addTag(this.currentTag.getName());
        op.setParameters(Collections.singletonList(paramBody(ServiceDocument.class)));
        op.setResponses(responseMap(
                Operation.STATUS_CODE_OK, responseOk(doc),
                Operation.STATUS_CODE_NOT_FOUND, responseGenericError()));

        // service definition should be introspected to better
        // describe which actions are supported
        Path path = this.defaultInstancePath();
        path.setGet(opDefault(doc));
        path.setPost(op);
        path.setPut(op);
        path.setPatch(op);
        path.setDelete(op);
        return Collections.singletonMap("", path);
    }
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:26,代码来源:SwaggerAssembler.java

示例9: getSwaggerOperation

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
private io.swagger.models.Operation getSwaggerOperation(io.swagger.models.Operation sourceOp,
        io.swagger.models.Operation destOp) {
    if (destOp != null) {
        destOp.getParameters().addAll(sourceOp.getParameters());
        // Append the description as well
        if (isNotBlank(destOp.getDescription()) && isNotBlank(sourceOp.getDescription())) {
            destOp.setDescription(String.format("%s / %s", destOp.getDescription(), sourceOp
                    .getDescription()));
        } else {
            // retain the non-blank description if there is one
            if (isNotBlank(sourceOp.getDescription())) {
                destOp.setDescription(sourceOp.getDescription());
            }
        }
    } else {
        destOp = sourceOp;
    }
    return destOp;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:20,代码来源:SwaggerAssembler.java

示例10: opFactoryGetInstances

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
private io.swagger.models.Operation opFactoryGetInstances() {
    io.swagger.models.Operation op = new io.swagger.models.Operation();
    op.addTag(this.currentTag.getName());
    op.setResponses(responseMap(
            Operation.STATUS_CODE_OK, responseOk(template(ServiceDocumentQueryResult.class))));
    op.setDescription("Query service instances");

    for (String[] data : FACTORY_QUERY_PARAMS) {
        QueryParameter p = new QueryParameter();
        p.setName(data[0]);
        p.setDescription(data[1]);
        p.setType(data[2]);
        p.setExample(data[3]);
        p.setDefaultValue(data[4]);
        p.setRequired(false);
        op.addParameter(p);
    }
    return op;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:20,代码来源:SwaggerAssembler.java

示例11: handleGet

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
@Override
public void handleGet(Operation get) {
    Operation op = Operation.createGet(this, "/");
    op.setCompletion((o, e) -> {
        SwaggerAssembler
                .create(this)
                .setExcludedPrefixes(this.excludedPrefixes)
                .setStripPackagePrefixes(this.stripPackagePrefixes)
                .setSupportLevel(this.supportLevel)
                .setInfo(this.info)
                .setPostprocessor(this.swaggerPostprocessor)
                .setExcludeUtilities(this.excludeUtilities)
                .setQueryResult(o.getBody(ServiceDocumentQueryResult.class))
                .build(get);
    });

    getHost().queryServiceUris(
            // all services
            EnumSet.noneOf(ServiceOption.class),
            true,
            op,
            // exclude factory items
            EnumSet.of(ServiceOption.FACTORY_ITEM));
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:25,代码来源:SwaggerDescriptorService.java

示例12: handlePut

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
@Override
public void handlePut(Operation put) {
    UserToken body = put.getBody(UserToken.class);
    Map<String, String> queryParams = UriUtils.parseUriQueryParams(put.getUri());
    String appendValue = queryParams.get("append");

    UserToken currentState = new UserToken();
    currentState.token = body.token;
    currentState.user = body.user;
    if (Boolean.valueOf(appendValue)) {
        currentState.internalId = body.user + body.internalId;
    }
    log(Level.INFO, "user:%s token:%s internal:%s", currentState.user, currentState.token,
            currentState.internalId);
    put.setBody(currentState).complete();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:17,代码来源:TokenService.java

示例13: handleGet

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
@RouteDocumentation(description = "@CAR_ENGINE",
        path = "?engine",
        produces = { "application/json" },
        responses = {
            @ApiResponse(statusCode = Operation.STATUS_CODE_OK, description = "OK", response = EngineInfo.class)
        })
@RouteDocumentation(description = "@CAR",
        produces = { "application/json" },
        responses = {
            @ApiResponse(statusCode = Operation.STATUS_CODE_OK, description = "OK", response = Car.class),
            @ApiResponse(statusCode = Operation.STATUS_CODE_NOT_FOUND, description = "Not Found"),
        })
@Override
public void handleGet(Operation get) {
    Map<String,String> queryParams = UriUtils.parseUriQueryParams(get.getUri());
    boolean engineInfo = Boolean.parseBoolean(queryParams.get("engine"));
    if (engineInfo) {
        Car car = this.getState(get);
        get.setBody(car.engineInfo);
        get.complete();
    } else {
        super.handleGet(get);
    }
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:25,代码来源:CarService.java

示例14: getDescriptionInJson

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
@Test
public void getDescriptionInJson() throws Throwable {
    TestRequestSender sender = host.getTestRequestSender();

    Operation op = Operation
            .createGet(UriUtils.buildUri(host, SwaggerDescriptorService.SELF_LINK))
            .setReferer(host.getUri());

    Operation result = null;
    Throwable error = null;
    try {
        result = sender.sendAndWait(op);
    } catch (Throwable e) {
        error = e;
    }

    assertDescriptorJson(result, error);
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:19,代码来源:TestSwaggerDescriptorService.java

示例15: getDescriptionInCompressedJson

import com.vmware.xenon.common.Operation; //导入依赖的package包/类
@Test
public void getDescriptionInCompressedJson() throws Throwable {
    TestRequestSender sender = host.getTestRequestSender();

    Operation op = Operation
            .createGet(UriUtils.buildUri(host, SwaggerDescriptorService.SELF_LINK))
            .setReferer(host.getUri())
            .addRequestHeader(Operation.ACCEPT_ENCODING_HEADER, Operation.CONTENT_ENCODING_GZIP);
    Operation result = null;
    Throwable error = null;
    try {
        result = sender.sendAndWait(op);
    } catch (Throwable e) {
        error = e;
    }

    assertDescriptorJson(result, error);
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:19,代码来源:TestSwaggerDescriptorService.java


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