[infinispan-commits] Infinispan SVN: r528 - trunk/core/src/main/java/org/infinispan/config/parsing.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Thu Jul 9 03:57:26 EDT 2009


Author: vblagojevic at jboss.com
Date: 2009-07-09 03:57:25 -0400 (Thu, 09 Jul 2009)
New Revision: 528

Modified:
   trunk/core/src/main/java/org/infinispan/config/parsing/AutomatedXmlConfigurationParserImpl.java
   trunk/core/src/main/java/org/infinispan/config/parsing/CacheLoaderManagerConfigReader.java
Log:
ns

Modified: trunk/core/src/main/java/org/infinispan/config/parsing/AutomatedXmlConfigurationParserImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/AutomatedXmlConfigurationParserImpl.java	2009-07-09 07:38:36 UTC (rev 527)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/AutomatedXmlConfigurationParserImpl.java	2009-07-09 07:57:25 UTC (rev 528)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.infinispan.config.parsing;
 
 import java.io.File;
@@ -34,17 +55,14 @@
  * @author Vladimir Blagojevic
  * @since 4.0
  */
-public class AutomatedXmlConfigurationParserImpl extends XmlParserBase implements XmlConfigurationParser {
+public class AutomatedXmlConfigurationParserImpl extends XmlParserBase implements XmlConfigurationParser {   
+   private static  List<Class<?>> CONFIG_BEANS =null;
    
-   public static List<Class<?>> INFINISPAN_CLASSES = null;
-   public static  List<Class<?>> CONFIG_BEANS =null;
-   
    static {
       String path = System.getProperty("java.class.path") + File.pathSeparator
                + System.getProperty("surefire.test.class.path");
-      try {
-         INFINISPAN_CLASSES = ClassFinder.infinispanClasses();
-         CONFIG_BEANS = ClassFinder.isAssignableFrom(INFINISPAN_CLASSES,AbstractConfigurationBean.class);
+      try {         
+         CONFIG_BEANS = ClassFinder.isAssignableFrom(ClassFinder.infinispanClasses(),AbstractConfigurationBean.class);
       } catch (Exception e) {
          throw new ConfigurationException(
                   "Exception while searching for Infinispan configuration beans, path is " + path,
@@ -114,7 +132,7 @@
             return new Configuration();
          } else {
             defaultElement.normalize();            
-            AbstractConfigurationBean bean = findAndInstantiateBean(CONFIG_BEANS, defaultElement);
+            AbstractConfigurationBean bean = findAndInstantiateBean(defaultElement);
             visitElement(defaultElement, bean);
             return (Configuration) bean;
          }
@@ -137,7 +155,7 @@
                throw new DuplicateCacheNameException("Named cache " + configurationName + " is declared more than once!");
             }
             try {
-               AbstractConfigurationBean bean = findAndInstantiateBean(CONFIG_BEANS, e);
+               AbstractConfigurationBean bean = findAndInstantiateBean(e);
                visitElement(e, bean);               
                namedCaches.put(configurationName,(Configuration) bean);
             } catch (ConfigurationException ce) {
@@ -154,7 +172,7 @@
       if (gc == null) {
          Configuration defaultConfiguration = parseDefaultConfiguration();
          Element globalElement = getSingleElementInCoreNS("global", rootElement);         
-         AbstractConfigurationBean bean = findAndInstantiateBean(CONFIG_BEANS, globalElement);
+         AbstractConfigurationBean bean = findAndInstantiateBean(globalElement);
          visitElement(globalElement, bean);
          gc = (GlobalConfiguration) bean;
          gc.setDefaultConfiguration(defaultConfiguration);
@@ -190,6 +208,10 @@
       return null;
    }
    
+   public AbstractConfigurationBean findAndInstantiateBean(Element e) throws ConfigurationException {
+      return findAndInstantiateBean(CONFIG_BEANS,e);
+   }
+   
    private ConfigurationElement findConfigurationElement(Element e, Class<?> bean) {
       ConfigurationElement ces[] = null;
       ConfigurationElements configurationElements = bean.getAnnotation(ConfigurationElements.class);
@@ -252,10 +274,10 @@
          }
          NodeList nodeList = e.getChildNodes();
          for (int numChildren = nodeList.getLength(), i = 0; i < numChildren; i++) {
-            Node node = nodeList.item(i);
-            if (node instanceof Element) {               
+            Node child = nodeList.item(i);
+            if (child instanceof Element) {               
                // recursive step
-               visitElement((Element) node, bean);
+               visitElement((Element) child, bean);
             }
          }
       }
@@ -275,11 +297,11 @@
                m.invoke(bean, o);
             } catch (Exception ae) {
                throw new ConfigurationException("Illegal attribute value " + attValue + ",type="
-                        + parameterType + ", method=" + m, ae);
+                        + parameterType + ",method=" + m + ",attribute=" + a.name(), ae);
             }
          }
       } else if (isConfigBean) {
-         AbstractConfigurationBean childBean = findAndInstantiateBean(CONFIG_BEANS, node);
+         AbstractConfigurationBean childBean = findAndInstantiateBean(node);
          boolean foundMatchingChild = childBean != null
                   && !bean.getClass().equals(childBean.getClass())
                   && parameterType.isInstance(childBean);

Modified: trunk/core/src/main/java/org/infinispan/config/parsing/CacheLoaderManagerConfigReader.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/CacheLoaderManagerConfigReader.java	2009-07-09 07:38:36 UTC (rev 527)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/CacheLoaderManagerConfigReader.java	2009-07-09 07:57:25 UTC (rev 528)
@@ -44,10 +44,8 @@
       this.parser = parser;
    }
 
-   public void process(Element e, AbstractConfigurationBean bean) {
-      
-      CacheLoaderManagerConfig cBean = (CacheLoaderManagerConfig) parser.findAndInstantiateBean(
-               AutomatedXmlConfigurationParserImpl.CONFIG_BEANS, e);
+   public void process(Element e, AbstractConfigurationBean bean) {      
+      CacheLoaderManagerConfig cBean = (CacheLoaderManagerConfig) parser.findAndInstantiateBean(e);
 
       Set<Element> elements = parser.getAllElementsInCoreNS("loader", e);
       if (elements.isEmpty())
@@ -64,8 +62,7 @@
             cl = (CacheLoader) Util.getInstance(clClass);
             clc = Util.getInstance(cl.getConfigurationClass());
          } catch (Exception ex) {
-            throw new ConfigurationException("Unable to instantiate cache loader or configuration",
-                     ex);
+            throw new ConfigurationException("Unable to instantiate cache loader or configuration",ex);
          }
 
          clc.setCacheLoaderClassName(clClass);




More information about the infinispan-commits mailing list