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

📄 applicationimpl.java

📁 Please read your package and describe it at least 40 bytes in English. System will automatically de
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright 2002-2004 the original author or authors. * * 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 de.mindmatters.faces.application;import java.util.Collection;import java.util.Iterator;import java.util.Locale;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.MethodBinding;import javax.faces.el.PropertyResolver;import javax.faces.el.ValueBinding;import javax.faces.el.VariableResolver;import javax.faces.event.ActionListener;import javax.faces.validator.Validator;import org.springframework.beans.factory.BeanFactory;/** * <strong>Application</strong> represents a per-web-application singleton * object where applications based on JavaServer Faces (or implementations * wishing to provide extended functionality) can register application-wide * singletons that provide functionality required by JavaServer Faces. *  * <p> * This implemetation delegates the management and creation of * {@link UIComponent}s, {@link Converter}s, {@link Validator}s and * {@link MethodBinding}s to appropriate factories as follows: *  * <table class="javaDoc"> * <tr> * <th>Methods which delegates to</th> * <th>Factory of type</th> * </tr> * <tr> * <td>{@link Application#addComponent(String, String)}, * {@link Application#addComponent(String, String)}, * {@link Application#addComponent(String, String)}, * {@link Application#addComponent(String, String)}</td> * <td>{@link ComponentFactory}</td> * </tr> * <tr> * <td>{@link Application#addConverter(Class, String)}, * {@link Application#addConverter(String, String)}, * {@link Application#createConverter(Class)}, * {@link Application#createConverter(String)}, * {@link Application#getConverterIds()}, * {@link Application#getConverterTypes()}</td> * <td>{@link ConverterFactory}</td> * </tr> * <tr> * <td>{@link Application#addValidator(String, String)}, * {@link Application#createValidator(String)}, * {@link Application#getValidatorIds()}</td> * <td>{@link ValidatorFactory}</td> * </tr> * <tr> * <td>{@link Application#createMethodBinding(String, Class[])}, * {@link Application#createValueBinding(String)}</td> * <td>{@link MethodBindingFactory}</td> * </tr> * </table> * </p> *  * @author Andreas Kuhrwahl *  */public final class ApplicationImpl extends Application {    /** Name of the MethodBindingFactory bean in the factory. */    public static final String METHOD_BINDING_FACTORY_BEAN_NAME = "methodBindingFactory";    /** Name of the ValidatorFactory bean in the factory. */    public static final String VALIDATOR_FACTORY_BEAN_NAME = "validatorFactory";    /** Name of the ConverterFactory bean in the factory. */    public static final String CONVERTER_FACTORY_BEAN_NAME = "converterFactory";    /** Name of the ComponentFactory bean in the factory. */    public static final String COMPONENT_FACTORY_BEAN_NAME = "componentFactory";    /**     * Default implementation of <strong>ComponentFactory</strong>. Simply     * delegates to the original application of the underlying JSF     * implementation.     *      * @author Andreas Kuhrwahl     *      */    private static class DefaultComponentFactory implements ComponentFactory {        /**         * {@inheritDoc}         */        public void addComponent(final Application application,                final String componentType, final String componentClass) {            application.addComponent(componentType, componentClass);        }        /**         * {@inheritDoc}         */        public UIComponent createComponent(final Application application,                final String componentType) {            return application.createComponent(componentType);        }        /**         * {@inheritDoc}         */        public UIComponent createComponent(final Application application,                final ValueBinding componentBinding,                final FacesContext context, final String componentType) {            return application.createComponent(componentBinding, context,                    componentType);        }        /**         * {@inheritDoc}         */        public Iterator getComponentTypes(final Application application) {            return application.getComponentTypes();        }    }    /**     * Default implementation of <strong>ConverterFactory</strong>. Simply     * delegates to the original application of the underlying JSF     * implementation.     *      * @author Andreas Kuhrwahl     *      */    private static class DefaultConverterFactory implements ConverterFactory {        /**         * {@inheritDoc}         */        public void addConverter(final Application application,                final String converterId, final String converterClass) {            application.addConverter(converterId, converterClass);        }        /**         * {@inheritDoc}         */        public void addConverter(final Application application,                final Class targetClass, final String converterClass) {            application.addConverter(targetClass, converterClass);        }        /**         * {@inheritDoc}         */        public Converter createConverter(final Application application,                final String converterId) {            return application.createConverter(converterId);        }        /**         * {@inheritDoc}         */        public Converter createConverter(final Application application,                final Class targetClass) {            return application.createConverter(targetClass);        }        /**         * {@inheritDoc}         */        public Iterator getConverterIds(final Application application) {            return application.getConverterIds();        }        /**         * {@inheritDoc}         */        public Iterator getConverterTypes(final Application application) {            return application.getConverterTypes();        }    }    /**     * Default implementation of <strong>ValidatorFactory</strong>. Simply     * delegates to the original application of the underlying JSF     * implementation.     *      * @author Andreas Kuhrwahl     *      */    private static class DefaultValidatorFactory implements ValidatorFactory {        /**         * {@inheritDoc}         */        public void addValidator(final Application application,                final String validatorId, final String validatorClass) {            application.addValidator(validatorId, validatorClass);        }        /**         * {@inheritDoc}         */        public Validator createValidator(final Application application,                final String validatorId) {            return application.createValidator(validatorId);        }        /**         * {@inheritDoc}         */        public Iterator getValidatorIds(final Application application) {            return application.getValidatorIds();        }    }    /**     * Default implementation of <strong>MethodBindingFactory</strong>. Simply     * delegates to the original application of the underlying JSF     * implementation.     *      * @author Andreas Kuhrwahl     *      */    private static class DefaultMethodBindingFactory implements            MethodBindingFactory {        /**         * {@inheritDoc}         */        public MethodBinding createMethodBinding(final Application application,                final String ref, final Class[] params) {            return application.createMethodBinding(ref, params);        }        /**         * {@inheritDoc}         */        public ValueBinding createValueBinding(final Application application,                final String ref) {            return application.createValueBinding(ref);        }    }    /** The original application of the underlying JSF implementation. */    private final Application delegate;    /** The ComponentFactory. */    private final ComponentFactory componentFactory;    /** The ConverterFactory. */    private final ConverterFactory converterFactory;    /** The ValidatorFactory. */    private final ValidatorFactory validatorFactory;    /** The MethodBindingFactory. */    private final MethodBindingFactory methodBindingFactory;    /**     * Creates an application with the given original application     * <code>delegate</code>.     *      * @param delegate     *            The original application of the underlying JSF implementation     * @param componentFactory     *            the ComponentFactory     * @param converterFactory     *            the ConverterFactory     * @param validatorFactory     *            the ValidatorFactory     * @param methodBindingFactory     *            the MethodBindingFactory     */    private ApplicationImpl(final Application delegate,            final ComponentFactory componentFactory,            final ConverterFactory converterFactory,            final ValidatorFactory validatorFactory,            final MethodBindingFactory methodBindingFactory) {        super();        if (delegate instanceof ApplicationImpl) {            this.delegate = ((ApplicationImpl) delegate).delegate;        } else {            this.delegate = delegate;        }        this.componentFactory = componentFactory;        this.converterFactory = converterFactory;        this.validatorFactory = validatorFactory;        this.methodBindingFactory = methodBindingFactory;        initComponents();        initConverters();        initValidators();    }    /**     * Component synchronisation.     */    private void initComponents() {        for (Iterator i = this.delegate.getComponentTypes(); i.hasNext();) {            String componentType = (String) i.next();            addComponent(componentType, this.delegate.createComponent(                    componentType).getClass().getName());        }    }    /**     * Converter synchronisation.     */    private void initConverters() {        for (Iterator i = this.delegate.getConverterIds(); i.hasNext();) {            String converterId = (String) i.next();            addConverter(converterId, this.delegate                    .createConverter(converterId).getClass().getName());        }        for (Iterator i = this.delegate.getConverterTypes(); i.hasNext();) {            Class targetClass = (Class) i.next();            addConverter(targetClass, this.delegate                    .createConverter(targetClass).getClass().getName());        }    }

⌨️ 快捷键说明

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