示例#1
0
 public ServletContextImpl(final ServletContainer servletContainer, final Deployment deployment) {
   this.servletContainer = servletContainer;
   this.deployment = deployment;
   this.deploymentInfo = deployment.getDeploymentInfo();
   sessionCookieConfig = new SessionCookieConfigImpl(this);
   ServletSessionConfig sc = deploymentInfo.getServletSessionConfig();
   if (sc != null) {
     sessionCookieConfig.setName(sc.getName());
     sessionCookieConfig.setComment(sc.getComment());
     sessionCookieConfig.setDomain(sc.getDomain());
     sessionCookieConfig.setHttpOnly(sc.isHttpOnly());
     sessionCookieConfig.setMaxAge(sc.getMaxAge());
     sessionCookieConfig.setPath(sc.getPath());
     sessionCookieConfig.setSecure(sc.isSecure());
     if (sc.getSessionTrackingModes() != null) {
       defaultSessionTrackingModes =
           sessionTrackingModes = new HashSet<SessionTrackingMode>(sc.getSessionTrackingModes());
     }
   }
   if (deploymentInfo.getServletContextAttributeBackingMap() == null) {
     this.attributes = new ConcurrentHashMap<String, Object>();
   } else {
     this.attributes = deploymentInfo.getServletContextAttributeBackingMap();
   }
   attributes.putAll(deployment.getDeploymentInfo().getServletContextAttributes());
 }
 public void handleDeploymentSessionConfig(
     DeploymentInfo deploymentInfo, ServletContextImpl servletContext) {
   SessionCookieConfigImpl sessionCookieConfig = servletContext.getSessionCookieConfig();
   ServletSessionConfig sc = deploymentInfo.getServletSessionConfig();
   if (sc != null) {
     sessionCookieConfig.setName(sc.getName());
     sessionCookieConfig.setComment(sc.getComment());
     sessionCookieConfig.setDomain(sc.getDomain());
     sessionCookieConfig.setHttpOnly(sc.isHttpOnly());
     sessionCookieConfig.setMaxAge(sc.getMaxAge());
     if (sc.getPath() != null) {
       sessionCookieConfig.setPath(sc.getPath());
     } else {
       sessionCookieConfig.setPath(deploymentInfo.getContextPath());
     }
     sessionCookieConfig.setSecure(sc.isSecure());
     if (sc.getSessionTrackingModes() != null) {
       servletContext.setDefaultSessionTrackingModes(new HashSet<>(sc.getSessionTrackingModes()));
     }
   }
 }