webappcontroller.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 727 行 · 第 1/2 页
JAVA
727 行
/* * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Resin Open Source is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty * of NON-INFRINGEMENT. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the * * Free Software Foundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * * @author Scott Ferguson */package com.caucho.server.webapp;import com.caucho.config.types.PathBuilder;import com.caucho.log.Log;import com.caucho.server.deploy.DeployConfig;import com.caucho.server.deploy.DeployControllerAdmin;import com.caucho.server.deploy.EnvironmentDeployController;import com.caucho.server.host.Host;import com.caucho.server.util.CauchoSystem;import com.caucho.util.L10N;import com.caucho.util.Alarm;import com.caucho.vfs.Path;import com.caucho.webbeans.manager.*;import javax.servlet.jsp.el.ELException;import java.io.IOException;import java.util.ArrayList;import java.util.Map;import java.util.logging.Logger;import java.util.regex.Matcher;import java.util.regex.Pattern;import javax.webbeans.*;/** * A configuration entry for a web-app. */public class WebAppController extends EnvironmentDeployController<WebApp,WebAppConfig>{ private static final L10N L = new L10N(WebAppController.class); private static final Logger log = Log.open(WebAppController.class); protected WebAppContainer _container; private WebAppController _parent; // The context path is the URL prefix for the web-app private String _contextPath; private String _version = ""; // Any old version web-app private WebAppController _oldWebAppController; private long _oldWebAppExpireTime; private String _warName; // regexp values private ArrayList<String> _regexpValues; private boolean _isInheritSession; private boolean _isDynamicDeploy; private ArrayList<Path> _dependPathList = new ArrayList<Path>(); private String _sourceType = "unknown"; private final Object _statisticsLock = new Object(); private volatile long _lifetimeConnectionCount; private volatile long _lifetimeConnectionTime; private volatile long _lifetimeReadBytes; private volatile long _lifetimeWriteBytes; private volatile long _lifetimeClientDisconnectCount; private WebAppAdmin _admin = new WebAppAdmin(this); public WebAppController() { this("/", "/", null, null); } public WebAppController(String name, String contextPath, Path rootDirectory, WebAppContainer container) { super(name, rootDirectory); _container = container; setContextPath(contextPath); getVariableMap().put("app", new Var()); getVariableMap().put("webApp", new Var()); } /** * Returns the webApp's context path */ public String getContextPath() { return _contextPath; } /** * Sets the webApp's context path */ public void setContextPath(String contextPath) { if (! contextPath.equals("") && ! contextPath.startsWith("/")) contextPath = "/" + contextPath; if (contextPath.endsWith("/")) contextPath = contextPath.substring(0, contextPath.length() - 1); _contextPath = contextPath; } /** * Returns the webApp's context path */ public String getContextPath(String uri) { if (getConfig() == null || getConfig().getURLRegexp() == null) return getContextPath(); Pattern regexp = getConfig().getURLRegexp(); Matcher matcher = regexp.matcher(uri); int tail = 0; while (tail >= 0 && tail <= uri.length()) { String prefix = uri.substring(0, tail); matcher.reset(prefix); if (matcher.find() && matcher.start() == 0) return matcher.group(); if (tail < uri.length()) { tail = uri.indexOf('/', tail + 1); if (tail < 0) tail = uri.length(); } else break; } return _contextPath; } /** * Sets the war name prefix. */ public void setWarName(String warName) { _warName = warName; } /** * Gets the war name prefix. */ public String getWarName() { return _warName; } /** * Gets the URL */ public String getURL() { if (_container != null) return _container.getURL() + _contextPath; else return _contextPath; } /** * Returns the parent controller. */ public WebAppController getParent() { return _parent; } /** * Returns the web-app container. */ public WebAppContainer getContainer() { return _container; } /** * Sets the parent controller. */ public void setParentWebApp(WebAppController parent) { _parent = parent; } /** * Returns the containing host. */ public Host getHost() { if (_container != null) return _container.getHost(); else return null; } /** * Returns the source (for backwards compatibility) */ public String getSourceType() { return _sourceType; } /** * Sets the source (for backwards compatibility) */ public void setSourceType(String type) { _sourceType = type; } /** * Sets the regexp values. */ public void setRegexpValues(ArrayList<String> values) { _regexpValues = values; } /** * True for inherit-session webApps. */ public boolean isInheritSession() { return _isInheritSession; } /** * True for inherit-session */ public void setInheritSession(boolean inheritSession) { _isInheritSession = inheritSession; } /** * Returns the webApp object. */ public WebApp getWebApp() { return getDeployInstance(); } /** * Set true for a dynamically deployed webApp. */ public void setDynamicDeploy(boolean isDynamicDeploy) { _isDynamicDeploy = isDynamicDeploy; } /** * Returns true for a dynamically deployed webApp. */ public boolean isDynamicDeploy() { return _isDynamicDeploy; } @Override protected String getMBeanTypeName() { return "WebApp"; } @Override protected String getMBeanId() { String name = getId(); if (name.equals("")) name = "/"; return name; } /** * Sets the version id. */ protected void setVersion(String version) { _version = version; } /** * Gets the version id. */ public String getVersion() { return _version; } /** * Sets the old version web-app. */ public void setOldWebApp(WebAppController oldWebApp, long expireTime) { _oldWebAppController = oldWebApp; _oldWebAppExpireTime = expireTime; WebApp webApp = getDeployInstance(); if (webApp != null) webApp.setOldWebApp(oldWebApp.request(), expireTime); } /** * Adds a version to the controller list. */ /* protected WebAppController addVersion(WebAppController controller) { WebAppVersioningController versioningController = new WebAppVersioningController(getContextPath()); versioningController.addVersion(this); versioningController.addVersion(controller); return versioningController; } */ /** * Returns the deploy admin. */ @Override protected DeployControllerAdmin getDeployAdmin() { return _admin; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?