Package com.vaadin

Examples of com.vaadin.Application$WindowDetachListener


        }
    }

    private Application createApplication(PortletRequest request)
            throws PortletException, MalformedURLException {
        Application newApplication = getNewApplication(request);
        final PortletApplicationContext2 context = PortletApplicationContext2
                .getApplicationContext(request.getPortletSession());
        context.addApplication(newApplication, request.getWindowID());
        return newApplication;
    }
View Full Code Here


            throw new SessionExpiredException();
        }

        PortletApplicationContext2 context = PortletApplicationContext2
                .getApplicationContext(session);
        Application application = context.getApplicationForWindowId(request
                .getWindowID());
        if (application == null) {
            return null;
        }
        if (application.isRunning()) {
            return application;
        }
        // application found but not running
        PortletApplicationContext2.getApplicationContext(session)
                .removeApplication(application);
View Full Code Here

            throws ClassNotFoundException;

    protected Application getNewApplication(PortletRequest request)
            throws PortletException {
        try {
            final Application application = getApplicationClass().newInstance();
            return application;
        } catch (final IllegalAccessException e) {
            throw new PortletException("getNewApplication failed", e);
        } catch (final InstantiationException e) {
            throw new PortletException("getNewApplication failed", e);
View Full Code Here

        if (requestType == RequestType.STATIC_FILE) {
            serveStaticResources(request, response);
            return;
        }

        Application application = null;
        boolean transactionStarted = false;
        boolean requestStarted = false;

        try {
            // If a duplicate "close application" URL is received for an
            // application that is not open, redirect to the application's main
            // page.
            // This is needed as e.g. Spring Security remembers the last
            // URL from the application, which is the logout URL, and repeats
            // it.
            // We can tell apart a real onunload request from a repeated one
            // based on the real one having content (at least the UIDL security
            // key).
            if (requestType == RequestType.UIDL
                    && request.getParameterMap().containsKey(
                            ApplicationConnection.PARAM_UNLOADBURST)
                    && request.getContentLength() < 1
                    && getExistingApplication(request, false) == null) {
                redirectToApplication(request, response);
                return;
            }

            // Find out which application this request is related to
            application = findApplicationInstance(request, requestType);
            if (application == null) {
                return;
            }

            /*
             * Get or create a WebApplicationContext and an ApplicationManager
             * for the session
             */
            WebApplicationContext webApplicationContext = WebApplicationContext
                    .getApplicationContext(request.getSession());
            CommunicationManager applicationManager = webApplicationContext
                    .getApplicationManager(application, this);

            /* Update browser information from the request */
            updateBrowserProperties(webApplicationContext.getBrowser(), request);

            /*
             * Call application requestStart before Application.init() is called
             * (bypasses the limitation in TransactionListener)
             */
            if (application instanceof HttpServletRequestListener) {
                ((HttpServletRequestListener) application).onRequestStart(
                        request, response);
                requestStarted = true;
            }

            // Start the newly created application
            startApplication(request, application, webApplicationContext);

            /*
             * Transaction starts. Call transaction listeners. Transaction end
             * is called in the finally block below.
             */
            webApplicationContext.startTransaction(application, request);
            transactionStarted = true;

            /* Handle the request */
            if (requestType == RequestType.FILE_UPLOAD) {
                applicationManager.handleFileUpload(request, response);
                return;
            } else if (requestType == RequestType.UIDL) {
                // Handles AJAX UIDL requests
                Window window = applicationManager.getApplicationWindow(
                        request, this, application, null);
                applicationManager.handleUidlRequest(request, response, this,
                        window);
                return;
            }

            // Removes application if it has stopped (mayby by thread or
            // transactionlistener)
            if (!application.isRunning()) {
                endApplication(request, response, application);
                return;
            }

            // Finds the window within the application
            Window window = getApplicationWindow(request, applicationManager,
                    application);
            if (window == null) {
                throw new ServletException(ERROR_NO_WINDOW_FOUND);
            }

            // Sets terminal type for the window, if not already set
            if (window.getTerminal() == null) {
                window.setTerminal(webApplicationContext.getBrowser());
            }

            // Handle parameters
            final Map parameters = request.getParameterMap();
            if (window != null && parameters != null) {
                window.handleParameters(parameters);
            }

            /*
             * Call the URI handlers and if this turns out to be a download
             * request, send the file to the client
             */
            if (handleURI(applicationManager, window, request, response)) {
                return;
            }

            // Send initial AJAX page that kickstarts a Vaadin application
            writeAjaxPage(request, response, window, application);

        } catch (final SessionExpiredException e) {
            // Session has expired, notify user
            handleServiceSessionExpired(request, response);
        } catch (final GeneralSecurityException e) {
            handleServiceSecurityException(request, response);
        } catch (final Throwable e) {
            handleServiceException(request, response, application, e);
        } finally {
            // Notifies transaction end
            try {
                if (transactionStarted) {
                    ((WebApplicationContext) application.getContext())
                            .endTransaction(application, request);

                }

            } finally {
View Full Code Here

        boolean requestCanCreateApplication = requestCanCreateApplication(
                request, requestType);

        /* Find an existing application for this request. */
        Application application = getExistingApplication(request,
                requestCanCreateApplication);

        if (application != null) {
            /*
             * There is an existing application. We can use this as long as the
View Full Code Here

     * @throws ServletException
     * @throws MalformedURLException
     */
    private Application createApplication(HttpServletRequest request)
            throws ServletException, MalformedURLException {
        Application newApplication = getNewApplication(request);

        final WebApplicationContext context = WebApplicationContext
                .getApplicationContext(request.getSession());
        context.addApplication(newApplication);

View Full Code Here

        final Collection<Application> applications = context.getApplications();

        // Search for the application (using the application URI) from the list
        for (final Iterator<Application> i = applications.iterator(); i
                .hasNext();) {
            final Application sessionApplication = i.next();
            final String sessionApplicationPath = sessionApplication.getURL()
                    .getPath();
            String requestApplicationPath = getApplicationUrl(request)
                    .getPath();

            if (requestApplicationPath.equals(sessionApplicationPath)) {
                // Found a running application
                if (sessionApplication.isRunning()) {
                    return sessionApplication;
                }
                // Application has stopped, so remove it before creating a new
                // application
                WebApplicationContext.getApplicationContext(session)
View Full Code Here

    protected Application getNewApplication(HttpServletRequest request)
            throws ServletException {

        // Creates a new application instance
        try {
            final Application application = (Application) getApplicationClass()
                    .newInstance();
            return application;
        } catch (final IllegalAccessException e) {
            throw new ServletException(e);
        } catch (final InstantiationException e) {
View Full Code Here

    @Override
    protected void removeApplication(Application application) {
        portletListeners.remove(application);
        for (Iterator<Application> it = portletToApplication.values()
                .iterator(); it.hasNext();) {
            Application value = it.next();
            if (value == application) {
                // values().iterator() is backed by the map
                it.remove();
            }
        }
View Full Code Here

        }
    }

    public void firePortletRenderRequest(Portlet portlet,
            RenderRequest request, RenderResponse response) {
        Application app = getPortletApplication(portlet);
        Set<PortletListener> listeners = portletListeners.get(app);
        if (listeners != null) {
            for (PortletListener l : listeners) {
                l.handleRenderRequest(request, new RestrictedRenderResponse(
                        response));
View Full Code Here

TOP

Related Classes of com.vaadin.Application$WindowDetachListener

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.