applicationimpl.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 1,774 行 · 第 1/4 页
JAVA
1,774 行
/* * 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.application;import com.caucho.config.Config;import com.caucho.jsf.cfg.ManagedBeanConfig;import com.caucho.jsf.cfg.ResourceBundleConfig;import com.caucho.jsf.cfg.JsfPropertyGroup;import com.caucho.jsf.context.FacesELContext;import com.caucho.jsf.el.FacesContextELResolver;import com.caucho.jsf.el.FacesJspELResolver;import com.caucho.jsf.el.JsfResourceBundleELResolver;import com.caucho.jsf.el.MethodBindingAdapter;import com.caucho.jsf.el.ValueBindingAdapter;import com.caucho.jsf.el.ValueExpressionAdapter;import com.caucho.server.webapp.WebApp;import com.caucho.util.L10N;import com.caucho.util.LruCache;import javax.el.*;import javax.el.PropertyNotFoundException;import javax.faces.FacesException;import javax.faces.application.Application;import javax.faces.application.NavigationHandler;import javax.faces.application.StateManager;import javax.faces.application.ViewHandler;import javax.faces.application.ResourceHandler;import javax.faces.application.ProjectStage;import javax.faces.component.*;import javax.faces.component.html.*;import javax.faces.context.FacesContext;import javax.faces.convert.*;import javax.faces.el.*;import javax.faces.event.ActionListener;import javax.faces.event.SystemEvent;import javax.faces.event.SystemEventListener;import javax.faces.event.SystemEventListenerHolder;import javax.faces.event.AbortProcessingException;import javax.faces.validator.DoubleRangeValidator;import javax.faces.validator.LengthValidator;import javax.faces.validator.LongRangeValidator;import javax.faces.validator.Validator;import javax.servlet.jsp.JspApplicationContext;import javax.servlet.jsp.JspFactory;import javax.naming.InitialContext;import javax.naming.NamingException;import java.lang.reflect.Constructor;import java.util.*;import java.util.logging.Logger;import java.util.logging.Level;import java.beans.FeatureDescriptor;public class ApplicationImpl extends Application{ private static final L10N L = new L10N(ApplicationImpl.class); private static final Logger log = Logger.getLogger(ApplicationImpl.class.getName()); private ActionListener _actionListener; private StateManager _stateManager; private ViewHandler _viewHandler; private ResourceHandler _resourceHandler; private NavigationHandler _navigationHandler; final private NavigationHandlerImpl _defaultNavigationHandler; private PropertyResolver _propertyResolver; private VariableResolver _variableResolver; private ExpressionFactory _jsfExpressionFactory; private FacesContextELResolver _elResolver; private JsfResourceBundleELResolver _bundleResolver = new JsfResourceBundleELResolver(); private ArrayList<Locale> _locales; private Locale _defaultLocale; private ArrayList<ELContextListener> _elContextListenerList = new ArrayList<ELContextListener>(); private ELContextListener []_elContextListeners; private HashMap<String, String> _componentClassNameMap = new HashMap<String, String>(); private HashMap<String, Class> _componentClassMap = new HashMap<String, Class>(); private HashMap<String, String> _validatorClassMap = new HashMap<String, String>(); private HashMap<String, String> _converterIdNameMap = new HashMap<String, String>(); private HashMap<String, Class> _converterIdMap = new HashMap<String, Class>(); private HashMap<Class, String> _converterClassNameMap = new HashMap<Class, String>(); private HashMap<Class, Class> _converterClassMap = new HashMap<Class, Class>(); private HashMap<Class<? extends SystemEvent>, HashMap<Class, SystemEventListener []>> _systemEventListenerMap = new HashMap<Class<? extends SystemEvent>, HashMap<Class, SystemEventListener []>>(); private LruCache<Class<? extends SystemEvent>, LruCache<Class<? extends SystemEventListenerHolder>, Constructor>> _systemEventConstructorMap = new LruCache<Class<? extends SystemEvent>, LruCache<Class<? extends SystemEventListenerHolder>, Constructor>>(32); private String _defaultRenderKitId = "HTML_BASIC"; private String _messageBundle; private boolean _isInit; private PropertyResolver _legacyPropertyResolver; private VariableResolver _legacyVariableResolver; private ProjectStage _projectStage; public ApplicationImpl() { WebApp webApp = WebApp.getLocal(); JspFactory jspFactory = JspFactory.getDefaultFactory(); JspApplicationContext appContext = jspFactory.getJspApplicationContext(webApp); _jsfExpressionFactory = appContext.getExpressionFactory(); ELResolver []customResolvers = new ELResolver[0]; _elResolver = new FacesContextELResolver(customResolvers, _bundleResolver); setViewHandler(new JspViewHandler()); setResourceHandler(new ResourceHandlerImpl()); SessionStateManager stateManager = new SessionStateManager(); JsfPropertyGroup jsfPropertyGroup = webApp.getJsf(); if (jsfPropertyGroup != null) stateManager.setStateSerializationMethod( jsfPropertyGroup.getStateSerializationMethod()); setStateManager(stateManager); appContext.addELResolver(new FacesJspELResolver(this)); addComponent(UIColumn.COMPONENT_TYPE, "javax.faces.component.UIColumn"); addComponent(UICommand.COMPONENT_TYPE, "javax.faces.component.UICommand"); addComponent(UIData.COMPONENT_TYPE, "javax.faces.component.UIData"); addComponent(UIForm.COMPONENT_TYPE, "javax.faces.component.UIForm"); addComponent(UIGraphic.COMPONENT_TYPE, "javax.faces.component.UIGraphic"); addComponent(UIInput.COMPONENT_TYPE, "javax.faces.component.UIInput"); addComponent(UIMessage.COMPONENT_TYPE, "javax.faces.component.UIMessage"); addComponent(UIMessages.COMPONENT_TYPE, "javax.faces.component.UIMessages"); addComponent(UINamingContainer.COMPONENT_TYPE, "javax.faces.component.UINamingContainer"); addComponent(UIOutput.COMPONENT_TYPE, "javax.faces.component.UIOutput"); addComponent(UIPanel.COMPONENT_TYPE, "javax.faces.component.UIPanel"); addComponent(UIParameter.COMPONENT_TYPE, "javax.faces.component.UIParameter"); addComponent(UISelectBoolean.COMPONENT_TYPE, "javax.faces.component.UISelectBoolean"); addComponent(UISelectOne.COMPONENT_TYPE, "javax.faces.component.UISelectOne"); addComponent(UISelectMany.COMPONENT_TYPE, "javax.faces.component.UISelectMany"); addComponent(UISelectItem.COMPONENT_TYPE, "javax.faces.component.UISelectItem"); addComponent(UISelectItems.COMPONENT_TYPE, "javax.faces.component.UISelectItems"); addComponent(UIViewRoot.COMPONENT_TYPE, "javax.faces.component.UIViewRoot"); addComponent(HtmlCommandButton.COMPONENT_TYPE, "javax.faces.component.html.HtmlCommandButton"); addComponent(HtmlCommandLink.COMPONENT_TYPE, "javax.faces.component.html.HtmlCommandLink"); addComponent(HtmlDataTable.COMPONENT_TYPE, "javax.faces.component.html.HtmlDataTable"); addComponent(HtmlGraphicImage.COMPONENT_TYPE, "javax.faces.component.html.HtmlGraphicImage"); addComponent(HtmlInputHidden.COMPONENT_TYPE, "javax.faces.component.html.HtmlInputHidden"); addComponent(HtmlInputSecret.COMPONENT_TYPE, "javax.faces.component.html.HtmlInputSecret"); addComponent(HtmlInputText.COMPONENT_TYPE, "javax.faces.component.html.HtmlInputText"); addComponent(HtmlInputTextarea.COMPONENT_TYPE, "javax.faces.component.html.HtmlInputTextarea"); addComponent(HtmlMessage.COMPONENT_TYPE, "javax.faces.component.html.HtmlMessage"); addComponent(HtmlMessages.COMPONENT_TYPE, "javax.faces.component.html.HtmlMessages"); addComponent(HtmlOutputFormat.COMPONENT_TYPE, "javax.faces.component.html.HtmlOutputFormat"); addComponent(HtmlOutputLabel.COMPONENT_TYPE, "javax.faces.component.html.HtmlOutputLabel"); addComponent(HtmlOutputLink.COMPONENT_TYPE, "javax.faces.component.html.HtmlOutputLink"); addComponent(HtmlOutputText.COMPONENT_TYPE, "javax.faces.component.html.HtmlOutputText"); addComponent(HtmlPanelGrid.COMPONENT_TYPE, "javax.faces.component.html.HtmlPanelGrid"); addComponent(HtmlPanelGroup.COMPONENT_TYPE, "javax.faces.component.html.HtmlPanelGroup"); addComponent(HtmlForm.COMPONENT_TYPE, "javax.faces.component.html.HtmlForm"); addComponent(HtmlSelectBooleanCheckbox.COMPONENT_TYPE, "javax.faces.component.html.HtmlSelectBooleanCheckbox"); addComponent(HtmlSelectManyCheckbox.COMPONENT_TYPE, "javax.faces.component.html.HtmlSelectManyCheckbox"); addComponent(HtmlSelectManyListbox.COMPONENT_TYPE, "javax.faces.component.html.HtmlSelectManyListbox"); addComponent(HtmlSelectManyMenu.COMPONENT_TYPE, "javax.faces.component.html.HtmlSelectManyMenu"); addComponent(HtmlSelectOneListbox.COMPONENT_TYPE, "javax.faces.component.html.HtmlSelectOneListbox"); addComponent(HtmlSelectOneMenu.COMPONENT_TYPE, "javax.faces.component.html.HtmlSelectOneMenu"); addComponent(HtmlSelectOneRadio.COMPONENT_TYPE, "javax.faces.component.html.HtmlSelectOneRadio"); addConverter(BooleanConverter.CONVERTER_ID, BooleanConverter.class.getName()); addConverter(boolean.class, BooleanConverter.class.getName()); addConverter(Boolean.class, BooleanConverter.class.getName()); addConverter(CharacterConverter.CONVERTER_ID, CharacterConverter.class.getName()); addConverter(char.class, CharacterConverter.class.getName()); addConverter(Character.class, CharacterConverter.class.getName()); addConverter(ByteConverter.CONVERTER_ID, ByteConverter.class.getName()); addConverter(byte.class, ByteConverter.class.getName()); addConverter(Byte.class, ByteConverter.class.getName()); addConverter(Byte.TYPE, ByteConverter.class.getName()); addConverter(ShortConverter.CONVERTER_ID, ShortConverter.class.getName()); addConverter(short.class, ShortConverter.class.getName()); addConverter(Short.class, ShortConverter.class.getName()); addConverter(IntegerConverter.CONVERTER_ID, IntegerConverter.class.getName()); addConverter(int.class, IntegerConverter.class.getName()); addConverter(Integer.class, IntegerConverter.class.getName()); addConverter(LongConverter.CONVERTER_ID, LongConverter.class.getName()); addConverter(long.class, LongConverter.class.getName()); addConverter(Long.class, LongConverter.class.getName()); addConverter(FloatConverter.CONVERTER_ID, FloatConverter.class.getName()); addConverter(float.class, FloatConverter.class.getName()); addConverter(Float.class, FloatConverter.class.getName()); addConverter(DoubleConverter.CONVERTER_ID, DoubleConverter.class.getName()); addConverter(double.class, DoubleConverter.class.getName()); addConverter(Double.class, DoubleConverter.class.getName()); addConverter(DateTimeConverter.CONVERTER_ID, DateTimeConverter.class.getName()); addConverter(NumberConverter.CONVERTER_ID, NumberConverter.class.getName()); addConverter(BigDecimalConverter.CONVERTER_ID, BigDecimalConverter.class.getName()); addConverter(java.math.BigDecimal.class, BigDecimalConverter.class.getName()); addConverter(BigIntegerConverter.CONVERTER_ID, BigIntegerConverter.class.getName()); addConverter(java.math.BigInteger.class, BigIntegerConverter.class.getName()); addConverter(EnumConverter.CONVERTER_ID, EnumConverter.class.getName()); addConverter(Enum.class, EnumConverter.class.getName()); addValidator(DoubleRangeValidator.VALIDATOR_ID, DoubleRangeValidator.class.getName()); addValidator(LengthValidator.VALIDATOR_ID, LengthValidator.class.getName()); addValidator(LongRangeValidator.VALIDATOR_ID, LongRangeValidator.class.getName()); _defaultNavigationHandler = new NavigationHandlerImpl(); } public void addManagedBean(String name, ManagedBeanConfig managedBean) { _elResolver.addManagedBean(name, managedBean); } public void addResourceBundle(String name, ResourceBundleConfig bundle) { _bundleResolver.addBundle(name, bundle); } public ActionListener getActionListener() { if (_actionListener == null) _actionListener = new ActionListenerImpl(); return _actionListener; } public void setActionListener(ActionListener listener) { if (listener == null) throw new NullPointerException(); _actionListener = listener; } public Locale getDefaultLocale() { return _defaultLocale; } public void setDefaultLocale(Locale locale) { if (locale == null) throw new NullPointerException(); _defaultLocale = locale; } public String getDefaultRenderKitId() { return _defaultRenderKitId; } public void setDefaultRenderKitId(String renderKitId) { _defaultRenderKitId = renderKitId; } public String getMessageBundle() { return _messageBundle; } public void setMessageBundle(String bundle) { _messageBundle = bundle; } @Override public ResourceBundle getResourceBundle(FacesContext context, String name) { return null; } public NavigationHandler getNavigationHandler() { if (_navigationHandler == null) return _defaultNavigationHandler; return _navigationHandler;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?