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

📄 delegatingvariableresolver.java

📁 Please read your package and describe it at least 40 bytes in English. System will automatically de
💻 JAVA
字号:
/* * 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.spring.factory;import javax.faces.context.FacesContext;import javax.faces.el.VariableResolver;import org.springframework.beans.BeansException;import org.springframework.beans.factory.BeanFactory;import org.springframework.beans.factory.BeanFactoryAware;/** * <strong>{@link javax.faces.el.VariableResolver}</strong> implementation * that delegates to the internal BeanFactory of the used * {@link org.springframework.web.context.WebApplicationContext} and original * resolver of the underlying JSF implementation to resolve the asked beans or * variables. *  * @author Andreas Kuhrwahl *  * @see ManagedBeanFactory */public final class DelegatingVariableResolver extends VariableResolver        implements BeanFactoryAware {    /**     * The original configured VariableResolver which is used for delegation.     */    private final VariableResolver originalVariableResolver;    /** The BeanFactory this VariableResolver uses for bean resolving. */    private BeanFactory beanFactory;    /**     * Creates a DelegatingVariableResolver with the given VariableResolver     * <code>originalVariableResolver</code>.     *      * @param originalVariableResolver     *            the original resolver of the underlying JSF implementation     */    public DelegatingVariableResolver(            final VariableResolver originalVariableResolver) {        super();        this.originalVariableResolver = originalVariableResolver;    }    /**     * Creates a DelegatingVariableResolver with the given VariableResolver     * <code>originalVariableResolver</code>.     *      * @param originalVariableResolver     *            the original resolver of the underlying JSF implementation     * @param beanFactory     *            The BeanFactory this VariableResolver uses for bean resolving     */    public DelegatingVariableResolver(            final VariableResolver originalVariableResolver,            final BeanFactory beanFactory) {        this(originalVariableResolver);        this.beanFactory = beanFactory;    }    /**     * Checks wether there is a bean with name <code>name</code> in the     * internal BeanFactory of the used     * {@link org.springframework.web.context.WebApplicationContext} and returns     * it. Otherwise delegates to the encapsulated original     * {@link VariableResolver}.     *      * @param context     *            context against which to resolve the bean name     * @param name     *            name of the bean to be resolved     * @return the resolved object     * @throws javax.faces.el.EvaluationException     *             if an exception is thrown while resolving the variable name     *      * @see VariableResolver#resolveVariable(javax.faces.context.FacesContext,     *      java.lang.String)     */    public Object resolveVariable(final FacesContext context, final String name) {        Object bean = null;        boolean beanNotFound = true;        if (this.beanFactory.containsBean(name)) {            beanNotFound = false;            try {                bean = this.beanFactory.getBean(name);            } catch (BeansException ex) {                throw new BeansEvaluationException(ex);            }        }        if (beanNotFound) {            bean = this.originalVariableResolver.resolveVariable(context, name);        }        return bean;    }    /**     * {@inheritDoc}     */    public void setBeanFactory(final BeanFactory beanFactory) {        this.beanFactory = beanFactory;    }    /**     * Returns the encapsulated original VariableResolver of the underlying JSF     * implementation.     *      * @return the original VariableResolver     */    VariableResolver getOriginalVariableResolver() {        return originalVariableResolver;    }}

⌨️ 快捷键说明

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