⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultwebapplication.java

📁 pojo的mvc框架
💻 JAVA
字号:
package xyz.frame.webapp;import java.io.IOException;import java.io.InputStream;import javax.servlet.ServletException;import org.apache.log4j.Logger;import xyz.frame.XyzServlet;import xyz.frame.component.ComponentManager;import xyz.frame.config.ConfigException;import xyz.frame.config.XStreamConfiguration;import xyz.frame.converter.ConverterManager;import xyz.frame.converter.SimpleConverterManager;import xyz.frame.factory.FactoryManager;import xyz.frame.factory.SimpleFactoryManager;import xyz.frame.plugin.DefaultPluginManager;import xyz.frame.url.DefaultURLManager;import xyz.frame.url.URLManager;import xyz.frame.view.RegexViewManager;import xyz.frame.view.ViewManager;/** * A simple web application configuration. It uses the default url manager. *  * @author Guilherme Silveira */public class DefaultWebApplication implements WebApplication {	private static final Logger logger = Logger			.getLogger(DefaultWebApplication.class);	private ConverterManager converterManager;	private URLManager urlManager;	private ComponentManager componentManager;	private FactoryManager factoryManager;	private ViewManager viewManager;	private PluginManager pluginManager;	public DefaultWebApplication() {		urlManager = new DefaultURLManager();		componentManager = new DefaultComponentManager();		factoryManager = new SimpleFactoryManager();		viewManager = new RegexViewManager("/$1/$2.$3.jsp");		converterManager = new SimpleConverterManager();		pluginManager = new DefaultPluginManager();	}	/**	 * 	 * @see xyz.frame.webapp.WebApplication#getURLManager()	 */	public URLManager getURLManager() {		return urlManager;	}	/**	 * Reads the xml file. Inits this configuration: overrides the viewmanager	 * with the views.properties file	 * 	 * @throws ConfigException	 * 	 * @see xyz.frame.webapp.WebApplication#init()	 */	public void init() throws ConfigException {		// reads the xml file		try {			InputStream file = getXMLFile();			new XStreamConfiguration().readManagers(file, this);			file.close();			file = getXMLFile();			new XStreamConfiguration().readComponents(file, this);			file.close();		} catch (IOException e) {			throw new ConfigException(e.getMessage(), e);		}		// reads overriden views.properties		InputStream fis = DefaultWebApplication.class				.getResourceAsStream("/views.properties");		if (fis != null) {			try {				this.viewManager = new ViewsPropertiesReader().overrideViews(						viewManager, fis);			} catch (IOException e) {				logger.warn("Error reading views.properties", e);			}		}	}	/**	 * @return	 * @throws ServletException	 * @throws ConfigException	 */	private InputStream getXMLFile() throws ConfigException {		InputStream file = XyzServlet.class				.getResourceAsStream("/xyz.xml");		if (file == null) {			throw new ConfigException(					"Xyz was not configured: where is xyz.xml?");		}		return file;	}	/**	 * 	 * @see xyz.frame.webapp.WebApplication#getFactoryManager()	 */	public FactoryManager getFactoryManager() {		return this.factoryManager;	}	/**	 * 	 * @see xyz.frame.webapp.WebApplication#getComponentManager()	 */	public ComponentManager getComponentManager() {		return this.componentManager;	}	/**	 * 	 * @see xyz.frame.webapp.WebApplication#getViewManager()	 */	public ViewManager getViewManager() {		return this.viewManager;	}	/**	 * 	 * @see xyz.frame.webapp.WebApplication#getConverterManager()	 */	public ConverterManager getConverterManager() {		return this.converterManager;	}	/**	 * @param viewManager	 *            the viewManager to set	 */	public void setViewManager(ViewManager viewManager) {		this.viewManager = viewManager;	}	public PluginManager getPluginManager() {		return this.pluginManager;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -