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

📄 jsfnamespacehandler.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.xml;import java.io.IOException;import java.util.Enumeration;import java.util.Properties;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.beans.BeanUtils;import org.springframework.beans.FatalBeanException;import org.springframework.beans.factory.xml.BeanDefinitionDecorator;import org.springframework.beans.factory.xml.BeanDefinitionParser;import org.springframework.beans.factory.xml.NamespaceHandlerSupport;import org.springframework.core.io.ClassPathResource;import org.springframework.core.io.support.PropertiesLoaderUtils;import org.springframework.util.ClassUtils;import de.mindmatters.faces.spring.JsfSpringConfig;/** * {@link org.springframework.beans.factory.xml.NamespaceHandler} for the '<code>jsh</code>' * namespace. *  * <p> * <strong>Note: For further information regarding the '<code>jsh</code>' * namespace please have a look at <a * href="http://jsf-spring.sourceforge.net/schema/jsf/jsf-spring.xsd" * target="_top">jsf-spring.xsd</a></strong> * </p> *  * @author Andreas Kuhrwahl *  */public final class JsfNameSpaceHandler extends NamespaceHandlerSupport {    /** The parsers for an aspectj-enabled environment. */    private static final String NAMESPACE_AOP_PROPERTIES = "namespace-aop.properties";    /** The parsers for the default environment. */    private static final String NAMESPACE_PROPERTIES = "namespace.properties";    /** For logging. */    private final Log logger = LogFactory.getLog(getClass());    /**     * {@inheritDoc}     */    public void init() {        String parserLocation = NAMESPACE_PROPERTIES;        if (JsfSpringConfig.isAspectJVersionEnabled()) {            parserLocation = NAMESPACE_AOP_PROPERTIES;        }        if (logger.isDebugEnabled()) {            logger.debug("Loading bean definition parsers from ["                    + parserLocation + "].");        }        Properties parsers = null;        try {            parsers = PropertiesLoaderUtils                    .loadProperties(new ClassPathResource(parserLocation, this                            .getClass()));            if (logger.isDebugEnabled()) {                logger.debug("Loaded bean definition parsers: " + parsers);            }        } catch (IOException ex) {            throw new FatalBeanException(                    "Unable to load bean definition parsers from location ["                            + parserLocation + "].", ex);        }        if (parsers != null) {            for (Enumeration e = parsers.propertyNames(); e.hasMoreElements();) {                String namespace = (String) e.nextElement();                String className = parsers.getProperty(namespace);                try {                    Class parserClass = ClassUtils.forName(className);                    Object parser = BeanUtils.instantiateClass(parserClass);                    if (BeanDefinitionParser.class                            .isAssignableFrom(parserClass)) {                        registerBeanDefinitionParser(namespace,                                (BeanDefinitionParser) parser);                    }                    if (BeanDefinitionDecorator.class                            .isAssignableFrom(parserClass)) {                        registerBeanDefinitionDecorator(namespace,                                (BeanDefinitionDecorator) parser);                    }                } catch (ClassNotFoundException ex) {                    if (logger.isDebugEnabled()) {                        logger.debug("Ignoring parser [" + className                                + "]: class not found", ex);                    }                } catch (LinkageError ex) {                    if (logger.isDebugEnabled()) {                        logger                                .debug(                                        "Ignoring parser ["                                                + className                                                + "]: problem with class file or dependent class",                                        ex);                    }                }            }        }    }}

⌨️ 快捷键说明

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