incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r902094 - in /incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container: impl/ parsing/impl/ unit/impl/
Date Fri, 22 Jan 2010 14:24:44 GMT
Author: timothyjward
Date: Fri Jan 22 14:24:43 2010
New Revision: 902094

URL: http://svn.apache.org/viewvc?rev=902094&view=rev
Log:
ARIES-127 : Add logging to the JPA components

Modified:
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceDescriptorImpl.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java?rev=902094&r1=902093&r2=902094&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
Fri Jan 22 14:24:43 2010
@@ -126,6 +126,8 @@
    */
   public synchronized void addingProvider(ServiceReference ref)
   {
+    if(_logger.isDebugEnabled())
+      _logger.debug("Adding a provider: {}", new Object[] {ref});
     persistenceProviders.add(ref);
   }
   
@@ -139,6 +141,10 @@
     //We may get a null reference if the ref-list is empty to start with
     if(ref == null)
       return;
+    
+    if(_logger.isDebugEnabled())
+      _logger.debug("Removing a provider: {}", new Object[] {ref});
+    
     Map<Bundle, EntityManagerFactoryManager> mgrs;
     synchronized (this) {
       persistenceProviders.remove(ref);
@@ -221,6 +227,9 @@
       //If we have no persistence units then our job is done
       if (!!!persistenceXmls.isEmpty()) {
         
+        if(_logger.isDebugEnabled())
+          _logger.debug("Located Persistence descriptors: {} in bundle {}", new Object[]
{persistenceXmls, bundle.getSymbolicName() + "_" + bundle.getVersion()});
+        
         if(bundle.getState() == Bundle.ACTIVE) {
           _logger.warn("The bundle {} is already active, it may not be possible to create
managed persistence units for it.", 
               new Object[] {bundle.getSymbolicName() + "_" + bundle.getVersion()});
@@ -241,6 +250,10 @@
         
         //If we have any persistence units then find a provider to use
         if(!!!pUnits.isEmpty()) {
+          
+          if(_logger.isDebugEnabled())
+            _logger.debug("Located Persistence units: {}", new Object[] {pUnits});
+          
           ServiceReference ref = getProviderServiceReference(pUnits);
           //If we found a provider then create the ManagedPersistenceUnitInfo objects
           if(ref != null) {  

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceDescriptorImpl.java?rev=902094&r1=902093&r2=902094&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceDescriptorImpl.java
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceDescriptorImpl.java
Fri Jan 22 14:24:43 2010
@@ -59,4 +59,12 @@
     return inputStream;
   }
   
+  public String toString()
+  {
+    if(location != null)
+      return location;
+    else 
+      return super.toString();
+  }
+  
 }

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java?rev=902094&r1=902093&r2=902094&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java
Fri Jan 22 14:24:43 2010
@@ -44,7 +44,7 @@
    * The Service Reference for the provider to which this persistence
    * unit is tied
    */
-  ServiceReference provider;
+  private ServiceReference provider;
 
   
   /**
@@ -61,7 +61,10 @@
     this.bundle = b;
     metadata.put(SCHEMA_VERSION, version);
 
-    if (name != null)metadata.put(UNIT_NAME, name);
+    if (name == null)
+      name = "";
+      
+    metadata.put(UNIT_NAME, name);
     if (transactionType != null) metadata.put(TRANSACTION_TYPE, transactionType);
 
   }
@@ -180,4 +183,10 @@
   {
     provider = providerRef;
   }
+  
+  public String toString()
+  {
+    return "Persistence unit " + metadata.get(UNIT_NAME) + " in bundle "
+    + bundle.getSymbolicName() + "_" + bundle.getVersion();
+  }
 }

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java?rev=902094&r1=902093&r2=902094&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
Fri Jan 22 14:24:43 2010
@@ -20,6 +20,7 @@
 
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
@@ -76,10 +77,15 @@
   public List<URL> getJarFileUrls() {
     List<String> jarFiles = (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.JAR_FILES);
     List<URL> urls = new ArrayList<URL>();
-    
-    for(String jarFile : jarFiles)
-      urls.add(bundle.getResource(jarFile));
-    
+    if(jarFiles != null) {
+      for(String jarFile : jarFiles){
+        URL url = bundle.getResource(jarFile);
+        if(url == null)
+          _logger.error("The persistence unit {} in bundle {} listed the jar file {}, but
" +
+          		"{} could not be found in the bundle", new Object[]{getPersistenceUnitName(),
+              bundle.getSymbolicName() + "_" + bundle.getVersion(), jarFile, jarFile});
+      }
+    }
     return urls;
   }
 
@@ -100,12 +106,20 @@
 
   @SuppressWarnings("unchecked")
   public List<String> getManagedClassNames() {
-    return (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.MANAGED_CLASSES);
+    List<String> classes = (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.MANAGED_CLASSES);
+    if(classes == null)
+      classes = new ArrayList<String>();
+    
+    return Collections.unmodifiableList(classes);
   }
 
   @SuppressWarnings("unchecked")
   public List<String> getMappingFileNames() {
-    return (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.MAPPING_FILES);
+    List<String> mappingFiles = (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.MAPPING_FILES);
+    if(mappingFiles == null)
+      mappingFiles = new ArrayList<String>();
+    
+    return Collections.unmodifiableList(mappingFiles);
   }
 
   public ClassLoader getNewTempClassLoader() {
@@ -150,17 +164,22 @@
 
   public SharedCacheMode getSharedCacheMode() {
     // TODO This needs to be supported once we parse JPA 2.0 xml
-    return null;
+    return SharedCacheMode.UNSPECIFIED;
   }
 
   public PersistenceUnitTransactionType getTransactionType() {
-    return PersistenceUnitTransactionType.valueOf(
-        (String) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.TRANSACTION_TYPE));
+    
+    String s = (String) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.TRANSACTION_TYPE);
+
+    if(s == null)
+      return PersistenceUnitTransactionType.JTA;
+    else
+      return PersistenceUnitTransactionType.valueOf(s);
   }
 
   public ValidationMode getValidationMode() {
     // TODO This needs to be supported once we parse JPA 2.0 xml
-    return null;
+    return ValidationMode.AUTO;
   }
   
 }
\ No newline at end of file



Mime
View raw message