applicationconfig.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 609 行 · 第 1/2 页
JAVA
609 行
/* * 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 version 2 * as published by the Free Software Foundation. * * 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.jsf.cfg;import com.caucho.config.program.ConfigProgram;import java.util.*;import java.util.logging.*;import java.lang.reflect.*;import javax.el.*;import javax.faces.*;import javax.faces.application.*;import javax.faces.component.*;import javax.faces.component.html.*;import javax.faces.context.*;import javax.faces.convert.*;import javax.faces.el.*;import javax.faces.event.*;import javax.faces.validator.*;import com.caucho.config.*;import com.caucho.util.*;import com.caucho.jsf.application.ApplicationImpl;public class ApplicationConfig{ private static final Logger log = Logger.getLogger(ApplicationConfig.class.getName()); private static final L10N L = new L10N(ApplicationConfig.class); private String _id; private Class _actionListener; private String _defaultRenderKitId; private String _messageBundle; private Class _navigationHandler; private Class _viewHandler; private Class _resourceHandler; private Class _stateManager; private ArrayList<ELResolver> _elResolverList = new ArrayList<ELResolver>(); private Class _propertyResolver; private Class _variableResolver; private ArrayList<ResourceBundleConfig> _resourceBundleList = new ArrayList<ResourceBundleConfig>(); private LocaleConfig _localeConfig; public void setId(String id) { _id = id; } public void setDefaultRenderKitId(String id) { _defaultRenderKitId = id; } public void setMessageBundle(String messageBundle) { _messageBundle = messageBundle; } public void setActionListener(Class actionListener) throws ConfigException { Config.validate(actionListener, ActionListener.class, ActionListener.class); _actionListener = actionListener; } public void setNavigationHandler(Class navigationHandler) throws ConfigException { if (! NavigationHandler.class.isAssignableFrom(navigationHandler)) throw new ConfigException(L.l("navigation-handler '{0}' must extend javax.faces.application.NavigationHandler.", navigationHandler.getName())); Constructor ctor = null; try { ctor = navigationHandler.getConstructor(new Class[] { NavigationHandler.class }); } catch (Exception e) { log.log(Level.FINEST, e.toString(), e); } try { if (ctor == null) ctor = navigationHandler.getConstructor(new Class[] { }); } catch (Exception e) { log.log(Level.FINEST, e.toString(), e); } if (ctor == null) throw new ConfigException(L.l("navigation-handler '{0}' must have either a zero-arg constructor or a constructor with a single NavigationHandler argument.", navigationHandler.getName())); _navigationHandler = navigationHandler; } public void setViewHandler(Class viewHandler) throws ConfigException { if (! ViewHandler.class.isAssignableFrom(viewHandler)) throw new ConfigException(L.l("view-handler '{0}' must extend javax.faces.application.ViewHandler.", viewHandler.getName())); Constructor ctor = null; try { ctor = viewHandler.getConstructor(new Class[] { ViewHandler.class }); } catch (Exception e) { log.log(Level.FINEST, e.toString(), e); } try { if (ctor == null) ctor = viewHandler.getConstructor(new Class[] { }); } catch (Exception e) { log.log(Level.FINEST, e.toString(), e); } if (ctor == null) throw new ConfigException(L.l("view-handler '{0}' must have either a zero-arg constructor or a constructor with a single ViewHandler argument.", viewHandler.getName())); _viewHandler = viewHandler; } public void setResourceHandler(Class resourceHandler) throws ConfigException { if (! ResourceHandler.class.isAssignableFrom(resourceHandler)) throw new ConfigException(L.l("resource-handler '{0}' must extend javax.faces.application.ResourceHandler", resourceHandler.getName())); Constructor ctor = null; try { ctor = resourceHandler.getConstructor(new Class[]{ ResourceHandler.class }); } catch (NoSuchMethodException e) { log.log(Level.FINEST, e.toString(), e); } try { if (ctor == null) ctor = resourceHandler.getConstructor(new Class[]{}); } catch (NoSuchMethodException e) { log.log(Level.FINEST, e.toString(), e); } if (ctor == null) throw new ConfigException(L.l("resource-handler '{0}' must have either a zero-arg constructor or a constructor with a single ResorceHandler argument.", resourceHandler.getName())); _resourceHandler = resourceHandler; } public void setStateManager(Class stateManager) throws ConfigException { if (! StateManager.class.isAssignableFrom(stateManager)) throw new ConfigException(L.l("state-manager '{0}' must extend javax.faces.application.StateManager.", stateManager.getName())); Constructor ctor = null; try { ctor = stateManager.getConstructor(new Class[] { StateManager.class }); } catch (Exception e) { log.log(Level.FINEST, e.toString(), e); } try { if (ctor == null) ctor = stateManager.getConstructor(new Class[] { }); } catch (Exception e) { log.log(Level.FINEST, e.toString(), e); } if (ctor == null) throw new ConfigException(L.l("state-manager '{0}' must have either a zero-arg constructor or a constructor with a single StateManager argument.", stateManager.getName())); _stateManager = stateManager; } public Class getStateManager() { return _stateManager; } public void setElResolver(Class elResolver) throws ConfigException { Config.validate(elResolver, ELResolver.class); try { _elResolverList.add((ELResolver) elResolver.newInstance()); } catch (Exception e) { throw ConfigException.create(e); } } public Class getElResolver() { return null; } public ArrayList<ELResolver> getElResolverList() { return _elResolverList; } public void setPropertyResolver(Class propertyResolver) throws ConfigException { Config.validate(propertyResolver, PropertyResolver.class, PropertyResolver.class); _propertyResolver = propertyResolver; } public Class getPropertyResolver() { return _propertyResolver; } public void setVariableResolver(Class variableResolver) throws ConfigException { Config.validate(variableResolver, VariableResolver.class, VariableResolver.class); _variableResolver = variableResolver; } public Class getVariableResolver() { return _variableResolver; } public void setResourceBundle(ResourceBundleConfig bundle) throws ConfigException { _resourceBundleList.add(bundle); } private ResourceBundleConfig getResourceBundle() throws ConfigException { return null; } public ArrayList<ResourceBundleConfig> getResourceBundleList() { return _resourceBundleList; } public void setApplicationExtension(ConfigProgram program) { }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?