Package com.sun.grizzly.tcp.http11

Examples of com.sun.grizzly.tcp.http11.GrizzlyAdapter


        if (!scheme.equalsIgnoreCase("http"))
            throw new IllegalArgumentException("The URI scheme, of the URI " + u +
                    ", must be equal (ignoring case) to 'http'");           

        if (adapter instanceof GrizzlyAdapter) {
            GrizzlyAdapter ga = (GrizzlyAdapter)adapter;
            ga.setResourcesContextPath(u.getRawPath());
        }
       
        final SelectorThread selectorThread = new SelectorThread();

        selectorThread.setAlgorithmClassName(StaticStreamAlgorithm.class.getName());
View Full Code Here


        if (!scheme.equalsIgnoreCase("http"))
            throw new IllegalArgumentException("The URI scheme, of the URI " + u +
                    ", must be equal (ignoring case) to 'http'");

        if (adapter instanceof GrizzlyAdapter) {
            GrizzlyAdapter ga = (GrizzlyAdapter)adapter;
            ga.setResourcesContextPath(u.getRawPath());
        }

        final SelectorThread selectorThread = new SelectorThread();

        selectorThread.setAlgorithmClassName(StaticStreamAlgorithm.class.getName());
View Full Code Here

        if (!scheme.equalsIgnoreCase("http"))
            throw new IllegalArgumentException("The URI scheme, of the URI " + u +
                    ", must be equal (ignoring case) to 'http'");           

        if (adapter instanceof GrizzlyAdapter) {
            GrizzlyAdapter ga = (GrizzlyAdapter)adapter;
            ga.setResourcesContextPath(u.getRawPath());
        }
       
        final SelectorThread selectorThread = new SelectorThread();

        selectorThread.setAlgorithmClassName(StaticStreamAlgorithm.class.getName());
View Full Code Here

            if (!scheme.equalsIgnoreCase("http"))
                throw new IllegalArgumentException("The URI scheme, of the URI " + u +
                        ", must be equal (ignoring case) to 'http'");

            if (adapter instanceof GrizzlyAdapter) {
                GrizzlyAdapter ga = (GrizzlyAdapter)adapter;
                ga.setResourcesContextPath(u.getRawPath());
            }

            final SelectorThread selectorThread = new SelectorThread();

            selectorThread.setAlgorithmClassName(StaticStreamAlgorithm.class.getName());
View Full Code Here

                // Use the non-localized String version of the status
                serverVersion = AdapterState.WELCOME_TO.toString()+" "+serverVersion+".";
            }
            status +="\n"+serverVersion;
            try {
                GrizzlyOutputBuffer ob = getOutputBuffer(res);

                byte[] bytes = (":::" + status).getBytes("UTF-8");
                res.setContentLength(bytes.length);
                ob.write(bytes, 0, bytes.length);
                ob.flush();

            } catch (IOException ex) {
                Logger.getLogger(AdminConsoleAdapter.class.getName()).log(Level.SEVERE, null, ex);
            }
View Full Code Here

    }
     *
     */

    private GrizzlyOutputBuffer getOutputBuffer(GrizzlyResponse res) {
        GrizzlyOutputBuffer ob = res.getOutputBuffer();
        res.setStatus(202);
        res.setContentType("text/html");
        ob.setEncoding("UTF-8");
        return ob;
    }
View Full Code Here

     */
    private synchronized void sendConsentPage(GrizzlyRequest req, GrizzlyResponse res) { //should have only one caller
        setStateMsg(AdapterState.PERMISSION_NEEDED);
        byte[] bytes;
        try {
            GrizzlyOutputBuffer ob = getOutputBuffer(res);
            try {
                // Replace locale specific Strings
                String localHtml = replaceTokens(initHtml, bundle);

                // Replace path token
                String hp = (contextRoot.endsWith("/")) ? contextRoot : contextRoot + "/";
                bytes = localHtml.replace(MYURL_TOKEN, hp).getBytes("UTF-8");
            } catch (Exception ex) {
                bytes = ("Catastrophe:" + ex.getMessage()).getBytes("UTF-8");
            }
            res.setContentLength(bytes.length);
            ob.write(bytes, 0, bytes.length);
            ob.flush();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

     *
     */
    private void sendStatusPage(GrizzlyRequest req, GrizzlyResponse res) {
        byte[] bytes;
        try {
            GrizzlyOutputBuffer ob = getOutputBuffer(res);
            // Replace locale specific Strings
            String localHtml = replaceTokens(statusHtml, bundle);

            // Replace state token
            String status = getStateMsg().getI18NKey();
            try {
                // Try to get a localized version of this key
                status = bundle.getString(status);
            } catch (MissingResourceException ex) {
                // Use the non-localized String version of the status
                status = getStateMsg().toString();
            }
            String locationUrl = req.getScheme()
                                 + "://" + req.getServerName()
                                 + ':' + req.getServerPort() + "/login.jsf";
            localHtml = localHtml.replace(REDIRECT_TOKEN, locationUrl);
            bytes = localHtml.replace(STATUS_TOKEN, status).getBytes("UTF-8");
            res.setContentLength(bytes.length);
            ob.write(bytes, 0, bytes.length);
            ob.flush();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

     */
    private void sendStatusNotDAS(GrizzlyRequest req, GrizzlyResponse res) {
        byte[] bytes;
        try {
            String html = Utils.packageResource2String("statusNotDAS.html");
            GrizzlyOutputBuffer ob = getOutputBuffer(res);
            // Replace locale specific Strings
            String localHtml = replaceTokens(html, bundle);

            bytes = localHtml.getBytes("UTF-8");
            res.setContentLength(bytes.length);
            ob.write(bytes, 0, bytes.length);
            ob.flush();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

                // Use the non-localized String version of the status
                serverVersion = AdapterState.WELCOME_TO.toString()+" "+serverVersion+".";
            }
            status +="\n"+serverVersion;
            try {
                GrizzlyOutputBuffer ob = getOutputBuffer(res);

                byte[] bytes = (":::" + status).getBytes("UTF-8");
                res.setContentLength(bytes.length);
                ob.write(bytes, 0, bytes.length);
                ob.flush();

            } catch (IOException ex) {
                Logger.getLogger(AdminConsoleAdapter.class.getName()).log(Level.SEVERE, null, ex);
            }
View Full Code Here

TOP

Related Classes of com.sun.grizzly.tcp.http11.GrizzlyAdapter

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.