[jboss-cvs] JBossAS SVN: r72373 - in projects/metadata/trunk/src: main/java/org/jboss/metadata/jpa and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 17 11:51:57 EDT 2008


Author: alesj
Date: 2008-04-17 11:51:57 -0400 (Thu, 17 Apr 2008)
New Revision: 72373

Added:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaData.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaDataConstants.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceUnitMetaData.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/TransactionType.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jpa/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jpa/PersistenceMDUnitTestCase.java
   projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jpa/
   projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jpa/PersistenceMD_testDefaultMetaData.xml
Log:
Initial PersistenceMetaData.
TODO on failing tests.

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaData.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaData.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaData.java	2008-04-17 15:51:57 UTC (rev 72373)
@@ -0,0 +1,72 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.jboss.metadata.jpa.spec;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * The persistence metadata.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at XmlRootElement(name="persistence", namespace=PersistenceMetaDataConstants.PERSISTENCE_NS)
+ at JBossXmlSchema(namespace=PersistenceMetaDataConstants.PERSISTENCE_NS, elementFormDefault= XmlNsForm.QUALIFIED)
+ at XmlType(
+      name="persistenceType",
+      namespace=PersistenceMetaDataConstants.PERSISTENCE_NS,
+      propOrder={"persistenceUnits"}
+)
+public class PersistenceMetaData implements Serializable
+{
+   private String version;
+   private List<PersistenceUnitMetaData> persistenceUnits;
+
+   public String getVersion()
+   {
+      return version;
+   }
+
+   @XmlAttribute(required = true)
+   public void setVersion(String version)
+   {
+      this.version = version;
+   }
+
+   public List<PersistenceUnitMetaData> getPersistenceUnits()
+   {
+      return persistenceUnits;
+   }
+
+   @XmlElement(name = "persistence-unit")
+   public void setPersistenceUnits(List<PersistenceUnitMetaData> persistenceUnits)
+   {
+      this.persistenceUnits = persistenceUnits;
+   }
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaDataConstants.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaDataConstants.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaDataConstants.java	2008-04-17 15:51:57 UTC (rev 72373)
@@ -0,0 +1,31 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.jboss.metadata.jpa.spec;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface PersistenceMetaDataConstants
+{
+   /** The persistence namespace */
+   String PERSISTENCE_NS = "http://java.sun.com/xml/ns/persistence";
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceUnitMetaData.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceUnitMetaData.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceUnitMetaData.java	2008-04-17 15:51:57 UTC (rev 72373)
@@ -0,0 +1,179 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.jboss.metadata.jpa.spec;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.xb.annotations.JBossXmlMapEntry;
+import org.jboss.xb.annotations.JBossXmlMapKeyAttribute;
+import org.jboss.xb.annotations.JBossXmlMapValueAttribute;
+
+/**
+ * The persistence unit metadata.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at XmlType(propOrder={"mappingFiles", "jarFiles", "classes", "properties"})
+public class PersistenceUnitMetaData implements Serializable
+{
+   private String description;
+   private String provider;
+   private String jtaDataSource;
+   private String nonJtaDataSource;
+   private Set<String> mappingFiles;
+   private Set<String> jarFiles;
+   private Set<String> classes;
+   private boolean excludeUnlistedClasses;
+   private Map<String, String> properties;
+   private String name;
+   private TransactionType transactionType;
+
+   public String getDescription()
+   {
+      return description;
+   }
+
+   @XmlElement
+   public void setDescription(String description)
+   {
+      this.description = description;
+   }
+
+   public String getProvider()
+   {
+      return provider;
+   }
+
+   @XmlElement
+   public void setProvider(String provider)
+   {
+      this.provider = provider;
+   }
+
+   public String getJtaDataSource()
+   {
+      return jtaDataSource;
+   }
+
+   @XmlElement(name = "jta-data-source")
+   public void setJtaDataSource(String jtaDataSource)
+   {
+      this.jtaDataSource = jtaDataSource;
+   }
+
+   public String getNonJtaDataSource()
+   {
+      return nonJtaDataSource;
+   }
+
+   @XmlElement(name = "non-jta-data-source")
+   public void setNonJtaDataSource(String nonJtaDataSource)
+   {
+      this.nonJtaDataSource = nonJtaDataSource;
+   }
+
+   public Set<String> getMappingFiles()
+   {
+      return mappingFiles;
+   }
+
+   @XmlElement(name = "mapping-file")
+   public void setMappingFiles(Set<String> mappingFiles)
+   {
+      this.mappingFiles = mappingFiles;
+   }
+
+   public Set<String> getJarFiles()
+   {
+      return jarFiles;
+   }
+
+   @XmlElement(name = "jar-file")
+   public void setJarFiles(Set<String> jarFiles)
+   {
+      this.jarFiles = jarFiles;
+   }
+
+   public Set<String> getClasses()
+   {
+      return classes;
+   }
+
+   @XmlElement(name = "class")
+   public void setClasses(Set<String> classes)
+   {
+      this.classes = classes;
+   }
+
+   public boolean isExcludeUnlistedClasses()
+   {
+      return excludeUnlistedClasses;
+   }
+
+   @XmlElement(name = "exclude-unlisted-classes")
+   public void setExcludeUnlistedClasses(boolean excludeUnlistedClasses)
+   {
+      this.excludeUnlistedClasses = excludeUnlistedClasses;
+   }
+
+   public Map<String, String> getProperties()
+   {
+      return properties;
+   }
+
+   @XmlElementWrapper(name="properties")
+   @JBossXmlMapEntry(name="property")
+   @JBossXmlMapKeyAttribute(name="name")
+   @JBossXmlMapValueAttribute(name="value", namespace = "")
+   public void setProperties(Map<String, String> properties)
+   {
+      this.properties = properties;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   @XmlAttribute(required = true)
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public TransactionType getTransactionType()
+   {
+      return transactionType;
+   }
+
+   @XmlAttribute
+   public void setTransactionType(TransactionType transactionType)
+   {
+      this.transactionType = transactionType;
+   }
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/TransactionType.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/TransactionType.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/TransactionType.java	2008-04-17 15:51:57 UTC (rev 72373)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.jboss.metadata.jpa.spec;
+
+import org.jboss.xb.annotations.JBossXmlEnum;
+
+/**
+ * The transaction type.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at JBossXmlEnum(ignoreCase = true)
+public enum TransactionType
+{
+   JTA,
+   RESOURCE_LOCAL
+}
\ No newline at end of file

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jpa/PersistenceMDUnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jpa/PersistenceMDUnitTestCase.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jpa/PersistenceMDUnitTestCase.java	2008-04-17 15:51:57 UTC (rev 72373)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.jboss.test.metadata.jpa;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.metadata.jpa.spec.PersistenceMetaData;
+import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
+import org.jboss.test.metadata.javaee.AbstractJavaEEMetaDataTest;
+
+/**
+ * Test persistence metadata.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PersistenceMDUnitTestCase extends AbstractJavaEEMetaDataTest
+{
+   public PersistenceMDUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testDefaultMetaData() throws Throwable
+   {
+      final Class<PersistenceMetaData> expected = PersistenceMetaData.class;
+      PersistenceMetaData metadata = unmarshal(expected, schemaResolverForClass(expected));
+      assertEquals("1.0", metadata.getVersion());
+      List<PersistenceUnitMetaData> units = metadata.getPersistenceUnits();
+      assertNotNull(units);
+      assertEquals(1, units.size());
+      PersistenceUnitMetaData unit = units.get(0);
+      assertEquals("manager", unit.getName());
+      assertEquals("java:/DefaultDS", unit.getJtaDataSource());
+      Set<String> jars = unit.getJarFiles();
+      assertNotNull(jars);
+      assertEquals(1, jars.size());
+      String jar = jars.iterator().next();
+      assertEquals("persistence.jar", jar);
+      Map<String, String> properties = unit.getProperties();
+      assertNotNull(properties);
+      assertEquals("create-drop", properties.get("hibernate"));
+   }
+}

Added: projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jpa/PersistenceMD_testDefaultMetaData.xml
===================================================================
--- projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jpa/PersistenceMD_testDefaultMetaData.xml	                        (rev 0)
+++ projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jpa/PersistenceMD_testDefaultMetaData.xml	2008-04-17 15:51:57 UTC (rev 72373)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
+   <persistence-unit name="manager">
+      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <jar-file>persistence.jar</jar-file>
+      <properties>
+         <property name="hibernate" value="create-drop"/>
+      </properties>
+   </persistence-unit>
+</persistence>




More information about the jboss-cvs-commits mailing list