Author: drobiazko
Date: Thu Aug 18 13:01:18 2011
New Revision: 1159201

URL: http://svn.apache.org/viewvc?rev=1159201&view=rev
Log:
Persistence unit parser now also checks for jar file urls

Modified:
    
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceContentHandler.java
    
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceUnitInfoImpl.java
    
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/TapestryPersistenceUnitInfo.java

Modified: 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceContentHandler.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceContentHandler.java?rev=1159201&r1=1159200&r2=1159201&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceContentHandler.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceContentHandler.java
 Thu Aug 18 13:01:18 2011
@@ -113,25 +113,36 @@ public class PersistenceContentHandler i
             if (ELEMENT_PROVIDER.equals(localName))
             {
                 persistenceUnitInfo.persistenceProviderClassName(string);
-            } else if (ELEMENT_CLASS.equals(localName))
+            }
+            else if (ELEMENT_CLASS.equals(localName))
             {
                 persistenceUnitInfo.addManagedClassName(string);
-            } else if (ELEMENT_CACHING.equals(localName))
+            }
+            else if (ELEMENT_CACHING.equals(localName))
             {
                 
persistenceUnitInfo.sharedCacheMode(toEnum(SharedCacheMode.class, string));
-            } else if (ELEMENT_VALIDATION_MODE.equals(localName))
+            }
+            else if (ELEMENT_VALIDATION_MODE.equals(localName))
             {
                 
persistenceUnitInfo.validationMode(toEnum(ValidationMode.class, string));
-            } else if (ELEMENT_MAPPING_FILE.equals(localName))
+            }
+            else if (ELEMENT_MAPPING_FILE.equals(localName))
             {
                 persistenceUnitInfo.addMappingFileName(string);
-            } else if (ELEMENT_NON_JTA_DATA_SOURCE.equals(localName))
+            }
+            else if (ELEMENT_JAR_FILE.equals(localName))
+            {
+                persistenceUnitInfo.addJarFileUrl(string);
+            }
+            else if (ELEMENT_NON_JTA_DATA_SOURCE.equals(localName))
             {
                 persistenceUnitInfo.nonJtaDataSource(string);
-            } else if (ELEMENT_JTA_DATA_SOURCE.equals(localName))
+            }
+            else if (ELEMENT_JTA_DATA_SOURCE.equals(localName))
             {
                 persistenceUnitInfo.jtaDataSource(string);
-            } else if (ELEMENT_PERSISTENCE_UNIT.equals(localName))
+            }
+            else if (ELEMENT_PERSISTENCE_UNIT.equals(localName))
             {
                 if (persistenceUnitInfo != null)
                 {

Modified: 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceUnitInfoImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceUnitInfoImpl.java?rev=1159201&r1=1159200&r2=1159201&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceUnitInfoImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/PersistenceUnitInfoImpl.java
 Thu Aug 18 13:01:18 2011
@@ -25,6 +25,7 @@ import javax.persistence.ValidationMode;
 import javax.persistence.spi.ClassTransformer;
 import javax.persistence.spi.PersistenceUnitTransactionType;
 import javax.sql.DataSource;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.Collections;
@@ -56,6 +57,8 @@ public class PersistenceUnitInfoImpl imp
 
     private final Set<String> mappingFilesNames = CollectionFactory.newSet();
 
+    private final List<URL> jarFileUrls = CollectionFactory.newList();
+
     private final Properties properties = new Properties();
 
 
@@ -163,6 +166,34 @@ public class PersistenceUnitInfoImpl imp
 
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public TapestryPersistenceUnitInfo addJarFileUrl(URL url)
+    {
+        jarFileUrls.add(url);
+
+        return this;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public TapestryPersistenceUnitInfo addJarFileUrl(String url)
+    {
+        try
+        {
+            return addJarFileUrl(new URL(getPersistenceUnitRootUrl(), url));
+        } catch (MalformedURLException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public TapestryPersistenceUnitInfo addProperty(String name, String value)
     {
         getProperties().put(name, value);
@@ -170,6 +201,10 @@ public class PersistenceUnitInfoImpl imp
         return this;
     }
 
+
+    /**
+     * {@inheritDoc}
+     */
     public TapestryPersistenceUnitInfo excludeUnlistedClasses(boolean exclude)
     {
         this.excludeUnlistedClasses = exclude;
@@ -182,7 +217,7 @@ public class PersistenceUnitInfoImpl imp
      */
     public List<URL> getJarFileUrls()
     {
-        return Arrays.asList();
+        return Collections.unmodifiableList(jarFileUrls);
     }
 
     /**

Modified: 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/TapestryPersistenceUnitInfo.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/TapestryPersistenceUnitInfo.java?rev=1159201&r1=1159200&r2=1159201&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/TapestryPersistenceUnitInfo.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/TapestryPersistenceUnitInfo.java
 Thu Aug 18 13:01:18 2011
@@ -18,6 +18,7 @@ import javax.persistence.SharedCacheMode
 import javax.persistence.ValidationMode;
 import javax.persistence.spi.PersistenceUnitInfo;
 import javax.persistence.spi.PersistenceUnitTransactionType;
+import java.net.URL;
 
 /**
  * Tapestry's mutable extension of {@link PersistenceUnitInfo} interface used 
for XML-less configuration
@@ -113,6 +114,26 @@ public interface TapestryPersistenceUnit
     TapestryPersistenceUnitInfo addMappingFileName(String fileName);
 
     /**
+     * Add a URLs for the jar file or exploded jar file directory that the 
persistence provider must examine
+     * for managed classes of the persistence unit. Corresponds to a 
<code>jar-file</code> element in the
+     * <code>persistence.xml</code> file.
+     *
+     * @param url
+     *         url to add
+     */
+    TapestryPersistenceUnitInfo addJarFileUrl(URL url);
+
+    /**
+     * Add a URLs for the jar file or exploded jar file directory that the 
persistence provider must examine
+     * for managed classes of the persistence unit. Corresponds to a 
<code>jar-file</code> element in the
+     * <code>persistence.xml</code> file.
+     *
+     * @param url
+     *         url to add
+     */
+    TapestryPersistenceUnitInfo addJarFileUrl(String url);
+
+    /**
      * Add a property. Corresponds to a <code>property</code> element in the 
<code>persistence.xml</code> file.
      *
      * @param name


Reply via email to