Package com.bj58.spat.gaea.server.core.communication.telnet

Examples of com.bj58.spat.gaea.server.core.communication.telnet.TelnetServer


        return beat;
    }

    private void route(BeatContext beat) {
        try {
            ActionResult result = router.route(beat);

            if (ActionResult.NULL == result)
                result = statusCodeActionResult.getSc404();

            result.render(beat);

        } catch (Exception e) {

            statusCodeActionResult.render405(beat);
View Full Code Here


public class ActionResults {

    private ActionResults() {}

    public static ActionResult redirect(final String url) {
        return new ActionResult() {
            @Override
            public void render(BeatContext beatContext) {
                try {
                    beatContext.getResponse().sendRedirect(url);
                } catch (IOException e) {
View Full Code Here

            }
        };
    }

    public static ActionResult redirect301(final String url) {
        return new ActionResult() {
            @Override
            public void render(BeatContext beatContext) {
                try {
                    //fixMe: 需要判断是否是同一个schema等因素
                    HttpServletResponse response = beatContext.getResponse();
View Full Code Here

        if (!match)
            return RouteResult.unMatch();

        // PreIntercept
        for(PreInterceptor preInterceptor : actionInfo.getPreInterceptors()) {
            ActionResult actionResult = preInterceptor.preExecute(bag.getBeat());
            if (ActionResult.NULL != actionResult)
                return RouteResult.invoked(actionResult);
        }

        ActionResult actionResult = actionInfo.invoke(uriTemplateVariables);

        // PostIntercept
        for(PostInterceptor postInterceptor : actionInfo.getPostInterceptors()) {
            actionResult = postInterceptor.postExecute(bag.getBeat(), actionResult);
        }
View Full Code Here

        Iterable<ArgoController> sets = Iterables.transform(controllerClasses, new Function<Class<? extends ArgoController>, ArgoController>() {
            @Override
            public ArgoController apply(Class<? extends ArgoController> clazz) {

                // instance a controller
                ArgoController controller = argo.getInstance(clazz);
                // initialize the controller.
                controller.init();

                return controller;
            }
        });
View Full Code Here

        Assert.assertEquals("/....pathFolder../abc.txt", PathUtils.simply("/....pathFolder../abc.txt?abc"));
        Assert.assertEquals("/....pathFolder../abc.txt", PathUtils.simply("/....pathFolder../abc.txt#abc"));
        Assert.assertEquals("/....pathFolder../abc.txt", PathUtils.simply("/....pathFolder../abc.txt#abc<>"));
        Assert.assertEquals("/春节/", PathUtils.simply("/春节/"));
       
        ArgoException e = throwCombine("..");
        Assert.assertEquals("Illegal URL path!\ncontext: {url=..}", e.getMessage());
        Assert.assertNotNull(e);
        Assert.assertNotNull(throwCombine("."));
        Assert.assertNotNull(throwCombine( ".\\"));
        Assert.assertNotNull(throwCombine("<"));
        Assert.assertNotNull(throwCombine(">"));
View Full Code Here

    public void service(HttpServletRequest request, HttpServletResponse response) {

        ArgoRequest argoRequest = new ArgoRequest(request, config);

        try {
            BeatContext beatContext = bindBeatContext(argoRequest, response);

            route(beatContext);
        } finally {
            Closeables.closeQuietly(argoRequest);
        }
View Full Code Here

    private BeatContext bindBeatContext(HttpServletRequest request, HttpServletResponse response) {
        Context context = new Context(request, response);
        localContext.set(context);

        BeatContext beat = argo.injector().getInstance(defaultBeatContextKey);
        // 增加默认参数到model
        beat.getModel().add("__beat", beat);
        context.setBeat(beat);
        return beat;
    }
View Full Code Here

     * @param phoneNumber
     * @return
     */
    @Path("{phoneNumber:\\d+}")
    public ActionResult helloView(int phoneNumber) {
        BeatContext beatContext = beat();

        beatContext
                .getModel()
                .add("title", "phone")
                .add("phoneNumber", phoneNumber);

        return view("hello");
View Full Code Here

    @Path("post.html")
    @POST  // 只处理post的请求
    public ActionResult postForm() {

        BeatContext beat = beat();

        ClientContext client = beat.getClient();

        Preconditions.checkState(Strings.isNullOrEmpty(client.form("company")));
        Preconditions.checkState(Strings.isNullOrEmpty(client.form("address")));

        client.queryString("name");

        Preconditions.checkState(Strings.isNullOrEmpty(client.queryString("name")));
        Preconditions.checkState(Strings.isNullOrEmpty(client.queryString("phone")));
        Preconditions.checkState(Strings.isNullOrEmpty(client.queryString("submit")));


        beat.getModel()
                .add("company", client.queryString("company"))
                .add("address", client.queryString("address"))

                .add("name", client.form("name"))
                .add("phone", client.form("phone"))
View Full Code Here

TOP

Related Classes of com.bj58.spat.gaea.server.core.communication.telnet.TelnetServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.