001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.servlet.config; 018 019import org.w3c.dom.Element; 020 021import org.springframework.beans.factory.support.AbstractBeanDefinition; 022import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; 023import org.springframework.beans.factory.xml.ParserContext; 024 025/** 026 * Parse the <code><mvc:groovy-configurer></code> MVC namespace element and register a 027 * {@code GroovyConfigurer} bean. 028 * 029 * @author Sebastien Deleuze 030 * @since 4.1 031 */ 032public class GroovyMarkupConfigurerBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { 033 034 /** 035 * The bean name used for the {@code GroovyMarkupConfigurer}. 036 */ 037 public static final String BEAN_NAME = "mvcGroovyMarkupConfigurer"; 038 039 040 @Override 041 protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) { 042 return BEAN_NAME; 043 } 044 045 @Override 046 protected String getBeanClassName(Element element) { 047 return "org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer"; 048 } 049 050 @Override 051 protected boolean isEligibleAttribute(String name) { 052 return (name.equals("auto-indent") || name.equals("cache-templates") || name.equals("resource-loader-path")); 053 } 054 055}