Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 86261 invoked from network); 14 Mar 2008 09:53:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Mar 2008 09:53:57 -0000 Received: (qmail 69283 invoked by uid 500); 14 Mar 2008 09:53:54 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 69259 invoked by uid 500); 14 Mar 2008 09:53:54 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 69250 invoked by uid 99); 14 Mar 2008 09:53:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Mar 2008 02:53:54 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Mar 2008 09:53:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4887F1A9838; Fri, 14 Mar 2008 02:53:36 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r637027 - in /incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring: BusApplicationContext.java ControlledValidationXmlBeanDefinitionReader.java Date: Fri, 14 Mar 2008 09:53:35 -0000 To: cxf-commits@incubator.apache.org From: bimargulies@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080314095336.4887F1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bimargulies Date: Fri Mar 14 02:53:32 2008 New Revision: 637027 URL: http://svn.apache.org/viewvc?rev=637027&view=rev Log: Suppress validation of CXF's spring config files. Add compatible name for validation control variable. Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java (with props) Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java?rev=637027&r1=637026&r2=637027&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java Fri Mar 14 02:53:32 2008 @@ -33,9 +33,11 @@ import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.configuration.Configurer; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.BeansDtdResolver; import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver; import org.springframework.beans.factory.xml.PluggableSchemaResolver; +import org.springframework.beans.factory.xml.ResourceEntityResolver; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -193,7 +195,10 @@ } reader.setNamespaceHandlerResolver(nsHandlerResolver); - String mode = System.getProperty("spring.validation.mode"); + String mode = System.getProperty("org.apache.cxf.spring.validation.mode"); + if (mode == null) { + mode = System.getProperty("spring.validation.mode"); + } if (null != mode) { reader.setValidationModeName(mode); } @@ -206,6 +211,22 @@ ClassLoader cl = Thread.currentThread().getContextClassLoader(); reader.setEntityResolver(new BusEntityResolver(new BeansDtdResolver(), new PluggableSchemaResolver(cl))); + } + @Override + protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException { + // Create a new XmlBeanDefinitionReader for the given BeanFactory. + XmlBeanDefinitionReader beanDefinitionReader = + new ControlledValidationXmlBeanDefinitionReader(beanFactory); + + // Configure the bean definition reader with this context's + // resource loading environment. + beanDefinitionReader.setResourceLoader(this); + beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); + + // Allow a subclass to provide custom initialization of the reader, + // then proceed with actually loading the bean definitions. + initBeanDefinitionReader(beanDefinitionReader); + loadBeanDefinitions(beanDefinitionReader); } } Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java?rev=637027&view=auto ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java (added) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java Fri Mar 14 02:53:32 2008 @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.cxf.bus.spring; + +import java.io.IOException; +import java.net.URL; + +import org.xml.sax.InputSource; + +import org.springframework.beans.factory.BeanDefinitionStoreException; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.core.io.Resource; + +/** + * This is a mutant version of the bean definition reader + * which allows us to avoid validating our internal CXF + * configuration files. + */ +public class ControlledValidationXmlBeanDefinitionReader extends XmlBeanDefinitionReader { + + // Spring has no 'getter' for this. + private int visibleValidationMode = VALIDATION_AUTO; + + /** + * @param beanFactory + */ + public ControlledValidationXmlBeanDefinitionReader(BeanDefinitionRegistry beanFactory) { + super(beanFactory); + } + + @Override + protected int doLoadBeanDefinitions(InputSource inputSource, + Resource resource) throws BeanDefinitionStoreException { + // sadly, the Spring class we are extending has the critical function + // getValidationModeForResource + // marked private instead of protected, so trickery is called for here. + boolean suppressValidation = false; + try { + URL url = resource.getURL(); + if (url.getFile().contains("/META-INF/cxf/")) { + suppressValidation = true; + } + } catch (IOException e) { + // this space intentionally left blank. + } + + int savedValidation = visibleValidationMode; + if (suppressValidation) { + setValidationMode(VALIDATION_NONE); + } + int r = super.doLoadBeanDefinitions(inputSource, resource); + setValidationMode(savedValidation); + return r; + } + + @Override + public void setValidationMode(int validationMode) { + visibleValidationMode = validationMode; + super.setValidationMode(validationMode); + } + +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java ------------------------------------------------------------------------------ svn:keywords = Rev Date