incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romanst...@apache.org
Subject svn commit: r955861 [1/2] - in /incubator/bval/trunk: ./ bval-core/ bval-core/src/main/java/org/apache/bval/ bval-core/src/main/java/org/apache/bval/routines/ bval-core/src/main/java/org/apache/bval/xml/ bval-core/src/test/java/org/apache/bval/ bval-co...
Date Fri, 18 Jun 2010 07:08:33 GMT
Author: romanstumm
Date: Fri Jun 18 07:08:31 2010
New Revision: 955861

URL: http://svn.apache.org/viewvc?rev=955861&view=rev
Log:
BVAL-69 moved dependency to com.thoughtworks.xstream from bval-core to new optional module bval-xstream.
bval-xstream is optional for bval-jsr303 and mandatory for bval-json

Added:
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java
    incubator/bval/trunk/bval-xstream/
    incubator/bval/trunk/bval-xstream/pom.xml
    incubator/bval/trunk/bval-xstream/src/
    incubator/bval/trunk/bval-xstream/src/main/
    incubator/bval/trunk/bval-xstream/src/main/java/
    incubator/bval/trunk/bval-xstream/src/main/java/org/
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java   (contents, props changed)
      - copied, changed from r952125, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidation.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/NOPValidation.java   (contents, props changed)
      - copied, changed from r952125, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/NOPValidation.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/Reasons.java   (contents, props changed)
      - copied, changed from r952125, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/Reasons.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/MetaBeanEnricher.java   (contents, props changed)
      - copied, changed from r952125, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanEnricher.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMapper.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMapper.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBean.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBean.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanBuilder.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManagerFactory.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanURLLoader.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaElement.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaFeature.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaFeature.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaProperty.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaProperty.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaValidator.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaValidator.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaValidatorReference.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaValidatorReference.java
    incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaValue.java   (contents, props changed)
      - copied, changed from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaValue.java
    incubator/bval/trunk/bval-xstream/src/test/
    incubator/bval/trunk/bval-xstream/src/test/java/
    incubator/bval/trunk/bval-xstream/src/test/java/org/
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/example/
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/example/BusinessEnum.java
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/example/BusinessObject.java
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/example/BusinessObjectAddress.java
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/example/BusinessObjectBeanInfo.java
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/routines/
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/routines/StandardValidationTest.java
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/xml/
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/xml/BeanValidatorTest.java
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/xml/XMLMetaBeanInfosTest.java
    incubator/bval/trunk/bval-xstream/src/test/java/org/apache/bval/xml/XMLMetaBeanManagerTest.java
    incubator/bval/trunk/bval-xstream/src/test/resources/
    incubator/bval/trunk/bval-xstream/src/test/resources/org/
    incubator/bval/trunk/bval-xstream/src/test/resources/org/apache/
    incubator/bval/trunk/bval-xstream/src/test/resources/org/apache/bval/
    incubator/bval/trunk/bval-xstream/src/test/resources/org/apache/bval/example/
    incubator/bval/trunk/bval-xstream/src/test/resources/org/apache/bval/example/test-beanInfos-custom.xml
    incubator/bval/trunk/bval-xstream/src/test/resources/org/apache/bval/example/test-beanInfos.xml
Removed:
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanEnricher.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidation.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/NOPValidation.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/Reasons.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/StandardValidation.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/BeanValidatorTest.java
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/MetaBeanManagerTest.java
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/example/
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/jsr303/
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/routines/
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/xml/
    incubator/bval/trunk/bval-core/src/test/resources/org/
Modified:
    incubator/bval/trunk/bval-core/pom.xml
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/ValidationResults.java
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/model/MetaPropertyTest.java
    incubator/bval/trunk/bval-json/pom.xml
    incubator/bval/trunk/bval-json/src/test/java/org/apache/bval/json/JSONGeneratorTest.java
    incubator/bval/trunk/bval-jsr303/   (props changed)
    incubator/bval/trunk/bval-jsr303/pom.xml
    incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java
    incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java
    incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorConfiguration.java
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/TckReproducerTest.java
    incubator/bval/trunk/pom.xml

Modified: incubator/bval/trunk/bval-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/pom.xml?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/pom.xml (original)
+++ incubator/bval/trunk/bval-core/pom.xml Fri Jun 18 07:08:31 2010
@@ -50,10 +50,6 @@
             <artifactId>commons-beanutils</artifactId>
         </dependency>
         <dependency>
