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


Java Action类代码示例

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


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

示例1: init

import ratpack.func.Action; //导入依赖的package包/类
@Override
    public void init() {
        try {
            RatpackServer.start(server -> {
                server.serverConfig(c -> {
                    for(Action<ServerConfigBuilder> cfg : getConfigurators()) {
                        c = cfg.with(c);
                    }
                });
                server.registry(Guice.registry(b -> {
                    for(Action<BindingsSpec> binding : getBindings()) {
                        b = binding.with(b);
                    }
                }));
                server.handlers(chain -> {
                    for(Action<Chain> handler : getHandlers()) {
//                        chain = chain.insert(handler);
                        chain = handler.with(chain);
                    }
                });
            });
        } catch (Exception e) {
            logger.error("Ratpack failure", e);
        }
    }
 
开发者ID:beryx,项目名称:text-io,代码行数:26,代码来源:RatpackDataServer.java

示例2: accept

import ratpack.func.Action; //导入依赖的package包/类
@Override
public void accept(Throwable e) throws Exception {
  if (e instanceof OnErrorNotImplementedException) {
    Promise.error(e.getCause()).then(Action.noop());
  } else if (e instanceof UndeliverableException) {
    Promise.error(e.getCause()).then(Action.noop());
  } else {
    Promise.error(e).then(Action.noop());
  }
}
 
开发者ID:drmaas,项目名称:ratpack-rx2,代码行数:11,代码来源:ErrorHandler.java

示例3: proxyRequest

import ratpack.func.Action; //导入依赖的package包/类
private Action<RequestSpec> proxyRequest(final TypedData body, final Request request) {
    return spec -> {
        spec.getBody().buffer(body.getBuffer());
        spec.getHeaders().copy(request.getHeaders());
        spec.method(request.getMethod());
    };
}
 
开发者ID:vrapio,项目名称:vrap,代码行数:8,代码来源:RamlRouter.java

示例4: config

import ratpack.func.Action; //导入依赖的package包/类
private static Action<ServerConfigBuilder> config(String[] args) {
    final Path baseDir = Paths.get("").toAbsolutePath();
    log.info("Using baseDir: " + baseDir);

    Action<ServerConfigBuilder> cfg = Action.from(c -> c
            .baseDir(baseDir)
            .json(Resources.getResource("config-core.json"))
    );

    if (args.length == 1) {
        final String filename = args[0];
        final Path configPath = Paths.get(baseDir.toString(), filename);
        if (!Files.exists(configPath)) {
            throw new UnsupportedOperationException("Could not find config file: " + configPath);
        }
        cfg = cfg.append(c -> c.json(configPath));
    }

    cfg = cfg.append(c -> c
            .env("LAZYBOT_")
            .sysProps("lazybot.")
            .require("/hipchat", HipChatConfig.class)
            .require("/db", DatabaseConfig.class)
            .require("/plugins", PluginConfig.class)
    );

    return cfg;
}
 
开发者ID:RoyJacobs,项目名称:lazybot,代码行数:29,代码来源:App.java

示例5: request

import ratpack.func.Action; //导入依赖的package包/类
@Override
public Promise<ReceivedResponse> request(URI uri, Action<? super RequestSpec> action) {
    final AtomicReference<Span> span = new AtomicReference<>();

    return delegate
        .request(uri, (RequestSpec requestSpec) -> action.execute(new WrappedRequestSpec(handler, injector, requestSpec, span)))
        .wiretap(response -> responseWithSpan(response, span));
}
 
开发者ID:hyleung,项目名称:ratpack-zipkin,代码行数:9,代码来源:ZipkinHttpClientImpl.java

示例6: requestStream

import ratpack.func.Action; //导入依赖的package包/类
@Override
public Promise<StreamedResponse> requestStream(URI uri, Action<? super RequestSpec> action) {
    final AtomicReference<Span> span = new AtomicReference<>();

    return delegate
        .requestStream(uri, (RequestSpec requestSpec) -> {
            WrappedRequestSpec captor = new WrappedRequestSpec(handler, injector, requestSpec, span);
            // streamed request doesn't set the http method.
            // start span here until a better solution presents itself.
            span.set(handler.handleSend(injector, captor.getHeaders(), captor));
            action.execute(captor);
        })
        .wiretap(response -> streamedResponseWithSpan(response, span));
}
 
开发者ID:hyleung,项目名称:ratpack-zipkin,代码行数:15,代码来源:ZipkinHttpClientImpl.java

示例7: onRedirect

import ratpack.func.Action; //导入依赖的package包/类
@Override
public RequestSpec onRedirect(Function<? super ReceivedResponse, Action<? super RequestSpec>> function) {

    Function<? super ReceivedResponse, Action<? super RequestSpec>> wrapped =
        (ReceivedResponse response) -> redirectHandler(response).append(function.apply(response));

    this.delegate.onRedirect(wrapped);
    return this;
}
 
开发者ID:hyleung,项目名称:ratpack-zipkin,代码行数:10,代码来源:ZipkinHttpClientImpl.java

