Changeset 8321
- Timestamp:
- 07/04/09 07:29:33 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
versions/6.0/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
r8320 r8321 548 548 private Application findApplicationInstance(HttpServletRequest request, 549 549 RequestType requestType) throws MalformedURLException, 550 SAXException, IllegalAccessException, InstantiationException,551 550 ServletException, SessionExpired { 552 551 553 final boolean restartApplication = (request 554 .getParameter(URL_PARAMETER_RESTART_APPLICATION) != null); 555 final boolean closeApplication = (request 556 .getParameter(URL_PARAMETER_CLOSE_APPLICATION) != null); 557 558 Application application = getExistingApplication(request); 552 boolean requestCanCreateApplication = requestCanCreateApplication( 553 request, requestType); 554 555 /* Find an existing application for this request. */ 556 Application application = getExistingApplication(request, 557 requestCanCreateApplication); 558 559 559 if (application != null) { 560 560 /* … … 562 562 * user not specifically requested to close or restart it. 563 563 */ 564 565 final boolean restartApplication = (request 566 .getParameter(URL_PARAMETER_RESTART_APPLICATION) != null); 567 final boolean closeApplication = (request 568 .getParameter(URL_PARAMETER_CLOSE_APPLICATION) != null); 569 564 570 if (restartApplication) { 565 571 closeApplication(application, request.getSession(false)); … … 574 580 575 581 // No existing application was found 582 583 if (requestCanCreateApplication) { 584 /* 585 * If the request is such that it should create a new application if 586 * one as not found, we do that. 587 */ 588 return createApplication(request); 589 } else { 590 /* 591 * The application was not found and a new one should not be 592 * created. Assume the session has expired. 593 */ 594 throw new SessionExpired(); 595 } 596 597 } 598 599 /** 600 * Check if the request should create an application if an existing 601 * application is not found. 602 * 603 * @param request 604 * @param requestType 605 * @return true if an application should be created, false otherwise 606 */ 607 private boolean requestCanCreateApplication(HttpServletRequest request, 608 RequestType requestType) { 576 609 if (requestType == RequestType.UIDL && isRepaintAll(request)) { 577 610 /* … … 580 613 * without using writeAjaxPage. 581 614 */ 582 return createApplication(request);615 return true; 583 616 584 617 } else if (requestType == RequestType.OTHER) { 585 618 /* 586 * TODO Should any request really create a new application instance587 * i f none was found?619 * TODO Should any URL request really create a new application 620 * instance if none was found? 588 621 */ 589 return createApplication(request); 590 591 } else { 592 /* The application was not found. Assume the session has expired. */ 593 throw new SessionExpired(); 594 } 595 622 return true; 623 624 } 625 626 return false; 596 627 } 597 628 … … 1589 1620 servletPath = servletPath + "/"; 1590 1621 } 1622 System.out.println(request.getPathInfo()); 1591 1623 URL u = new URL(reqURL, servletPath); 1592 1624 return u; … … 1599 1631 * @param request 1600 1632 * the HTTP request. 1633 * @param allowSessionCreation 1634 * true if a session should be created if no session exists, 1635 * false if no session should be created 1601 1636 * @return Application instance, or null if the URL does not map to valid 1602 1637 * application. … … 1607 1642 * @throws IllegalAccessException 1608 1643 * @throws InstantiationException 1609 */ 1610 private Application getExistingApplication(HttpServletRequest request) 1611 throws MalformedURLException, SAXException, IllegalAccessException, 1612 InstantiationException { 1644 * @throws SessionExpired 1645 */ 1646 private Application getExistingApplication(HttpServletRequest request, 1647 boolean allowSessionCreation) throws MalformedURLException, 1648 SessionExpired { 1613 1649 1614 1650 // Ensures that the session is still valid 1615 final HttpSession session = request.getSession(true); 1651 final HttpSession session = request.getSession(allowSessionCreation); 1652 if (session == null) { 1653 throw new SessionExpired(); 1654 } 1616 1655 1617 1656 WebApplicationContext context = WebApplicationContext … … 1619 1658 1620 1659 // Gets application list for the session. 1621 final Collection applications = context.getApplications();1660 final Collection<Application> applications = context.getApplications(); 1622 1661 1623 1662 // Search for the application (using the application URI) from the list 1624 for (final Iterator i = applications.iterator(); i.hasNext();) { 1625 final Application sessionApplication = (Application) i.next(); 1663 for (final Iterator<Application> i = applications.iterator(); i 1664 .hasNext();) { 1665 final Application sessionApplication = i.next(); 1626 1666 final String sessionApplicationPath = sessionApplication.getURL() 1627 1667 .getPath();
