Examples of XFormsSessionManager


Examples of org.chiba.web.session.XFormsSessionManager

        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("requested session: " + key);
        }

        //todo: inherit from ChibaServlet for getXFormsSessionManager() method ? hm, weak reaon
        XFormsSessionManager sessionManager = DefaultXFormsSessionManagerImpl.getInstance();
        XFormsSession xFormsSession = sessionManager.getXFormsSession(key);

        if (session != null) {
            if(LOGGER.isDebugEnabled()){
                Enumeration keys = session.getAttributeNames();
                if(keys.hasMoreElements()){
                    LOGGER.debug("--- existing keys in session --- ");
                }
                while (keys.hasMoreElements()) {
                    String s = (String) keys.nextElement();
                    LOGGER.debug("existing sessionkey: " + s + ":" + session.getAttribute(s));
                }
            }

            // lookup attribute containing submission response map
            Map submissionResponse = (Map) xFormsSession.getProperty(ChibaServlet.CHIBA_SUBMISSION_RESPONSE);
            if (submissionResponse != null) {

                if(LOGGER.isDebugEnabled()){
                    LOGGER.debug("handling submission/@replace='all'");
                    Enumeration keys = session.getAttributeNames();
                    if(keys.hasMoreElements()){
                        LOGGER.debug("--- existing keys in session  --- ");
                        while (keys.hasMoreElements()) {
                            String s = (String) keys.nextElement();
                            LOGGER.debug("existing sessionkey: " + s + ":" + session.getAttribute(s));
                        }
                    }else{
                        LOGGER.debug("--- no keys left in session  --- ");
                    }
                }

                // copy header fields
                Map headerMap = (Map) submissionResponse.get("header");
                String name;
                String value;
                Iterator iterator = headerMap.keySet().iterator();
                while (iterator.hasNext()) {
                    name = (String) iterator.next();
                    if (name.equalsIgnoreCase("Transfer-Encoding")) {
                        // Some servers (e.g. WebSphere) may set a "Transfer-Encoding"
                        // with the value "chunked". This may confuse the client since
                        // ChibaServlet output is not encoded as "chunked", so this
                        // header is ignored.
                        continue;
                    }

                    value = (String) headerMap.get(name);
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("added header: " + name + "=" + value);
                    }

                    response.setHeader(name, value);
                }

                // copy body stream
                InputStream bodyStream = (InputStream) submissionResponse.get("body");
                OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
                for (int b = bodyStream.read(); b > -1; b = bodyStream.read()) {
                    outputStream.write(b);
                }

                // close streams
                bodyStream.close();
                outputStream.close();

                //kill XFormsSession
                sessionManager.deleteXFormsSession(xFormsSession.getKey());

                return;
            }
        }
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

        response.setContentType("text/html");

        String key = request.getParameter("sessionKey");
        try {

            XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
            XFormsSession xFormsSession = manager.getXFormsSession(key);

            webAdapter = xFormsSession.getAdapter();
            if (webAdapter == null) {
                throw new ServletException(Config.getInstance().getErrorMessage("session-invalid"));
            }
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("handling session: " + key);
            LOGGER.debug("referer: " + referer);
        }
        try {
            XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
            XFormsSession xFormsSession = manager.getXFormsSession(key);
            if (xFormsSession == null) {
                LOGGER.info("session does not exist: " + key + " - creating new one");
                response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/XFormsServlet?" + referer));

            } else {
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

            throws ServletException, IOException {

        WebAdapter adapter = null;
        HttpSession session = request.getSession(true);

        XFormsSessionManager sessionManager = getXFormsSessionManager();
        XFormsSession xFormsSession = sessionManager.createXFormsSession();

        /*
        the XFormsSessionManager is kept in the http-session though it is accessible as singleton. Subsequent
        servlets should access the manager through the http-session attribute as below to ensure the http-session
        is refreshed.
        */
        session.setAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER,sessionManager);

        if (LOGGER.isDebugEnabled()) {
            printSessionKeys(session);
            LOGGER.debug("created XFormsSession with key: " + xFormsSession.getKey());
        }

        request.setCharacterEncoding("UTF-8");
        response.setHeader("Cache-Control","private, no-store,  no-cache, must-revalidate");
        response.setHeader("Pragma","no-cache");
        response.setDateHeader("Expires",-1);

        try {
            // determine Form to load
            String formURI = getRequestURI(request) + request.getParameter(FORM_PARAM_NAME);
            if (formURI == null) {
                throw new IOException("Resource not found: " + formURI + " not found");
            }
           
            String xslFile = request.getParameter(XSL_PARAM_NAME);
            String javascriptPresent = request.getParameter(JAVASCRIPT_PARAM_NAME);

            String actionURL = null;
            if (javascriptPresent != null) {
                //do AJAX
                adapter = new FluxAdapter();
                actionURL = getActionURL(request, response, true);
            } else {
                //do standard browser support without scripting
                adapter = new ServletAdapter();
                actionURL = getActionURL(request, response, false);
            }
            adapter.setXFormsSession(xFormsSession);

            //setup Adapter
            adapter = setupAdapter(adapter, xFormsSession.getKey(), formURI);
            setContextParams(request, adapter);
            storeCookies(request, adapter);
            storeAcceptLanguage(request, adapter);
            adapter.init();
            XMLEvent exitEvent = adapter.checkForExitEvent();

            if (exitEvent != null) {
                handleExit(exitEvent, xFormsSession, session,  request, response);
            } else {
                //todo: review: the following may be substituted with the ViewServlet
                response.setContentType(HTML_CONTENT_TYPE);
                UIGenerator uiGenerator = createUIGenerator(request, xFormsSession, actionURL, xslFile == null ? xsltDefault : xslFile, javascriptPresent);
                uiGenerator.setInput(adapter.getXForms());
                uiGenerator.setOutput(response.getOutputStream());
                uiGenerator.generate();

                //store WebAdapter in XFormsSession
                xFormsSession.setAdapter(adapter);
                //store UIGenerator in XFormsSession as property
                xFormsSession.setProperty(XFormsSession.UIGENERATOR, uiGenerator);
                //store queryString as 'referer' in XFormsSession
                xFormsSession.setProperty(XFormsSession.REFERER,request.getQueryString());
                //actually add the XFormsSession ot the manager
                sessionManager.addXFormsSession(xFormsSession);
            }

            printSessionKeys(session);

        }
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

     * @param timeout a timeout in millis for the XFormsSession
     * @param className the fully qualified classname of the XFormsSessionManager to use
     * @throws org.chiba.xml.xforms.config.XFormsConfigException thrown if no usable XFormsSessionManager implementation around
     */
    protected void createXFormsSessionManager(int wipingInterval, int timeout, String className) throws XFormsConfigException {
        XFormsSessionManager manager=null;
        if(className==null) {
            if(LOGGER.isDebugEnabled()) {
                LOGGER.debug("Default XFormsSessionManager choosen" );
            }
            manager = getXFormsSessionManager();

        } else {
            try {
                if(LOGGER.isDebugEnabled()) {
                    LOGGER.debug("XFormsSessionManager: " + className  );
                }
                Class clazz = Class.forName(className);
                manager  = (XFormsSessionManager)clazz.getMethod("getInstance", (Class[])null).invoke(clazz,(Object[])null);
            }
            catch (ClassCastException cce) {
                throw new XFormsConfigException(cce);
            } catch (IllegalAccessException e) {
                throw new XFormsConfigException(e);
            } catch (ClassNotFoundException e) {
                throw new XFormsConfigException(e);
            } catch (NoSuchMethodException e) {
                LOGGER.fatal("Class '" + className +"' has no getInstance method") ;
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                LOGGER.fatal("Error invoking Class '" + className +"'") ;
                e.printStackTrace();
            }
        }

        /*
        Chiba Web comes with a default web.xml containing a default value of 120 Secs between expiry checks.
        If the value is not present in web.xml 0 is assumed meaning no expiry checking at all.
         */
        if(wipingInterval != 0){
            manager.setInterval(wipingInterval);
        }else{
            manager.setInterval(0);// no XFormsSession expiry takes place
        }

        if (timeout != 0){
            manager.setTimeout(timeout);
        }else{
            manager.setTimeout(1000 * 60); // 1 minute session lifetime (expressed in milliseconds)
        }

        //start running the session cleanup

        manager.init();

    }
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

        response.setHeader("Pragma","no-cache");
        response.setHeader("Expires","-1");

        String key = request.getParameter("sessionKey");
        try {
            XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
            XFormsSession xFormsSession = manager.getXFormsSession(key);

            String referer = (String) xFormsSession.getProperty(XFormsSession.REFERER);
            if(LOGGER.isDebugEnabled()){
                LOGGER.debug("referer: " + referer);
            }
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

        } else {
            //if session info is not found for some reason return 100 for safety which allows to exit
            //javascript polling of progress info
            progress = "100";
        }
        XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
        XFormsSession xFormsSession = manager.getXFormsSession(sessionKey);

        FluxAdapter adapter = (FluxAdapter) xFormsSession.getAdapter();
        EventLog eventLog = adapter.getEventLog();

        Element eventlogElement = eventLog.getLog();
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

     */
    public void keepAlive(String sessionKey) throws FluxException {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("FluxFacade keepAlive: " + sessionKey);
        }
        XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
        XFormsSession xFormsSession = manager.getXFormsSession(sessionKey);
        xFormsSession.getKey();
    }
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

     */
    public void close(String sessionKey) throws FluxException {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("FluxFacade close: " + sessionKey);
        }
        XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
        XFormsSession xFormsSession = manager.getXFormsSession(sessionKey);
        try {

            // don't use getXFormsSession to avoid needless error
            if (xFormsSession == null) return;
            WebAdapter adapter = xFormsSession.getAdapter();
            if (adapter == null) return;
            adapter.shutdown();
        } catch (XFormsException e) {
            LOGGER.warn("FluxFacade close: " + sessionKey, e);
        } finally {
            manager.deleteXFormsSession(sessionKey);
        }
    }
View Full Code Here

Examples of org.chiba.web.session.XFormsSessionManager

            manager.deleteXFormsSession(sessionKey);
        }
    }

    private org.w3c.dom.Element dispatch(ChibaEvent event, String sessionKey) throws FluxException {
        XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
        XFormsSession xFormsSession = manager.getXFormsSession(sessionKey);

        if(xFormsSession == null){
            LOGGER.fatal("XFormsSession not found - stopping");
            throw new FluxException("Your session has expired - Please start again.");
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.