applicationimpl.java
来自「一个使用struts+hibernate+spring开发的完的网站源代码。」· Java 代码 · 共 677 行 · 第 1/2 页
JAVA
677 行
/* * Copyright 2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.myfaces.application;import org.apache.myfaces.application.jsp.JspStateManagerImpl;import org.apache.myfaces.application.jsp.JspViewHandlerImpl;import org.apache.myfaces.el.MethodBindingImpl;import org.apache.myfaces.el.PropertyResolverImpl;import org.apache.myfaces.el.ValueBindingImpl;import org.apache.myfaces.el.VariableResolverImpl;import org.apache.myfaces.util.BiLevelCacheMap;import org.apache.myfaces.util.ClassUtils;import org.apache.myfaces.config.impl.digester.elements.Property;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.commons.beanutils.BeanUtils;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.component.UIComponent;import javax.faces.context.FacesContext;import javax.faces.convert.Converter;import javax.faces.el.*;import javax.faces.event.ActionListener;import javax.faces.validator.Validator;import java.util.*;/** * DOCUMENT ME! * @author Manfred Geiler (latest modification by $Author: matzew $) * @author Anton Koinov * @author Thomas Spiegl * @version $Revision: 1.37 $ $Date: 2005/03/10 10:26:00 $ * $Log: ApplicationImpl.java,v $ * Revision 1.37 2005/03/10 10:26:00 matzew * Patch for the ApplicationImpl form Mike Traum (MYFACES-122). * Also changed behaivor of "createConverter(java.lang.String converterId)" * * Revision 1.36 2005/03/04 00:28:45 mmarinschek * Changes in configuration due to missing Attribute/Property classes for the converter; not building in the functionality yet except for part of the converter properties * * Revision 1.35 2004/12/03 08:46:09 manolito * MYFACES-45 / ApplicationImpl does not correctly traverse a Class' hierarchy to create a Converter * * Revision 1.34 2004/10/13 11:50:59 matze * renamed packages to org.apache * * Revision 1.33 2004/09/08 07:45:05 mwessendorf * set DefaultRenderKitId = "HTML_BASIC" * * Revision 1.32 2004/08/10 10:57:37 manolito * fixed StackOverflow in ClassUtils and cleaned up ClassUtils methods * * Revision 1.31 2004/07/01 22:05:14 mwessendorf * ASF switch * * Revision 1.30 2004/06/14 12:55:23 manolito * Added missing CVS Log comment * */public class ApplicationImpl extends Application{ private static final Log log = LogFactory.getLog(ApplicationImpl.class); //~ Instance fields ---------------------------------------------------------------------------- private final Map _valueBindingCache = new BiLevelCacheMap(90) { protected Object newInstance(Object key) { return new ValueBindingImpl(ApplicationImpl.this, (String) key); } }; private Collection _supportedLocales = Collections.EMPTY_SET; private Locale _defaultLocale = Locale.getDefault(); private String _messageBundle; private ViewHandler _viewHandler; private NavigationHandler _navigationHandler; private VariableResolver _variableResolver; private PropertyResolver _propertyResolver; private ActionListener _actionListener; private String _defaultRenderKitId; private StateManager _stateManager; // components, converters, and validators can be added at runtime--must synchronize private final Map _converterIdToClassMap = Collections.synchronizedMap(new HashMap()); private final Map _converterClassToClassMap = Collections.synchronizedMap(new HashMap()); private final Map _converterClassNameToConfigurationMap = Collections.synchronizedMap(new HashMap()); private final Map _componentClassMap = Collections.synchronizedMap(new HashMap()); private final Map _validatorClassMap = Collections.synchronizedMap(new HashMap()); //~ Constructors ------------------------------------------------------------------------------- public ApplicationImpl() { // set default implementation in constructor // pragmatic approach, no syncronizing will be needed in get methods _viewHandler = new JspViewHandlerImpl(); _navigationHandler = new NavigationHandlerImpl(); _variableResolver = new VariableResolverImpl(); _propertyResolver = new PropertyResolverImpl(); _actionListener = new ActionListenerImpl(); _defaultRenderKitId = "HTML_BASIC"; _stateManager = new JspStateManagerImpl(); if (log.isTraceEnabled()) log.trace("New Application instance created"); } //~ Methods ------------------------------------------------------------------------------------ public void setActionListener(ActionListener actionListener) { if (actionListener == null) { log.error("setting actionListener to null is not allowed"); throw new NullPointerException("setting actionListener to null is not allowed"); } _actionListener = actionListener; if (log.isTraceEnabled()) log.trace("set actionListener = " + actionListener.getClass().getName()); } public ActionListener getActionListener() { return _actionListener; } public Iterator getComponentTypes() { return _componentClassMap.keySet().iterator(); } public Iterator getConverterIds() { return _converterIdToClassMap.keySet().iterator(); } public Iterator getConverterTypes() { return _converterClassToClassMap.keySet().iterator(); } public void setDefaultLocale(Locale locale) { if (locale == null) { log.error("setting locale to null is not allowed"); throw new NullPointerException("setting locale to null is not allowed"); } _defaultLocale = locale; if (log.isTraceEnabled()) log.trace("set defaultLocale = " + locale.getCountry() + " " + locale.getLanguage()); } public Locale getDefaultLocale() { return _defaultLocale; } public void setMessageBundle(String messageBundle) { if (messageBundle == null) { log.error("setting messageBundle to null is not allowed"); throw new NullPointerException("setting messageBundle to null is not allowed"); } _messageBundle = messageBundle; if (log.isTraceEnabled()) log.trace("set MessageBundle = " + messageBundle); } public String getMessageBundle() { return _messageBundle; } public void setNavigationHandler(NavigationHandler navigationHandler) { if (navigationHandler == null) { log.error("setting navigationHandler to null is not allowed"); throw new NullPointerException("setting navigationHandler to null is not allowed"); } _navigationHandler = navigationHandler; if (log.isTraceEnabled()) log.trace("set NavigationHandler = " + navigationHandler.getClass().getName()); } public NavigationHandler getNavigationHandler() { return _navigationHandler; } public void setPropertyResolver(PropertyResolver propertyResolver) { if (propertyResolver == null) { log.error("setting propertyResolver to null is not allowed"); throw new NullPointerException("setting propertyResolver to null is not allowed"); } _propertyResolver = propertyResolver; if (log.isTraceEnabled()) log.trace("set PropertyResolver = " + propertyResolver.getClass().getName()); } public PropertyResolver getPropertyResolver() { return _propertyResolver; } public void setSupportedLocales(Collection locales) { if (locales == null) { log.error("setting supportedLocales to null is not allowed"); throw new NullPointerException("setting supportedLocales to null is not allowed"); } _supportedLocales = locales; if (log.isTraceEnabled()) log.trace("set SupportedLocales"); } public Iterator getSupportedLocales() { return _supportedLocales.iterator(); } public Iterator getValidatorIds() { return _validatorClassMap.keySet().iterator(); } public void setVariableResolver(VariableResolver variableResolver) { if (variableResolver == null) { log.error("setting variableResolver to null is not allowed"); throw new NullPointerException("setting variableResolver to null is not allowed"); } _variableResolver = variableResolver; if (log.isTraceEnabled()) log.trace("set VariableResolver = " + variableResolver.getClass().getName()); } public VariableResolver getVariableResolver() { return _variableResolver; } public void setViewHandler(ViewHandler viewHandler) { if (viewHandler == null) { log.error("setting viewHandler to null is not allowed"); throw new NullPointerException("setting viewHandler to null is not allowed"); } _viewHandler = viewHandler; if (log.isTraceEnabled()) log.trace("set ViewHandler = " + viewHandler.getClass().getName()); } public ViewHandler getViewHandler() { return _viewHandler; } public void addComponent(String componentType, String componentClassName) { if ((componentType == null) || (componentType.length() == 0)) { log.error("addComponent: componentType = null is not allowed"); throw new NullPointerException("addComponent: componentType = null ist not allowed"); } if ((componentClassName == null) || (componentClassName.length() == 0)) { log.error("addComponent: component = null is not allowed"); throw new NullPointerException("addComponent: component = null is not allowed"); } try { _componentClassMap.put(componentType, ClassUtils.simpleClassForName(componentClassName)); if (log.isTraceEnabled()) log.trace("add Component class = " + componentClassName + " for type = " + componentType); } catch (Exception e) { log.error("Component class " + componentClassName + " not found", e); } } public void addConverter(String converterId, String converterClass) { if ((converterId == null) || (converterId.length() == 0)) { log.error("addConverter: converterId = null is not allowed"); throw new NullPointerException("addConverter: converterId = null ist not allowed"); } if ((converterClass == null) || (converterClass.length() == 0)) { log.error("addConverter: converterClass = null is not allowed"); throw new NullPointerException("addConverter: converterClass = null ist not allowed"); } try { _converterIdToClassMap.put(converterId, ClassUtils.simpleClassForName(converterClass)); if (log.isTraceEnabled()) log.trace("add Converter id = " + converterId + " converterClass = " + converterClass); } catch (Exception e) { log.error("Converter class " + converterClass + " not found", e); } } public void addConverter(Class targetClass, String converterClass) { if ((targetClass == null)) { log.error("addConverter: targetClass = null is not allowed"); throw new NullPointerException("addConverter: targetClass = null ist not allowed"); } if ((converterClass == null) || (converterClass.length() == 0))
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?