123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- /*
- @ITMillApache2LicenseForJavaFiles@
- */
-
- package com.vaadin.terminal.gwt.server;
-
- import java.io.File;
-
- import javax.servlet.http.HttpSession;
- import javax.servlet.http.HttpSessionBindingListener;
-
- import com.vaadin.Application;
-
- /**
- * Web application context for Vaadin applications.
- *
- * This is automatically added as a {@link HttpSessionBindingListener} when
- * added to a {@link HttpSession}.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.1
- */
- @SuppressWarnings("serial")
- public class WebApplicationContext extends AbstractWebApplicationContext {
-
- protected transient HttpSession session;
-
- /**
- * Creates a new Web Application Context.
- *
- */
- WebApplicationContext() {
-
- }
-
- /**
- * Gets the application context base directory.
- *
- * @see com.vaadin.service.ApplicationContext#getBaseDirectory()
- */
- public File getBaseDirectory() {
- final String realPath = ApplicationServlet.getResourcePath(
- session.getServletContext(), "/");
- if (realPath == null) {
- return null;
- }
- return new File(realPath);
- }
-
- /**
- * Gets the http-session application is running in.
- *
- * @return HttpSession this application context resides in.
- */
- public HttpSession getHttpSession() {
- return session;
- }
-
- /**
- * Gets the application context for an HttpSession.
- *
- * @param session
- * the HTTP session.
- * @return the application context for HttpSession.
- */
- static public WebApplicationContext getApplicationContext(
- HttpSession session) {
- WebApplicationContext cx = (WebApplicationContext) session
- .getAttribute(WebApplicationContext.class.getName());
- if (cx == null) {
- cx = new WebApplicationContext();
- session.setAttribute(WebApplicationContext.class.getName(), cx);
- }
- if (cx.session == null) {
- cx.session = session;
- }
- return cx;
- }
-
- protected void addApplication(Application application) {
- applications.add(application);
- }
-
- /**
- * Gets communication manager for an application.
- *
- * If this application has not been running before, a new manager is
- * created.
- *
- * @param application
- * @return CommunicationManager
- */
- protected CommunicationManager getApplicationManager(
- Application application, AbstractApplicationServlet servlet) {
- CommunicationManager mgr = (CommunicationManager) applicationToAjaxAppMgrMap
- .get(application);
-
- if (mgr == null) {
- // Creates new manager
- mgr = new CommunicationManager(application, servlet);
- applicationToAjaxAppMgrMap.put(application, mgr);
- }
- return mgr;
- }
-
- }
|