-            <groupId>com.thoughtworks.xstream</groupId>
-            <artifactId>xstream</artifactId>
-        </dependency>
-        <dependency>
             <groupId>commons-collections</groupId>
             <artifactId>commons-collections</artifactId>
         </dependency>

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java (original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java Fri Jun 18 07:08:31 2010
@@ -16,20 +16,21 @@
  */
 package org.apache.bval;
 
-import static org.apache.bval.model.Features.Property.*;
+import org.apache.bval.model.MetaBean;
+import org.apache.bval.model.MetaProperty;
 
 import java.beans.BeanInfo;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.util.Enumeration;
 
-import org.apache.bval.model.MetaBean;
-import org.apache.bval.model.MetaProperty;
+import static org.apache.bval.model.Features.Property.*;
 
 /**
  * Description: use information from java.beans.Introspector in MetaBeans.
  * The PropertyDescriptor can contain info about HIDDEN, PREFERRED, READONLY
  * and other features<br/>
+ * NOTE: THIS IS AN OPTIONAL CLASS, TO ENABLE IT, SET Factory Property apache.bval.enable-introspector="true"
  */
 public final class IntrospectorMetaBeanFactory implements MetaBeanFactory {
 

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java (original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java Fri Jun 18 07:08:31 2010
@@ -18,20 +18,16 @@ package org.apache.bval;
 
 
 import org.apache.bval.model.MetaBean;
-import org.apache.bval.xml.XMLMetaBean;
-import org.apache.bval.xml.XMLMetaBeanFactory;
-import org.apache.bval.xml.XMLMetaBeanInfos;
-import org.apache.bval.xml.XMLMetaBeanLoader;
 import org.apache.commons.lang.ClassUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
 /**
- * Description: internal implementation class to construct metabeans with factories<br/>
+ * Description: internal implementation class to construct 
+ * metabeans with factories<br/>
  */
 public class MetaBeanBuilder {
   private static final Log log = LogFactory.getLog(MetaBeanBuilder.class);
@@ -40,11 +36,10 @@ public class MetaBeanBuilder {
    * here you can install different kinds of factories to create MetaBeans from
    */
   private MetaBeanFactory[] factories;
-  private XMLMetaBeanFactory xmlFactory;
+
 
   public MetaBeanBuilder() {
-    this(new MetaBeanFactory[]{new IntrospectorMetaBeanFactory(),
-        new XMLMetaBeanFactory()});
+    this(new MetaBeanFactory[]{new IntrospectorMetaBeanFactory()});
   }
 
   public MetaBeanBuilder(MetaBeanFactory[] factories) {
@@ -57,22 +52,12 @@ public class MetaBeanBuilder {
 
   public void setFactories(MetaBeanFactory[] factories) {
     this.factories = factories;
-    updateXmlFactory();
   }
 
-  private void updateXmlFactory() {
-    for (MetaBeanFactory each : factories) {
-      if (each instanceof XMLMetaBeanFactory) { // use the first one!
-        xmlFactory = (XMLMetaBeanFactory) each;
-        return;
-      }
-    }
-    xmlFactory = null; // none
+  public MetaBean buildForId(String beanInfoId) throws Exception {
+    throw new IllegalArgumentException("MetaBean " + beanInfoId + " not found");
   }
 
-  public XMLMetaBeanFactory getXmlFactory() {
-    return xmlFactory;
-  }
 /*
     *//** convenience method *//*
     public void addLastFactory(MetaBeanFactory metaBeanFactory) {
@@ -101,122 +86,10 @@ public class MetaBeanBuilder {
         factories[0] = metaBeanFactory;
         updateXmlFactory();
     }*/
-  public void addLoader(XMLMetaBeanLoader loader) {
-    assertXmlFactory();
-    xmlFactory.addLoader(loader);
-  }
-
-  public Map<String, MetaBean> buildAll() throws Exception {
-    final Map<String, MetaBean> all = new HashMap<String, MetaBean>();
-    if (xmlFactory != null) {
-      xmlFactory.visitXMLBeanMeta(null, new XMLMetaBeanFactory.Visitor() {
-        public void visit(XMLMetaBean empty, XMLMetaBeanInfos xmlInfos)
-            throws Exception {
-          if (xmlInfos.getBeans() == null) return; // empty file, ignore
-          XMLMetaBeanFactory.XMLResult carrier =
-              new XMLMetaBeanFactory.XMLResult(null, xmlInfos);
-
-          for (XMLMetaBean xmlMeta : xmlInfos.getBeans()) {
-            MetaBean meta = all.get(xmlMeta.getId());
-            if (meta == null) {
-              meta = createMetaBean(xmlMeta);
-              all.put(xmlMeta.getId(), meta);
-            }
-            carrier.xmlMeta = xmlMeta;
-            xmlFactory.enrichMetaBean(meta, carrier);
-          }
-        }
-
-        public MetaBean getMetaBean() {
-          return null;  // do nothing
-        }
-      });
-    }
-    return all;
-  }
-
-  public Map<String, MetaBean> enrichCopies(Map<String, MetaBean> all,
-                                            XMLMetaBeanInfos... infosArray)
-      throws Exception {
-    assertXmlFactory();
-    final Map<String, MetaBean> copies = new HashMap<String, MetaBean>(all.size());
-    boolean nothing = true;
-    XMLMetaBeanFactory.XMLResult carrier = new XMLMetaBeanFactory.XMLResult();
-    for (XMLMetaBeanInfos xmlMetaBeanInfos : infosArray) {
-      carrier.xmlInfos = xmlMetaBeanInfos;
-      if (xmlMetaBeanInfos == null) continue;
-      try {
-        for (XMLMetaBean xmlMeta : xmlMetaBeanInfos.getBeans()) {
-          nothing = false;
-          MetaBean copy = copies.get(xmlMeta.getId());
-          if (copy == null) { // ist noch nicht kopiert
-            MetaBean meta = all.get(xmlMeta.getId());
-            if (meta == null) { // gibt es nicht
-              copy = createMetaBean(xmlMeta);
-            } else { // gibt es, jetzt kopieren
-              copy = meta.copy();
-            }
-            copies.put(xmlMeta.getId(), copy);
-          }
-          carrier.xmlMeta = xmlMeta;
-          xmlFactory.enrichMetaBean(copy, carrier);
-        }
-      } catch (IOException e) {
-        xmlFactory.handleLoadException(xmlMetaBeanInfos, e);
-      }
-    }
-    if (nothing) return all;
-    for (Map.Entry<String, MetaBean> entry : all.entrySet()) {
-      /*
-      * alle unveraenderten werden AUCH KOPIERT (nur zwar nur, wegen
-      * potentieller CrossReferenzen durch Relationships)
-      */
-      if (!copies.containsKey(entry.getKey())) {
-        if (entry.getValue().hasRelationships()) {
-          copies.put(entry.getKey(), (MetaBean) entry.getValue().copy());
-        } else { // no relationship: do not clone()
-          copies.put(entry.getKey(), entry.getValue());
-        }
-      }
-    }
-    return copies;
-  }
-
-  private void assertXmlFactory() {
-    if (xmlFactory == null) {
-      throw new IllegalStateException("no xmlFactory available");
-    }
-  }
-
-  public MetaBean buildForId(String beanInfoId) throws Exception {
-    final XMLMetaBeanFactory.Visitor v;
-    assertXmlFactory();
-    xmlFactory.visitXMLBeanMeta(beanInfoId, v = new XMLMetaBeanFactory.Visitor() {
-      private MetaBean meta;
-
-      public MetaBean getMetaBean() {
-        return meta;
-      }
-
-      public void visit(XMLMetaBean xmlMeta, XMLMetaBeanInfos xmlInfos)
-          throws Exception {
-        if (meta == null) {
-          meta = createMetaBean(xmlMeta);
-        }
-        xmlFactory.enrichMetaBean(meta,
-            new XMLMetaBeanFactory.XMLResult(xmlMeta, xmlInfos));
-      }
 
 
-    });
-    if (v.getMetaBean() == null) {
-      throw new IllegalArgumentException("MetaBean " + beanInfoId + " not found");
-    }
-    return v.getMetaBean();
-  }
-
-  private MetaBean createMetaBean(XMLMetaBean xmlMeta) throws Exception {
-    return buildForClass(findLocalClass(xmlMeta.getImpl()));
+  public Map<String, MetaBean> buildAll() throws Exception {
+    return new HashMap<String, MetaBean>();
   }
 
   protected Class<?> findLocalClass(String className) {

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java (original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java Fri Jun 18 07:08:31 2010
@@ -16,18 +16,12 @@
  */
 package org.apache.bval;
 
-import static org.apache.bval.model.Features.Property.*;
-
+import org.apache.bval.model.MetaBean;
+import org.apache.bval.model.MetaProperty;
 
 import java.util.Map;
 
-import org.apache.bval.model.MetaBean;
-import org.apache.bval.model.MetaProperty;
-import org.apache.bval.util.PrivilegedActions;
-import org.apache.bval.xml.XMLMetaBeanInfos;
-import org.apache.bval.xml.XMLMetaBeanLoader;
-import org.apache.bval.xml.XMLMetaBeanRegistry;
-import org.apache.bval.xml.XMLMetaBeanURLLoader;
+import static org.apache.bval.model.Features.Property.*;
 
 /**
  * Description: Default implementation for the interface to find, register and
@@ -35,11 +29,11 @@ import org.apache.bval.xml.XMLMetaBeanUR
  * sufficient and you can get this instance from the {@link MetaBeanManagerFactory}.
  * <br/>
  */
-public class MetaBeanManager implements MetaBeanFinder, XMLMetaBeanRegistry, MetaBeanEnricher {
+public class MetaBeanManager implements MetaBeanFinder {
 
     protected final MetaBeanCache cache = new MetaBeanCache();
     protected final MetaBeanBuilder builder;
-    private boolean complete = false;
+    protected boolean complete = false;
 
     public MetaBeanManager() {
         builder = new MetaBeanBuilder();
@@ -49,17 +43,6 @@ public class MetaBeanManager implements 
         this.builder = builder;
     }
 
-    public void addResourceLoader(String resource) {
-        addLoader(new XMLMetaBeanURLLoader(
-              PrivilegedActions.getClassLoader(getClass()).getResource(resource)));
-    }
-
-    public synchronized void addLoader(XMLMetaBeanLoader loader) {
-        builder.addLoader(loader);
-        cache.clear(); // clear because new loaders can affect ALL MetaBeans already created!
-        complete = false;
-    }
-
     public MetaBeanBuilder getBuilder() {
         return builder;
     }
@@ -99,30 +82,6 @@ public class MetaBeanManager implements 
         }
     }
 
-    /**
-     * @param infos - the patches to apply
-     * @return all MetaBeans for classes that have a xml descriptor and
-     *         additional the MetaBeans loaded by the given loaders.
-     *         The given loaders may also return patches for MetaBeans that have
-     *         also been returned by other loaders. The beans with patches for
-     *         references to patched beans will be copied.
-     */
-    public Map<String, MetaBean> enrichCopies(XMLMetaBeanInfos... infos) {
-        Map<String, MetaBean> cached = findAll();
-        try {
-            Map<String, MetaBean> patched = builder.enrichCopies(cached, infos);
-            for (Object oentry : patched.values()) {
-                MetaBean meta = (MetaBean) oentry;
-                computeRelationships(meta, patched);
-            }
-            return patched;
-        } catch (RuntimeException e) {
-            throw e; // do not wrap runtime exceptions
-        } catch (Exception e) {
-            throw new IllegalArgumentException("error enriching beanInfos", e);
-        }
-    }
-
     public MetaBean findForId(String beanInfoId) {
         MetaBean beanInfo = cache.findForId(beanInfoId);
         if (beanInfo != null) return beanInfo;
@@ -177,7 +136,7 @@ public class MetaBeanManager implements 
         }
     }
 
-    private void computeRelationships(MetaBean beanInfo, Map<String, MetaBean> cached) {
+    protected void computeRelationships(MetaBean beanInfo, Map<String, MetaBean> cached) {
         for (MetaProperty prop : beanInfo.getProperties()) {
             String beanRef = (String) prop.getFeature(REF_BEAN_ID);
             if (beanRef != null) {

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java (original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java Fri Jun 18 07:08:31 2010
@@ -16,8 +16,6 @@
  */
 package org.apache.bval;
 
-import org.apache.bval.xml.XMLMetaBeanRegistry;
-
 /**
  * Description: API class to hold a singleton of a {@link MetaBeanManager}
  * that implements the finder and registry interfaces for MetaBeans<br/>
@@ -36,21 +34,6 @@ public class MetaBeanManagerFactory {
         return manager;
     }
 
-    /**
-     * global meta bean registry
-     * @return
-     */
-    public static XMLMetaBeanRegistry getRegistry() {
-        return manager;
-    }
-
-    /**
-     * global meta bean enricher
-     * @return
-     */
-    public static MetaBeanEnricher getEnricher() {
-        return manager;
-    }
 
     /**
      * set global meta bean manager, that is responsible

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/ValidationResults.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/ValidationResults.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/ValidationResults.java (original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/ValidationResults.java Fri Jun 18 07:08:31 2010
@@ -17,12 +17,12 @@
 package org.apache.bval;
 
 
-import java.io.Serializable;
-import java.util.*;
-
 import org.apache.bval.model.ValidationContext;
 import org.apache.bval.model.ValidationListener;
 
+import java.io.Serializable;
+import java.util.*;
+
 /**
  * Description: Implements a contains to hold and transport validation results<br/>
  */
@@ -36,7 +36,7 @@ public class ValidationResults implement
     /**
      * API to add an error to the validation results.
      *
-     * @param reason       - Features from {@link org.apache.bval.routines.Reasons}
+     * @param reason       - Features from {@link org.apache.bval.model.Features.Property}
      *                       or custom reason of validation error
      * @param context        - context information (bean, propertyName, value, ...)
      */
@@ -64,7 +64,7 @@ public class ValidationResults implement
     /**
      * Old API to add an error to the validation results when no context is available.
      *
-     * @param reason       - Features from {@link org.apache.bval.routines.Reasons} or custom validation reason
+     * @param reason       - Features from {@link org.apache.bval.model.Features.Property} or custom validation reason
      * @param bean         - (optional) owner bean or null
      * @param propertyName - (optional) propertyName where valiation error occurred or null
      */

Added: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java?rev=955861&view=auto
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java (added)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidationUtils.java Fri Jun 18 07:08:31 2010
@@ -0,0 +1,59 @@
+/**
+ *  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.bval.routines;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Description: holds the regexp to validate an email address<br>
+ * User: roman.stumm<br>
+ * Date: 17.06.2010<br>
+ * Time: 10:40:59<br>
+ */
+public class EMailValidationUtils {
+  private static String ATOM =
+      "[^\\x00-\\x1F^\\(^\\)^\\<^\\>^\\@^\\,^\\;^\\:^\\\\^\\\"^\\.^\\[^\\]^\\s]";
+  private static String DOMAIN = "(" + ATOM + "+(\\." + ATOM + "+)*";
+  private static String IP_DOMAIN = "\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\]";
+  public static final java.util.regex.Pattern DEFAULT_EMAIL_PATTERN;
+
+  static {
+    DEFAULT_EMAIL_PATTERN = java.util.regex.Pattern.compile(
+        "^" + ATOM + "+(\\." + ATOM + "+)*@"
+            + DOMAIN
+            + "|"
+            + IP_DOMAIN
+            + ")$",
+        java.util.regex.Pattern.CASE_INSENSITIVE
+    );
+  }
+
+  public static boolean isValid(Object value) {
+    return isValid(value, DEFAULT_EMAIL_PATTERN);
+  }
+
+  public static boolean isValid(Object value, Pattern aPattern) {
+    if (value == null) return true;
+    if (!(value instanceof String)) return false;
+    String string = (String) value;
+    if (string.length() == 0) return true;
+    Matcher m = aPattern.matcher(string);
+    return m.matches();
+  }
+
+}

Modified: incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/model/MetaPropertyTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/model/MetaPropertyTest.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/model/MetaPropertyTest.java (original)
+++ incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/model/MetaPropertyTest.java Fri Jun 18 07:08:31 2010
@@ -16,10 +16,6 @@
  */
 package org.apache.bval.model;
 
-import org.apache.bval.example.BusinessEnum;
-import org.apache.bval.model.DynaTypeEnum;
-import org.apache.bval.model.MetaProperty;
-
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -42,9 +38,9 @@ public class MetaPropertyTest extends Te
         prop.setType(String.class);
         assertEquals(String.class, prop.getTypeClass());
         assertEquals(String.class, prop.getType());
-        prop.setType(new DynaTypeEnum(BusinessEnum.class, BusinessEnum.VALUE1.name(),
-              BusinessEnum.VALUE3.name()));
-        assertEquals(BusinessEnum.class, prop.getTypeClass());
+        prop.setType(new DynaTypeEnum(ExampleEnum.class, ExampleEnum.VALUE1.name(),
+              ExampleEnum.VALUE3.name()));
+        assertEquals(ExampleEnum.class, prop.getTypeClass());
         assertEquals(2, ((DynaTypeEnum)prop.getType()).getEnumConstants().length);
     }
 

Modified: incubator/bval/trunk/bval-json/pom.xml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-json/pom.xml?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-json/pom.xml (original)
+++ incubator/bval/trunk/bval-json/pom.xml Fri Jun 18 07:08:31 2010
@@ -42,6 +42,10 @@
             <artifactId>bval-core</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.bval</groupId>
+            <artifactId>bval-xstream</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.freemarker</groupId>
             <artifactId>freemarker</artifactId>
         </dependency>
@@ -56,6 +60,12 @@
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.bval</groupId>
+            <artifactId>bval-xstream</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

Modified: incubator/bval/trunk/bval-json/src/test/java/org/apache/bval/json/JSONGeneratorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-json/src/test/java/org/apache/bval/json/JSONGeneratorTest.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-json/src/test/java/org/apache/bval/json/JSONGeneratorTest.java (original)
+++ incubator/bval/trunk/bval-json/src/test/java/org/apache/bval/json/JSONGeneratorTest.java Fri Jun 18 07:08:31 2010
@@ -17,13 +17,13 @@
 package org.apache.bval.json;
 
 import junit.framework.TestCase;
-import org.apache.bval.MetaBeanManager;
 import org.apache.bval.example.BusinessEnum;
 import org.apache.bval.example.BusinessObject;
 import org.apache.bval.example.BusinessObjectAddress;
 import org.apache.bval.model.DynaTypeEnum;
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.MetaProperty;
+import org.apache.bval.xml.XMLMetaBeanManager;
 import org.apache.bval.xml.XMLMetaBeanURLLoader;
 
 import java.util.ArrayList;
@@ -34,7 +34,7 @@ import java.util.List;
  * Author: roman.stumm<br>
  */
 public class JSONGeneratorTest extends TestCase {
-  private MetaBeanManager mbm;
+  private XMLMetaBeanManager mbm;
 
   public JSONGeneratorTest(String name) {
     super(name);
@@ -42,8 +42,8 @@ public class JSONGeneratorTest extends T
 
   public void setUp() throws Exception {
     super.setUp();
-    mbm = new MetaBeanManager();
-    mbm.getBuilder().addLoader(new XMLMetaBeanURLLoader(
+    mbm = new XMLMetaBeanManager();
+    mbm.addLoader(new XMLMetaBeanURLLoader(
         BusinessObject.class.getResource("test-beanInfos.xml")));
   }
 
@@ -54,7 +54,7 @@ public class JSONGeneratorTest extends T
     assertTrue(mprop.isMandatory());
 
     mbm.getCache().removeFromCache(mbean);
-    mbm.getBuilder().addLoader(new XMLMetaBeanURLLoader(
+    mbm.addLoader(new XMLMetaBeanURLLoader(
         BusinessObject.class.getResource("test-beanInfos-custom.xml")));
     mbean = mbm.findForClass(BusinessObject.class);
     mprop = mbean.getProperty("lastName");

Propchange: incubator/bval/trunk/bval-jsr303/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jun 18 07:08:31 2010
@@ -1,4 +1,3 @@
-*.log
-.*
 target
+.*
 maven-eclipse.xml

Modified: incubator/bval/trunk/bval-jsr303/pom.xml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/pom.xml?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/pom.xml (original)
+++ incubator/bval/trunk/bval-jsr303/pom.xml Fri Jun 18 07:08:31 2010
@@ -103,6 +103,11 @@
             <artifactId>bval-core</artifactId>
         </dependency>
         <dependency>
+          <groupId>org.apache.bval</groupId>
+          <artifactId>bval-xstream</artifactId>
+          <optional>true</optional>
+        </dependency>
+        <dependency>
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
         </dependency>

Modified: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java (original)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/constraints/EmailValidator.java Fri Jun 18 07:08:31 2010
@@ -18,10 +18,11 @@
  */
 package org.apache.bval.constraints;
 
+import org.apache.bval.routines.EMailValidationUtils;
+
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
 
-import org.apache.bval.routines.EMailValidation;
 
 /**
  * Description: <br/>
@@ -29,7 +30,7 @@ import org.apache.bval.routines.EMailVal
 public class EmailValidator implements ConstraintValidator<Email, String> {
 
     public boolean isValid(String value, ConstraintValidatorContext context) {
-        return EMailValidation.isValid(value);
+        return EMailValidationUtils.isValid(value);
     }
 
     public void initialize(Email parameters) {

Modified: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java (original)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java Fri Jun 18 07:08:31 2010
@@ -19,7 +19,9 @@
 package org.apache.bval.jsr303;
 
 import org.apache.bval.*;
+import org.apache.bval.xml.XMLMetaBeanBuilder;
 import org.apache.bval.xml.XMLMetaBeanFactory;
+import org.apache.bval.xml.XMLMetaBeanManager;
 
 import javax.validation.*;
 import java.util.ArrayList;
@@ -100,8 +102,9 @@ public class ApacheFactoryContext implem
      * Create MetaBeanManager that
      * uses JSR303-XML + JSR303-Annotations
      * to build meta-data from.
+     * @return a new instance of MetaBeanManager with adequate MetaBeanFactories
      */
-    private MetaBeanManager buildMetaBeanManager() {
+    protected MetaBeanManager buildMetaBeanManager() {
         // this is relevant: xml before annotations
         // (because ignore-annotations settings in xml)
         List<MetaBeanFactory> builders = new ArrayList<MetaBeanFactory>(3);
@@ -110,16 +113,23 @@ public class ApacheFactoryContext implem
             builders.add(new IntrospectorMetaBeanFactory());
         }
         builders.add(new Jsr303MetaBeanFactory(this));
-      /**
-       * TODO RSt - decide whether to move proprietary XMLMetaBeanFactory support (currently handled with XStream) out of the core:
-       *  get rid of XStream dependency and package org.apache.bval.xml in core
-       *  this would also require a split in MetaBeanManager and MetaBeanBuilder, because parts of the code deal with classes in this package  
-       */
+        // as long as we support both: jsr303 and xstream-xml metabeans:
         if (Boolean.parseBoolean(factory.getProperties().get(
               ApacheValidatorConfiguration.Properties.ENABLE_METABEANS_XML))) {
-            builders.add(new XMLMetaBeanFactory());
+          return createXMLMetaBeanManager(builders);
+        } else {
+          return createMetaBeanManager(builders);
         }
-        return new MetaBeanManager(
-              new MetaBeanBuilder(builders.toArray(new MetaBeanFactory[builders.size()])));
     }
+
+  protected MetaBeanManager createMetaBeanManager(List<MetaBeanFactory> builders) {
+    return new MetaBeanManager(
+      new MetaBeanBuilder(builders.toArray(new MetaBeanFactory[builders.size()])));
+  }
+
+  protected MetaBeanManager createXMLMetaBeanManager(List<MetaBeanFactory> builders) {
+    builders.add(new XMLMetaBeanFactory());
+    return new XMLMetaBeanManager(
+        new XMLMetaBeanBuilder(builders.toArray(new MetaBeanFactory[builders.size()])));
+  }
 }
\ No newline at end of file

Modified: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorConfiguration.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorConfiguration.java (original)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorConfiguration.java Fri Jun 18 07:08:31 2010
@@ -51,6 +51,10 @@ public interface ApacheValidatorConfigur
          * true/false. use apache metaBeans xml format additionally to
          * build metadata with JSR303.
          * default: false
+         *
+         * @deprecated we could decide to drop this feature in the future.
+         * we keep it as long as we support both: jsr303 and xstream-xml meta data at
+         * the same time (and potentially for the same domain classes)
          */
         String ENABLE_METABEANS_XML = "apache.bval.enable-metabeans-xml";
 

Modified: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/TckReproducerTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/TckReproducerTest.java?rev=955861&r1=955860&r2=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/TckReproducerTest.java (original)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/TckReproducerTest.java Fri Jun 18 07:08:31 2010
@@ -32,7 +32,6 @@ import java.util.Set;
  * User: roman.stumm<br>
  * Date: 21.04.2010<br>
  * Time: 14:21:45<br>
- * viaboxx GmbH, 2010
  */
 public class TckReproducerTest extends TestCase {
 

Added: incubator/bval/trunk/bval-xstream/pom.xml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/pom.xml?rev=955861&view=auto
==============================================================================
--- incubator/bval/trunk/bval-xstream/pom.xml (added)
+++ incubator/bval/trunk/bval-xstream/pom.xml Fri Jun 18 07:08:31 2010
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!--
+	Maven release plugin requires the project tag to be on a single line.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.bval</groupId>
+    <artifactId>bval-parent</artifactId>
+    <version>0.2-incubating-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>bval-xstream</artifactId>
+  <name>Apache Bean Validation :: bval-xstream</name>
+  <packaging>jar</packaging>
+
+  <description>Bean Validation XML Metadata with XStream</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.bval</groupId>
+      <artifactId>bval-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.thoughtworks.xstream</groupId>
+      <artifactId>xstream</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <!-- create mainClass attribute -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>default-jar</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+            <configuration>
+              <archive>
+                <manifest>
+                  <mainClass>org.apache.bval.util.BeanValidationVersion</mainClass>
+                </manifest>
+              </archive>
+            </configuration>
+          </execution>
+          <execution>
+            <id>attach-tests</id>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
+

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java (from r952125, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidation.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidation.java&r1=952125&r2=955861&rev=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/EMailValidation.java (original)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java Fri Jun 18 07:08:31 2010
@@ -21,38 +21,18 @@ import org.apache.bval.model.Validation;
 import org.apache.bval.model.ValidationContext;
 import org.apache.bval.model.ValidationListener;
 
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 /**
  * Description: example validation for email addresses using a regular expression<br/>
- * 
- * TODO RSt - could become part of optional module, depends on proprietary XML
- * support only (package org.apache.bval.xml)
  */
 public class EMailValidation implements Validation {
-    private static String ATOM =
-            "[^\\x00-\\x1F^\\(^\\)^\\<^\\>^\\@^\\,^\\;^\\:^\\\\^\\\"^\\.^\\[^\\]^\\s]";
-    private static String DOMAIN = "(" + ATOM + "+(\\." + ATOM + "+)*";
-    private static String IP_DOMAIN = "\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\]";
-    private static final java.util.regex.Pattern DEFAULT_PATTERN;
-
-    static {
-        DEFAULT_PATTERN = java.util.regex.Pattern.compile(
-                "^" + ATOM + "+(\\." + ATOM + "+)*@"
-                        + DOMAIN
-                        + "|"
-                        + IP_DOMAIN
-                        + ")$",
-                java.util.regex.Pattern.CASE_INSENSITIVE
-        );
-    }
 
-    private java.util.regex.Pattern pattern = DEFAULT_PATTERN;
+    private java.util.regex.Pattern pattern = EMailValidationUtils.DEFAULT_EMAIL_PATTERN;
 
     public <T extends ValidationListener> void validate(ValidationContext<T> context) {
         if (context.getPropertyValue() == null) return;
-        if (!isValid(context.getPropertyValue(), pattern)) {
+        if (!EMailValidationUtils.isValid(context.getPropertyValue(), getPattern())) {
             context.getListener().addError(Reasons.EMAIL_ADDRESS, context);
         }
     }
@@ -65,17 +45,4 @@ public class EMailValidation implements 
         this.pattern = pattern;
     }
 
-    public static boolean isValid(Object value) {
-        return isValid(value, DEFAULT_PATTERN);
-    }
-
-    private static boolean isValid(Object value, Pattern aPattern) {
-        if (value == null) return true;
-        if (!(value instanceof String)) return false;
-        String string = (String) value;
-        if (string.length() == 0) return true;
-        Matcher m = aPattern.matcher(string);
-        return m.matches();
-    }
-
 }

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/EMailValidation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/NOPValidation.java (from r952125, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/NOPValidation.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/NOPValidation.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/NOPValidation.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/NOPValidation.java&r1=952125&r2=955861&rev=955861&view=diff
==============================================================================
    (empty)

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/NOPValidation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/NOPValidation.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/NOPValidation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/Reasons.java (from r952125, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/Reasons.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/Reasons.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/Reasons.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/routines/Reasons.java&r1=952125&r2=955861&rev=955861&view=diff
==============================================================================
    (empty)

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/Reasons.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/Reasons.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/Reasons.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java?rev=955861&view=auto
==============================================================================
--- incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java (added)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/routines/StandardValidation.java Fri Jun 18 07:08:31 2010
@@ -0,0 +1,173 @@
+/**
+ *  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.bval.routines;
+
+import org.apache.bval.model.*;
+import org.apache.bval.xml.XMLMetaValue;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import static org.apache.bval.routines.Reasons.*;
+
+/**
+ * Description: This class implements the standard validations for properties!
+ * You can subclass this class and replace the implementation
+ * in the beanInfo-xml by providing it a validation "standard"<br/>
+ * 
+ */
+public class StandardValidation implements Validation {
+
+    /** key for this validation in the validation list of the beanInfos */
+    public String getValidationId() {
+        return "standard";
+    }
+
+    public <T extends ValidationListener> void validate(ValidationContext<T> context) {
+        validateMandatory(context);
+        validateMaxLength(context);
+        validateMinLength(context);
+        validateMaxValue(context);
+        validateMinValue(context);
+        validateRegExp(context);
+        validateTimeLag(context);
+    }
+
+    protected <T extends ValidationListener> void validateTimeLag(ValidationContext<T> context) {
+        String lag = (String) context.getMetaProperty().getFeature(TIME_LAG);
+        if (lag == null) return;
+        if (context.getPropertyValue() == null) return;
+        long date = ((Date) context.getPropertyValue()).getTime();
+        long now = System.currentTimeMillis();
+        if (XMLMetaValue.TIMELAG_Future.equals(lag)) {
+            if (date < now) {
+                context.getListener().addError(TIME_LAG, context);
+            }
+        } else if (XMLMetaValue.TIMELAG_Past.equals(lag)) {
+            if (date > now) {
+                context.getListener().addError(TIME_LAG, context);
+            }
+        } else {
+            throw new IllegalArgumentException("unknown timelag " + lag + " at " + context);
+        }
+    }
+
+    private static final String REG_EXP_PATTERN = "cachedRegExpPattern";
+
+    protected <T extends ValidationListener> void validateRegExp(ValidationContext<T> context) {
+        final MetaProperty meta = context.getMetaProperty();
+        final String regExp = (String) meta.getFeature(REG_EXP);
+        if (regExp == null) return;
+        if (context.getPropertyValue() == null) return;
+
+        final String value = String.valueOf(context.getPropertyValue());
+        try {
+            Pattern pattern = (Pattern) meta.getFeature(REG_EXP_PATTERN);
+            if (pattern == null) {
+                pattern = Pattern.compile(regExp);
+                meta.putFeature(REG_EXP_PATTERN, pattern);
+            }
+            if (!pattern.matcher(value).matches()) {
+                context.getListener().addError(REG_EXP, context);
+            }
+        } catch (PatternSyntaxException e) {
+            throw new IllegalArgumentException(
+                  "regular expression malformed. regexp " + regExp + " at " + context, e);
+        }
+    }
+
+    protected <T extends ValidationListener> void validateMinValue(ValidationContext<T> context) {
+        Comparable<Object> minValue = (Comparable<Object>) context.getMetaProperty().getFeature(MIN_VALUE);
+        if (minValue == null || context.getPropertyValue() == null) return;
+        if (compare(context, minValue, context.getPropertyValue()) > 0) {
+            context.getListener().addError(MIN_VALUE, context);
+        }
+    }
+
+    protected <T extends ValidationListener> void validateMaxValue(ValidationContext<T> context) {
+        Comparable<Object> maxValue = (Comparable<Object>) context.getMetaProperty().getFeature(MAX_VALUE);
+        if (maxValue == null || context.getPropertyValue() == null) return;
+        if (compare(context, maxValue, context.getPropertyValue()) < 0) {
+            context.getListener().addError(MAX_VALUE, context);
+        }
+    }
+
+    private <T extends ValidationListener> int compare(ValidationContext<T> context, Comparable<Object> constraintValue,
+                        Object currentValue) {
+        int r;
+        if (constraintValue.getClass().isAssignableFrom(currentValue.getClass())) {
+            r = constraintValue.compareTo(context.getPropertyValue());
+        } else if (currentValue instanceof Number) {
+            double dv = ((Number) currentValue).doubleValue();
+            double mdv = ((Number) constraintValue).doubleValue();
+            r = mdv > dv ? 1 : -1;
+        } else {
+            r = String.valueOf(constraintValue).compareTo(String.valueOf(currentValue));
+        }
+        return r;
+    }
+
+    protected <T extends ValidationListener> void validateMaxLength(ValidationContext<T> context) {
+        Integer maxLength = (Integer) context.getMetaProperty()
+              .getFeature(Features.Property.MAX_LENGTH);
+        if (maxLength == null) return;
+        if (context.getPropertyValue() == null) return;
+
+        final Object value = context.getPropertyValue();
+        int length = 0;
+        if (value instanceof String) {
+            length = ((String) value).length();
+        } else if (value instanceof Collection<?>) {
+            length = ((Collection<?>) value).size();
+        }
+        if (length > maxLength) {
+            context.getListener().addError(MAX_LENGTH, context);
+        }
+    }
+
+    protected <T extends ValidationListener> void validateMinLength(ValidationContext<T> context) {
+        Integer maxLength = (Integer) context.getMetaProperty()
+              .getFeature(Features.Property.MIN_LENGTH);
+        if (maxLength == null) return;
+        if (context.getPropertyValue() == null) return;
+
+        final Object value = context.getPropertyValue();
+        int length = 0;
+        if (value instanceof String) {
+            length = ((String) value).length();
+        } else if (value instanceof Collection<?>) {
+            length = ((Collection<?>) value).size();
+        }
+        if (length < maxLength) {
+            context.getListener().addError(MIN_LENGTH, context);
+        }
+    }
+
+    protected <T extends ValidationListener> void validateMandatory(ValidationContext<T> context) {
+        if (context.getMetaProperty().isMandatory()) {
+            if (context.getPropertyValue() == null) {
+                context.getListener().addError(MANDATORY, context);
+            }
+        }
+    }
+
+    public static StandardValidation getInstance() {
+        return new StandardValidation();
+    }
+}

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/MetaBeanEnricher.java (from r952125, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanEnricher.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/MetaBeanEnricher.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/MetaBeanEnricher.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanEnricher.java&r1=952125&r2=955861&rev=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/MetaBeanEnricher.java (original)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/MetaBeanEnricher.java Fri Jun 18 07:08:31 2010
@@ -14,13 +14,12 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.bval;
+package org.apache.bval.xml;
 
 
-import java.util.Map;
-
 import org.apache.bval.model.MetaBean;
-import org.apache.bval.xml.XMLMetaBeanInfos;
+
+import java.util.Map;
 
 /**
  * Description: Interface to merge meta beans<br/>

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/MetaBeanEnricher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/MetaBeanEnricher.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/MetaBeanEnricher.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java (original)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java Fri Jun 18 07:08:31 2010
@@ -17,13 +17,12 @@
 package org.apache.bval.xml;
 
 import com.thoughtworks.xstream.annotations.XStreamImplicit;
+import org.apache.bval.model.FeaturesCapable;
 
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.bval.model.FeaturesCapable;
-
 /**
  * Description: <br/>
  */

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLFeaturesCapable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMapper.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMapper.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMapper.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMapper.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMapper.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
    (empty)

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMapper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBean.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBean.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBean.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBean.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBean.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
    (empty)

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanBuilder.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanBuilder.java?rev=955861&view=auto
==============================================================================
--- incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanBuilder.java (added)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanBuilder.java Fri Jun 18 07:08:31 2010
@@ -0,0 +1,184 @@
+/**
+ *  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.bval.xml;
+
+import org.apache.bval.IntrospectorMetaBeanFactory;
+import org.apache.bval.MetaBeanBuilder;
+import org.apache.bval.MetaBeanFactory;
+import org.apache.bval.model.MetaBean;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Description: <br>
+ * User: roman.stumm<br>
+ * Date: 17.06.2010<br>
+ * Time: 10:10:46<br>
+ */
+public class XMLMetaBeanBuilder extends MetaBeanBuilder {
+  private XMLMetaBeanFactory xmlFactory;
+
+
+  public XMLMetaBeanBuilder(MetaBeanFactory[] factories) {
+    setFactories(factories);
+  }
+
+  public XMLMetaBeanBuilder() {
+    setFactories(new MetaBeanFactory[]{new IntrospectorMetaBeanFactory(),
+        new XMLMetaBeanFactory()});
+  }
+
+  public void setFactories(MetaBeanFactory[] factories) {
+    super.setFactories(factories);
+    updateXmlFactory();
+  }
+
+  public void addLoader(XMLMetaBeanLoader loader) {
+    assertXmlFactory();
+    xmlFactory.addLoader(loader);
+  }
+
+  public MetaBean buildForId(String beanInfoId) throws Exception {
+    final XMLMetaBeanFactory.Visitor v;
+    assertXmlFactory();
+    xmlFactory.visitXMLBeanMeta(beanInfoId, v = new XMLMetaBeanFactory.Visitor() {
+      private MetaBean meta;
+
+      public MetaBean getMetaBean() {
+        return meta;
+      }
+
+      public void visit(XMLMetaBean xmlMeta, XMLMetaBeanInfos xmlInfos)
+          throws Exception {
+        if (meta == null) {
+          meta = createMetaBean(xmlMeta);
+        }
+        xmlFactory.enrichMetaBean(meta,
+            new XMLMetaBeanFactory.XMLResult(xmlMeta, xmlInfos));
+      }
+
+
+    });
+    if (v.getMetaBean() == null) {
+      throw new IllegalArgumentException("MetaBean " + beanInfoId + " not found");
+    }
+    return v.getMetaBean();
+  }
+
+  public Map<String, MetaBean> buildAll() throws Exception {
+    final Map<String, MetaBean> all = super.buildAll();
+    if (xmlFactory != null) {
+      xmlFactory.visitXMLBeanMeta(null, new XMLMetaBeanFactory.Visitor() {
+        public void visit(XMLMetaBean empty, XMLMetaBeanInfos xmlInfos)
+            throws Exception {
+          if (xmlInfos.getBeans() == null) return; // empty file, ignore
+          XMLMetaBeanFactory.XMLResult carrier =
+              new XMLMetaBeanFactory.XMLResult(null, xmlInfos);
+
+          for (XMLMetaBean xmlMeta : xmlInfos.getBeans()) {
+            MetaBean meta = all.get(xmlMeta.getId());
+            if (meta == null) {
+              meta = createMetaBean(xmlMeta);
+              all.put(xmlMeta.getId(), meta);
+            }
+            carrier.xmlMeta = xmlMeta;
+            xmlFactory.enrichMetaBean(meta, carrier);
+          }
+        }
+
+        public MetaBean getMetaBean() {
+          return null;  // do nothing
+        }
+      });
+    }
+    return all;
+  }
+
+  public Map<String, MetaBean> enrichCopies(Map<String, MetaBean> all,
+                                            XMLMetaBeanInfos... infosArray)
+      throws Exception {
+    assertXmlFactory();
+    final Map<String, MetaBean> copies = new HashMap<String, MetaBean>(all.size());
+    boolean nothing = true;
+    XMLMetaBeanFactory.XMLResult carrier = new XMLMetaBeanFactory.XMLResult();
+    for (XMLMetaBeanInfos xmlMetaBeanInfos : infosArray) {
+      carrier.xmlInfos = xmlMetaBeanInfos;
+      if (xmlMetaBeanInfos == null) continue;
+      try {
+        for (XMLMetaBean xmlMeta : xmlMetaBeanInfos.getBeans()) {
+          nothing = false;
+          MetaBean copy = copies.get(xmlMeta.getId());
+          if (copy == null) { // ist noch nicht kopiert
+            MetaBean meta = all.get(xmlMeta.getId());
+            if (meta == null) { // gibt es nicht
+              copy = createMetaBean(xmlMeta);
+            } else { // gibt es, jetzt kopieren
+              copy = meta.copy();
+            }
+            copies.put(xmlMeta.getId(), copy);
+          }
+          carrier.xmlMeta = xmlMeta;
+          xmlFactory.enrichMetaBean(copy, carrier);
+        }
+      } catch (IOException e) {
+        xmlFactory.handleLoadException(xmlMetaBeanInfos, e);
+      }
+    }
+    if (nothing) return all;
+    for (Map.Entry<String, MetaBean> entry : all.entrySet()) {
+      /*
+      * alle unveraenderten werden AUCH KOPIERT (nur zwar nur, wegen
+      * potentieller CrossReferenzen durch Relationships)
+      */
+      if (!copies.containsKey(entry.getKey())) {
+        if (entry.getValue().hasRelationships()) {
+          copies.put(entry.getKey(), (MetaBean) entry.getValue().copy());
+        } else { // no relationship: do not clone()
+          copies.put(entry.getKey(), entry.getValue());
+        }
+      }
+    }
+    return copies;
+  }
+
+  private MetaBean createMetaBean(XMLMetaBean xmlMeta) throws Exception {
+    return buildForClass(findLocalClass(xmlMeta.getImpl()));
+  }
+
+  private void updateXmlFactory() {
+    for (MetaBeanFactory each : getFactories()) {
+      if (each instanceof XMLMetaBeanFactory) { // use the first one!
+        xmlFactory = (XMLMetaBeanFactory) each;
+        return;
+      }
+    }
+    xmlFactory = null; // none
+  }
+
+  public XMLMetaBeanFactory getXmlFactory() {
+    return xmlFactory;
+  }
+
+  private void assertXmlFactory() {
+    if (xmlFactory == null) {
+      throw new IllegalStateException("no xmlFactory available");
+    }
+  }
+}
+

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
    (empty)

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java (original)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java Fri Jun 18 07:08:31 2010
@@ -20,7 +20,6 @@ import com.thoughtworks.xstream.annotati
 import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
 import com.thoughtworks.xstream.annotations.XStreamImplicit;
 import com.thoughtworks.xstream.annotations.XStreamOmitField;
-
 import org.apache.bval.model.Validation;
 import org.apache.commons.collections.FastHashMap;
 import org.apache.commons.lang.ClassUtils;

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
    (empty)

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java?rev=955861&view=auto
==============================================================================
--- incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java (added)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java Fri Jun 18 07:08:31 2010
@@ -0,0 +1,79 @@
+/**
+ *  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.bval.xml;
+
+import org.apache.bval.MetaBeanManager;
+import org.apache.bval.model.MetaBean;
+import org.apache.bval.util.PrivilegedActions;
+
+import java.util.Map;
+
+/**
+ * Description: internal implementation class to construct
+ * metabeans with factories and from xstream xml files.
+ * You can register different XMLMetaBeanLoaders (see addLoader()) to register xstream-xml-files that
+ * contain meta-data.
+ * You can merge + unify meta data with method enrichCopies().
+ * <br/>
+ * User: roman.stumm<br>
+ * Date: 17.06.2010<br>
+ * Time: 09:47:14<br>
+ */
+public class XMLMetaBeanManager extends MetaBeanManager implements XMLMetaBeanRegistry, MetaBeanEnricher {
+  public XMLMetaBeanManager() {
+    this(new XMLMetaBeanBuilder());
+  }
+
+  public XMLMetaBeanManager(XMLMetaBeanBuilder builder) {
+    super(builder);
+  }
+
+  public void addResourceLoader(String resource) {
+    addLoader(new XMLMetaBeanURLLoader(
+        PrivilegedActions.getClassLoader(getClass()).getResource(resource)));
+  }
+
+  public synchronized void addLoader(XMLMetaBeanLoader loader) {
+    ((XMLMetaBeanBuilder)builder).addLoader(loader);
+    cache.clear(); // clear because new loaders can affect ALL MetaBeans already created!
+    complete = false;
+  }
+
+  /**
+   * @param infos - the patches to apply
+   * @return all MetaBeans for classes that have a xml descriptor and
+   *         additional the MetaBeans loaded by the given loaders.
+   *         The given loaders may also return patches for MetaBeans that have
+   *         also been returned by other loaders. The beans with patches for
+   *         references to patched beans will be copied.
+   */
+  public Map<String, MetaBean> enrichCopies(XMLMetaBeanInfos... infos) {
+    Map<String, MetaBean> cached = findAll();
+    try {
+      Map<String, MetaBean> patched = ((XMLMetaBeanBuilder)builder).enrichCopies(cached, infos);
+      for (Object entry : patched.values()) {
+        MetaBean meta = (MetaBean) entry;
+        computeRelationships(meta, patched);
+      }
+      return patched;
+    } catch (RuntimeException e) {
+      throw e; // do not wrap runtime exceptions
+    } catch (Exception e) {
+      throw new IllegalArgumentException("error enriching beanInfos", e);
+    }
+  }
+}

Added: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManagerFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManagerFactory.java?rev=955861&view=auto
==============================================================================
--- incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManagerFactory.java (added)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManagerFactory.java Fri Jun 18 07:08:31 2010
@@ -0,0 +1,62 @@
+/**
+ *  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.bval.xml;
+
+import org.apache.bval.MetaBeanFinder;
+
+/**
+ * Description: <br>
+ * User: roman.stumm<br>
+ * Date: 17.06.2010<br>
+ * Time: 10:06:37<br>
+ */
+public class XMLMetaBeanManagerFactory {
+    private static XMLMetaBeanManager manager = new XMLMetaBeanManager();
+     /**
+     * global meta bean finder.
+     * @return
+     */
+    public static MetaBeanFinder getFinder() {
+        return manager;
+    }
+
+
+    /**
+     * set global meta bean manager, that is responsible
+     * for finding, caching, xml registry and enrichment algorithm.
+     * @param finder
+     */
+    public static void setManager(XMLMetaBeanManager finder) {
+        manager = finder;
+    }
+
+    /**
+     * global meta bean registry
+     * @return
+     */
+    public static XMLMetaBeanRegistry getRegistry() {
+        return manager;
+    }
+
+    /**
+     * global meta bean enricher
+     * @return
+     */
+    public static MetaBeanEnricher getEnricher() {
+        return manager;
+    }
+}

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java (original)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java Fri Jun 18 07:08:31 2010
@@ -16,12 +16,11 @@
  */
 package org.apache.bval.xml;
 
-import static org.apache.bval.model.Features.Property.REF_BEAN_ID;
-
-import org.apache.bval.model.MetaProperty;
-
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
+import org.apache.bval.model.MetaProperty;
+
+import static org.apache.bval.model.Features.Property.REF_BEAN_ID;
 
 /**
  * Description: <br/>

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanReference.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
    (empty)

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanRegistry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanURLLoader.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanURLLoader.java?rev=955861&view=auto
==============================================================================
--- incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanURLLoader.java (added)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanURLLoader.java Fri Jun 18 07:08:31 2010
@@ -0,0 +1,45 @@
+/**
+ *  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.bval.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Description: <br/>
+ */
+public class XMLMetaBeanURLLoader implements XMLMetaBeanLoader {
+    private final URL url;
+
+    public XMLMetaBeanURLLoader(URL url) {
+        if (url == null) throw new NullPointerException("URL required");
+        this.url = url;
+    }
+
+    public XMLMetaBeanInfos load() throws IOException {
+        InputStream stream = url.openStream();
+        try {
+            XMLMetaBeanInfos beanInfos = (XMLMetaBeanInfos) XMLMapper.getInstance()
+                    .getXStream().fromXML(stream);
+            beanInfos.setId(url.toExternalForm());
+            return beanInfos;
+        } finally {
+            stream.close();
+        }
+    }
+}

Copied: incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java (from r955856, incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaElement.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java?p2=incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java&p1=incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaElement.java&r1=955856&r2=955861&rev=955861&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaElement.java (original)
+++ incubator/bval/trunk/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java Fri Jun 18 07:08:31 2010
@@ -16,13 +16,12 @@
  */
 package org.apache.bval.xml;
 
-import static org.apache.bval.model.Features.Property.*;
-
 import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
-
 import org.apache.bval.model.MetaProperty;
 import org.apache.commons.lang.ClassUtils;
 
+import static org.apache.bval.model.Features.Property.*;
+
 /**
  * Description: <br/>
  */



Mime
View raw message