enterpriseapplication.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 805 行 · 第 1/2 页
JAVA
805 行
/* * 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.e_app;import com.caucho.config.ConfigException;import com.caucho.ejb.manager.EjbContainer;import com.caucho.java.WorkDir;import com.caucho.lifecycle.Lifecycle;import com.caucho.loader.*;import com.caucho.log.Log;import com.caucho.server.deploy.EnvironmentDeployInstance;import com.caucho.server.webapp.WebAppContainer;import com.caucho.server.webapp.WebAppController;import com.caucho.server.webapp.WebAppConfig;import com.caucho.util.L10N;import com.caucho.vfs.Depend;import com.caucho.vfs.JarPath;import com.caucho.vfs.Path;import com.caucho.vfs.Vfs;import javax.annotation.PostConstruct;import java.util.ArrayList;import java.util.logging.Level;import java.util.logging.Logger;/** * An enterprise application (ear) */public class EnterpriseApplication implements EnvironmentBean, EnvironmentDeployInstance{ static final L10N L = new L10N(EnterpriseApplication.class); static final Logger log = Logger.getLogger(EnterpriseApplication.class.getName()); private static final EnvironmentLocal<EnterpriseApplication> _localEApp = new EnvironmentLocal<EnterpriseApplication>(); /* protected static EnvironmentLocal<EJBServerInterface> _localServer = new EnvironmentLocal<EJBServerInterface>("caucho.ejb-server"); */ private EnvironmentClassLoader _loader; private String _name; private String _ejbServerJndiName = "java:comp/env/cmp"; private Path _rootDir; private Path _earPath; private String _prefix = ""; private EarDeployController _controller; private Path _webappsPath; private WebAppContainer _container; private String _version; private String _libraryDirectory; private boolean _hasModule; // private WarDirApplicationGenerator _warDeploy; private ArrayList<Path> _ejbPaths = new ArrayList<Path>(); private ArrayList<WebModule> _webConfigList = new ArrayList<WebModule>(); private ArrayList<WebAppController> _webApps = new ArrayList<WebAppController>(); private Throwable _configException; private final Lifecycle _lifecycle; /** * Creates the application. */ EnterpriseApplication(WebAppContainer container, EarDeployController controller, String name) { if (container == null || controller == null) throw new NullPointerException(); _container = container; _controller = controller; _name = name; ClassLoader parentLoader; if (container != null) parentLoader = container.getClassLoader(); else parentLoader = Thread.currentThread().getContextClassLoader(); _loader = EnvironmentClassLoader.create(parentLoader, "eapp:" + name); _webappsPath = _controller.getRootDirectory().lookup("webapps"); WorkDir.setLocalWorkDir(_controller.getRootDirectory().lookup("META-INF/work"), _loader); _lifecycle = new Lifecycle(log, toString(), Level.INFO); if (controller.getArchivePath() != null) Environment.addDependency(new Depend(controller.getArchivePath()), _loader); _localEApp.set(this, _loader); } /* // ejb/0fa0 public EnterpriseApplication() { _lifecycle = new Lifecycle(log, toString(), Level.INFO); } */ public static EnterpriseApplication getLocal() { return _localEApp.get(); } /** * Sets the name. */ public void setName(String name) { _name = name; _loader.setId("eapp:" + name + ""); } /** * Gets the name. */ public String getName() { return _name; } /** * Sets the library directory. */ public void setLibraryDirectory(String libraryDirectory) { _libraryDirectory = libraryDirectory; } /** * Gets the library directory. */ public String getLibraryDirectory() { return _libraryDirectory; } /** * Sets the ejb-server jndi name. */ public void setEjbServerJndiName(String name) { _ejbServerJndiName = name; } /** * Sets the root directory. */ public void setRootDirectory(Path rootDir) { _rootDir = rootDir; } /** * Sets the root directory. */ public Path getRootDirectory() { return _rootDir; } /** * Returns the class loader. */ public EnvironmentClassLoader getClassLoader() { return _loader; } /** * Sets the class loader. */ public void setEnvironmentClassLoader(EnvironmentClassLoader loader) { _loader = loader; } /** * Sets the path to the .ear file */ public void setEarPath(Path earPath) { _earPath = earPath; } /** * Sets the path to the expanded webapps */ public void setWebapps(Path webappsPath) { _webappsPath = webappsPath; } /** * Sets the prefix URL for web applications. */ public void setPrefix(String prefix) { _prefix = prefix; } /** * Sets the id */ public void setId(String id) { } /** * Sets the application version. */ public void setVersion(String version) { _version = version; } /** * Sets the schema location */ public void setSchemaLocation(String schema) { } /** * Sets the display name. */ public void setDisplayName(String name) { } /** * Sets the description. */ public void setDescription(String description) { } /** * Sets the icon. */ public void setIcon(Icon icon) { } /** * Adds a module. */ public Module createModule() { _hasModule = true; return new Module(); } /** * Finds a web module based on the web-uri */ WebModule findWebModule(String webUri) { for (int i = 0; i < _webConfigList.size(); i++) { WebModule web = _webConfigList.get(i); if (webUri.equals(web.getWebURI())) return web; } return null; } /** * Finds a web module based on the web-uri */ void addWebModule(WebModule webModule) { _webConfigList.add(webModule); } /** * Adds a security role. */ public void addSecurityRole(SecurityRole role) { } /** * Returns true if it's modified. */ public boolean isModified() { return _loader.isModified(); } /** * Returns true if it's modified. */ public boolean isModifiedNow() { return _loader.isModifiedNow(); } /** * Log the reason for modification. */ public boolean logModified(Logger log) { return _loader.logModified(log); } /** * Returns true if it's modified. */ public boolean isDeployError() { return _configException != null; } /** * Returns true if the application is idle. */ public boolean isDeployIdle() { return false; } /** * Sets the config exception. */ public void setConfigException(Throwable e) { _configException = e; for (WebAppController controller : _webApps) { controller.setConfigException(e); } } /** * Gets the config exception. */ public Throwable getConfigException() { return _configException; } /** * Configures the application. */ @PostConstruct public void init() throws Exception {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?