示例8: config

import ratpack.func.Action; //导入依赖的package包/类
private Action<ServerConfigBuilder> config() {
    final Path baseDir = BaseDir.find(PUBLIC);

    return Action.from(c -> c
            .port(port)
            .address(address)
            .baseDir(baseDir)
    );
}
 
开发者ID:nwillc,项目名称:mysnipserver,代码行数:10,代码来源:RatPackApp.java

示例9: BaseServer

import ratpack.func.Action; //导入依赖的package包/类
public BaseServer(Action<Chain> handlers, ServerConfig config, Action<BindingsSpec> binding) throws ServerException {
    try {
        this.ratpackServer = RatpackServer.of(def ->
                def.serverConfig(config)
                        .registry(Guice.registry(binding))
                        .handlers(handlers));
    } catch (Exception e) {
        throw new ServerException("Error in building ratpack server.", e);
    }
}
 
开发者ID:masgari,项目名称:microservices-sample,代码行数:11,代码来源:BaseServer.java

示例10: newErrorAction

import ratpack.func.Action; //导入依赖的package包/类
public static Action<Throwable> newErrorAction(Context context) {
    return throwable -> {
        if (throwable instanceof InvalidValueException) {
            StatusHelper.sendBadRequest(context, throwable.getMessage());
        } else if (throwable instanceof ResourceNotFoundException) {
            StatusHelper.sendNotFound(context, ((ResourceNotFoundException) throwable).getId());
        } else {
            StatusHelper.sendInternalError(context, throwable);
        }
    };
}
 
开发者ID:masgari,项目名称:microservices-sample,代码行数:12,代码来源:HandlerHelper.java

示例11: handleAddNewUserAsync

import ratpack.func.Action; //导入依赖的package包/类
void handleAddNewUserAsync(Context context) {
    Action<Fulfiller<String>> action = fulfiller -> {
        User user = helper.fromBody(context, User.class);
        store.saveAsync(user, helper.newJsonConsumer(fulfiller), fulfiller::error);
    };
    HandlerHelper.handleRequestWithPromise(context, action);
}
 
开发者ID:masgari,项目名称:microservices-sample,代码行数:8,代码来源:UsersCollectionHandler.java

示例12: handleConnectionCreationAsync

import ratpack.func.Action; //导入依赖的package包/类
void handleConnectionCreationAsync(Context context) {
    Action<Fulfiller<String>> action = fulfiller -> {
        String userId = context.getPathTokens().get(USER_PATH_TOKEN);
        MultiValueMap<String, String> queryParams = context.getRequest().getQueryParams();
        if (!queryParams.containsKey(CONNECT_TO_QUERY_PARAM)) {
            throw new InvalidValueException("Query parameter 'to' is required.");
        }
        String connectTo = queryParams.get(CONNECT_TO_QUERY_PARAM);
        store.connectAsync(userId, connectTo, helper.newJsonConsumer(fulfiller), fulfiller::error);
    };
    HandlerHelper.handleRequestWithPromise(context, action);
}
 
开发者ID:masgari,项目名称:microservices-sample,代码行数:13,代码来源:UsersCollectionHandler.java

示例13: handleGetUserConnectionsListAsync

import ratpack.func.Action; //导入依赖的package包/类
void handleGetUserConnectionsListAsync(Context context) {
    Action<Fulfiller<String>> action = fulfiller -> {
        String userId = context.getPathTokens().get(USER_PATH_TOKEN);
        //other parameters like sort and count can be read from query parameters
        store.listConnections(userId, 100, helper.newJsonConsumer(fulfiller), fulfiller::error);
    };
    HandlerHelper.handleRequestWithPromise(context, action);
}
 
开发者ID:masgari,项目名称:microservices-sample,代码行数:9,代码来源:UsersCollectionHandler.java

示例14: handleSaveAsync

import ratpack.func.Action; //导入依赖的package包/类
private void handleSaveAsync(Context context) {
    Action<Fulfiller<String>> action = fulfiller -> {
        //at the moment, we only handle user entity type
        User entity = helper.fromBody(context, User.class);
        store.saveAsync(entity, helper.newJsonConsumer(fulfiller), fulfiller::error);
    };
    HandlerHelper.handleRequestWithPromise(context, action);
}
 
开发者ID:masgari,项目名称:microservices-sample,代码行数:9,代码来源:EntitiesCollectionHandler.java

示例15: handleFindByIdAsync

import ratpack.func.Action; //导入依赖的package包/类
private void handleFindByIdAsync(Context context) {
    Action<Fulfiller<String>> action = fulfiller -> {
        String id = context.getPathTokens().get("id");
        store.findById(id, helper.newJsonConsumer(fulfiller), fulfiller::error);
    };
    HandlerHelper.handleRequestWithPromise(context, action);
}
 
开发者ID:masgari,项目名称:microservices-sample,代码行数:8,代码来源:EntitiesCollectionHandler.java


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