aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1154500 - in /aries/trunk/jpa/jpa-container/src/main: java/org/apache/aries/jpa/container/impl/ java/org/apache/aries/jpa/container/parsing/impl/ java/org/apache/aries/jpa/container/unit/impl/ java/org/apache/aries/jpa/container/weaving/im...
Date Sat, 06 Aug 2011 12:10:19 GMT
Author: not
Date: Sat Aug  6 12:10:18 2011
New Revision: 1154500

URL: http://svn.apache.org/viewvc?rev=1154500&view=rev
Log:
ARIES-467 NLS enable the JPA container exception and log messages.

Added:
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/NLS.java
  (with props)
    aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/
    aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties
  (with props)
Modified:
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/DelayedLookupDataSource.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
Sat Aug  6 12:10:18 2011
@@ -20,14 +20,12 @@ package org.apache.aries.jpa.container.i
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
 import java.util.Map.Entry;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -204,11 +202,9 @@ public class EntityManagerFactoryManager
       registrations = new ConcurrentHashMap<String, ServiceRegistration>();
       String providerName = (String) provider.getProperty("javax.persistence.provider");
       if(providerName == null) {
-        _logger.warn("The PersistenceProvider for bundle {} did not specify a provider name
in the \"javax.persistence.provider\" service property. " +
-        		"As a result EntityManagerFactory objects will not be registered with the " 
-            + PersistenceUnitConstants.OSGI_UNIT_PROVIDER + " property. " 
-            + "The Peristence Provider service was {}",
-            new Object[] {bundle.getSymbolicName() + "_" + bundle.getVersion(), provider});
+        _logger.warn( NLS.MESSAGES.getMessage("no.provider.specified", 
+                      bundle.getSymbolicName() + '/' + bundle.getVersion(), 
+                      PersistenceUnitConstants.OSGI_UNIT_PROVIDER, provider));
       }
       //Register each EMF
       for(Entry<String, ? extends EntityManagerFactory> entry : emfs.entrySet())
@@ -225,8 +221,7 @@ public class EntityManagerFactoryManager
         try {
           registrations.put(unitName, bundle.getBundleContext().registerService(EntityManagerFactory.class.getCanonicalName(),
entry.getValue(), props));
         } catch (Exception e) {
-          _logger.error("There was an error registering the persistence unit " 
-              + unitName + " defined by the bundle " + bundle.getSymbolicName() + "_" + bundle.getVersion(),
e);
+          _logger.error(NLS.MESSAGES.getMessage("cannot.register.persistence.unit", unitName,
bundle.getSymbolicName() + '/' + bundle.getVersion()));
           throw new InvalidPersistenceUnitException(e);
         }
       }
@@ -249,12 +244,10 @@ public class EntityManagerFactoryManager
           PersistenceProvider providerService = (PersistenceProvider) containerContext.getService(provider);
 
           if(providerService == null) {
-            _logger.warn("The PersistenceProvider service hosting persistence units in bundle
" 
-                + bundle.getSymbolicName() + "_" + bundle.getVersion() + " is no longer available.
" +
-                		"Persistence units defined by the bundle will not be available until the
bundle is refreshed");
+            _logger.warn(NLS.MESSAGES.getMessage("persistence.provider.gone.awol", bundle.getSymbolicName()
+ '/' + bundle.getVersion()));
             throw new InvalidPersistenceUnitException();
           }
-      
+
           for(ManagedPersistenceUnitInfo info : persistenceUnits){
             PersistenceUnitInfo pUnitInfo = info.getPersistenceUnitInfo();
         
@@ -325,8 +318,7 @@ public class EntityManagerFactoryManager
         try {
           entry.getValue().close();
         } catch (Exception e) {
-          _logger.error("There was an exception when closing the EntityManagerFactory for
persistence unit "
-              + entry.getKey() + " in bundle " + bundle.getSymbolicName() + "_" + bundle.getVersion(),
e);
+          _logger.error(NLS.MESSAGES.getMessage("could.not.close.persistence.unit", entry.getKey(),
bundle.getSymbolicName() + '/' + bundle.getVersion()), e);
         }
       }
     }

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java
Sat Aug  6 12:10:18 2011
@@ -32,8 +32,7 @@ public class InvalidRangeCombination ext
 
   public InvalidRangeCombination(Version minVersion, boolean minExclusive,
       Version maxVersion, boolean maxExclusive) {
-    super("There was no overlap between the specified version ranges. The combined version
range" +
-    		"string would have been " + getVersionRangeString(minVersion, minExclusive, maxVersion,
maxExclusive));
+    super(NLS.MESSAGES.getMessage("no.overlap.for.version.range", getVersionRangeString(minVersion,
minExclusive, maxVersion, maxExclusive)));
   }
 
   private static String getVersionRangeString(Version minVersion,

Added: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/NLS.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/NLS.java?rev=1154500&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/NLS.java
(added)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/NLS.java
Sat Aug  6 12:10:18 2011
@@ -0,0 +1,26 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import org.apache.aries.util.nls.MessageUtil;
+
+public class NLS
+{
+  public static MessageUtil MESSAGES = MessageUtil.createMessageUtil(NLS.class, "org.apache.aries.jpa.container.nls.jpaContainerMessages");
+}
\ No newline at end of file

Propchange: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/NLS.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java
Sat Aug  6 12:10:18 2011
@@ -63,7 +63,6 @@ public class PersistenceBundleHelper
    */
   public static Collection<PersistenceDescriptor> findPersistenceXmlFiles(Bundle bundle)
   { 
-    @SuppressWarnings("unchecked")
     Dictionary<String, String> headers = bundle.getHeaders();
     String metaPersistence = headers.get(PERSISTENCE_UNIT_HEADER);
     String webContextPath = headers.get(WEB_CONTEXT_PATH_HEADER);
@@ -83,10 +82,7 @@ public class PersistenceBundleHelper
         locations = findWABClassPathLocations(bundleClassPath);
 
         if(_logger.isInfoEnabled())
-          _logger.info("The bundle " + bundleIdentity + " specifies the " + 
-                     WEB_CONTEXT_PATH_HEADER + " header; it does not specify the " + PERSISTENCE_UNIT_HEADER
+ " header. " +
-                     "This bundle will be scanned for persistence descriptors in the locations:
" + locations + " " +
-                     "using the rules defined by the JPA specification for finding persistence
descriptors for web applications.");
+          _logger.info(NLS.MESSAGES.getMessage("wab.without.meta.persistence.header", bundleIdentity,
WEB_CONTEXT_PATH_HEADER, PERSISTENCE_UNIT_HEADER, locations));
       }
     } else {
 
@@ -114,9 +110,7 @@ public class PersistenceBundleHelper
             persistenceXmlFiles.add(new PersistenceDescriptorImpl(location, file));
           }
       } catch (Exception e) {
-          _logger.error("There was an exception while locating the persistence descriptor
at location "
-              + location + " in bundle " + bundleIdentity
-          		+ ". No persistence descriptors will be processed for this bundle.", e);
+          _logger.error(NLS.MESSAGES.getMessage("exception.while.locating.descriptor", location,
bundleIdentity), e);
         //If we get an exception, then go through closing all of our streams.
         //It is better to fail completely than half succeed.
         for (PersistenceDescriptor desc : persistenceXmlFiles) {
@@ -133,8 +127,7 @@ public class PersistenceBundleHelper
     }
     
     if (persistenceXmlFiles.isEmpty()) {
-      _logger.warn("No persistence descriptors could be located in the bundle " + bundleIdentity
+ ". " +
-                   "The following locations were searched: " + locations.toString());
+      _logger.warn(NLS.MESSAGES.getMessage("no.persistence.descriptor", bundleIdentity, locations.toString()));
     }
 
     return persistenceXmlFiles;

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
Sat Aug  6 12:10:18 2011
@@ -123,8 +123,7 @@ public class PersistenceBundleManager im
           (Class<? extends ManagedPersistenceUnitInfoFactory>) ctx.getBundle().loadClass(className);
         persistenceUnitFactory = clazz.newInstance();
       } catch (Exception e) {
-        _logger.error("There was a problem creating the custom ManagedPersistenceUnitInfoFactory
" + className 
-            + ". The default ManagedPersistenceUnitInfo factory will be used instead", e);
+        _logger.error(NLS.MESSAGES.getMessage("unable.to.create.mpuif", className), e);
       }
     }
     
@@ -195,8 +194,7 @@ public class PersistenceBundleManager im
         if(e instanceof InvalidPersistenceUnitException) {
           logInvalidPersistenceUnitException(mgr.getBundle(), (InvalidPersistenceUnitException)e);
         } else {
-          _logger.warn("An error occured whilst trying to manage persistence units for bundle
" 
-              + mgr.getBundle().getSymbolicName() + "_" + mgr.getBundle().getVersion(), e);
+          _logger.warn(NLS.MESSAGES.getMessage("unable.to.manage.pu", mgr.getBundle().getSymbolicName(),
mgr.getBundle().getVersion()), e);
         }
         mgr.destroy();
         if(infos != null)
@@ -248,18 +246,26 @@ public class PersistenceBundleManager im
     
     if(u != null) {
       if(_logger.isInfoEnabled())
-        _logger.info("A {} file was found. The default properties {} will be overridden.",
-            new Object[] {ManagedPersistenceUnitInfoFactory.ARIES_JPA_CONTAINER_PROPERTIES,
config});
+        _logger.info(NLS.MESSAGES.getMessage("aries.jpa.config.file.found", 
+                                             ManagedPersistenceUnitInfoFactory.ARIES_JPA_CONTAINER_PROPERTIES,

+                                             ctx.getBundle().getSymbolicName(),
+                                             ctx.getBundle().getVersion(),
+                                             config));
       try {
         config.load(u.openStream());
       } catch (IOException e) {
-        _logger.error("There was an error reading from " 
-            + ManagedPersistenceUnitInfoFactory.ARIES_JPA_CONTAINER_PROPERTIES, e);
+        _logger.error(NLS.MESSAGES.getMessage("aries.jpa.config.file.read.error", 
+                                              ManagedPersistenceUnitInfoFactory.ARIES_JPA_CONTAINER_PROPERTIES,
+                                              ctx.getBundle().getSymbolicName(),
+                                              ctx.getBundle().getVersion()), e);
       }
     } else {
       if(_logger.isInfoEnabled())
-        _logger.info("No {} file was found. The default properties {} will be used.",
-            new Object[] {ManagedPersistenceUnitInfoFactory.ARIES_JPA_CONTAINER_PROPERTIES,
config});
+        _logger.info(NLS.MESSAGES.getMessage("aries.jpa.config.file.not.found", 
+            ManagedPersistenceUnitInfoFactory.ARIES_JPA_CONTAINER_PROPERTIES, 
+            ctx.getBundle().getSymbolicName(),
+            ctx.getBundle().getVersion(),
+            config));
     }
   }
 
@@ -319,8 +325,7 @@ public class PersistenceBundleManager im
         _logger.debug("Located Persistence descriptors: {} in bundle {}", new Object[] {persistenceXmls,
b.getSymbolicName() + "_" + b.getVersion()});
       
       if(b.getState() == Bundle.ACTIVE) {
-        _logger.warn("The bundle {} is already active, it may not be possible to create managed
persistence units for it.", 
-            new Object[] {b.getSymbolicName() + "_" + b.getVersion()});
+        _logger.warn(NLS.MESSAGES.getMessage("jpa.bundle.active", b.getSymbolicName(), b.getVersion()));
       }
       
       
@@ -330,9 +335,7 @@ public class PersistenceBundleManager im
         try {
           pUnits.addAll(parser.parse(b, descriptor));
         } catch (PersistenceDescriptorParserException e) {
-          _logger.error("There was an error while parsing the persistence descriptor " 
-              + descriptor.getLocation() + " in bundle " + b.getSymbolicName() 
-              + "_" + b.getVersion() + ". No persistence units will be managed for this bundle",
e);
+          _logger.error(NLS.MESSAGES.getMessage("persistence.description.parse.error", descriptor.getLocation(),
b.getSymbolicName(), b.getVersion()), e);
         }
       }
     }
@@ -427,8 +430,7 @@ public class PersistenceBundleManager im
           try {
             versionRanges.add(VersionRange.parseVersionRange(versionRangeString));
           } catch (IllegalArgumentException e) {
-            _logger.warn("There was an error parsing the version range string {} for persistence
unit {}. It will be ignored."
-                , new Object[] {versionRangeString, metadata.get(ParsedPersistenceUnit.UNIT_NAME)});
+            _logger.warn(NLS.MESSAGES.getMessage("version.range.parse.failure", versionRangeString,
metadata.get(ParsedPersistenceUnit.UNIT_NAME)));
           }
         }
       }
@@ -441,8 +443,7 @@ public class PersistenceBundleManager im
         range = combineVersionRanges(versionRanges);
       } catch (InvalidRangeCombination e) {
         Bundle bundle = parsedPersistenceUnits.iterator().next().getDefiningBundle();
-        _logger.error("The bundle " + bundle.getSymbolicName() 
-            + "_" + bundle.getVersion() + " specified an invalid combination of provider
version ranges",  e);
+        _logger.error(NLS.MESSAGES.getMessage("invalid.provider.version.ranges", bundle.getSymbolicName(),
bundle.getVersion()), e);
         return null;
       }
     }
@@ -450,16 +451,14 @@ public class PersistenceBundleManager im
     if(ppClassNames.size() > 1)
     {
       Bundle bundle = parsedPersistenceUnits.iterator().next().getDefiningBundle();
-      _logger.error("The bundle " + bundle.getSymbolicName() 
-          + "_" + bundle.getVersion() + " specified more than one persistence provider: {}.
"
-          + "This is not supported, so no persistence units will be created for this bundle.",
-          new Object[] {ppClassNames});
+      _logger.error(NLS.MESSAGES.getMessage("multiple.persistence.providers.specified", bundle.getSymbolicName(),
bundle.getVersion(), ppClassNames));
       return null;
     } else {
+      Bundle bundle = parsedPersistenceUnits.iterator().next().getDefiningBundle();
       //Get the best provider for the given filters
       String provider = (ppClassNames.isEmpty()) ?
           persistenceUnitFactory.getDefaultProviderClassName() : ppClassNames.iterator().next();
-          return getBestProvider(provider, range);
+          return getBestProvider(provider, range, bundle);
     }
   }
  
@@ -531,10 +530,11 @@ public class PersistenceBundleManager im
    * Locate the best provider for the given criteria
    * @param providerClass
    * @param matchingCriteria
+   * @param bundle 
    * @return
    */
   @SuppressWarnings("unchecked")
-  private synchronized ServiceReference getBestProvider(String providerClass, VersionRange
matchingCriteria)
+  private synchronized ServiceReference getBestProvider(String providerClass, VersionRange
matchingCriteria, Bundle bundle)
   {
     if(!!!persistenceProviders.isEmpty()) {
       if((providerClass != null && !!!"".equals(providerClass))
@@ -555,15 +555,14 @@ public class PersistenceBundleManager im
           //Return the "best" provider, i.e. the highest version
           return Collections.max(refs, new ProviderServiceComparator());
         } else {
-          _logger.warn("There are no suitable providers for the provider class name {} and
version range {}.",
-              new Object[] {providerClass, matchingCriteria});
+          _logger.warn(NLS.MESSAGES.getMessage("no.suitable.jpa.providers", providerClass,
matchingCriteria, bundle.getSymbolicName(), bundle.getVersion()));
         }
       } else {
         //Return the "best" provider, i.e. the service OSGi would pick
         return (ServiceReference) Collections.max(persistenceProviders);
       }
     } else {
-      _logger.warn("There are no providers available.");
+      _logger.warn(NLS.MESSAGES.getMessage("no.jpa.providers"));
     }
     return null;
   }
@@ -594,8 +593,7 @@ public class PersistenceBundleManager im
    */
   private void logInvalidPersistenceUnitException(Bundle bundle,
       InvalidPersistenceUnitException e) {
-    _logger.warn("The persistence units for bundle " + bundle.getSymbolicName() + "_" + bundle.getVersion()
-        + " became invalid and will be destroyed.", e);
+    _logger.warn(NLS.MESSAGES.getMessage("pu.has.becomd.invalid", bundle.getSymbolicName(),
bundle.getVersion()), e);
   }
 
   
@@ -627,7 +625,7 @@ public class PersistenceBundleManager im
       quiesceReg = context.registerService(QUIESCE_PARTICIPANT_CLASS,
          quiesceParticipant, null);
     } catch (ClassNotFoundException e) {
-      _logger.info("No quiesce support is available, so managed persistence units will not
participate in quiesce operations");
+      _logger.info(NLS.MESSAGES.getMessage("quiesce.manager.not.there"));
     }
   }
 

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
Sat Aug  6 12:10:18 2011
@@ -27,6 +27,7 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.validation.Schema;
 
+import org.apache.aries.jpa.container.impl.NLS;
 import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
 import org.apache.aries.jpa.container.parsing.PersistenceDescriptor;
 import org.apache.aries.jpa.container.parsing.PersistenceDescriptorParser;
@@ -77,8 +78,7 @@ public class PersistenceDescriptorParser
         } 
       }
     } catch (Exception e) {
-      throw new PersistenceDescriptorParserException("There was an error parsing " + descriptor.getLocation()

-          + " in bundle " + b.getSymbolicName() + "_" + b.getVersion(), e);
+      throw new PersistenceDescriptorParserException(NLS.MESSAGES.getMessage("persistence.description.parse.error",
descriptor.getLocation(), b.getSymbolicName(), b.getVersion()), e);
     } finally {
       if(is != null) try {
         is.closeUnderlying();
@@ -87,9 +87,7 @@ public class PersistenceDescriptorParser
       }
     }
     if(!!!schemaFound) {
-    throw new PersistenceDescriptorParserException("No Schema could be located for the" +
-        "persistence descriptor " + descriptor.getLocation() 
-        + " in bundle " + b.getSymbolicName() + "_" + b.getVersion());
+      throw new PersistenceDescriptorParserException(NLS.MESSAGES.getMessage("persistence.descriptor.schema.not.found",
descriptor.getLocation(), b.getSymbolicName(), b.getVersion()));
     }
     return persistenceUnits;
   }

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/DelayedLookupDataSource.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/DelayedLookupDataSource.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/DelayedLookupDataSource.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/DelayedLookupDataSource.java
Sat Aug  6 12:10:18 2011
@@ -27,6 +27,7 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.sql.DataSource;
 
+import org.apache.aries.jpa.container.impl.NLS;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -47,16 +48,14 @@ public class DelayedLookupDataSource imp
         
         BundleContext bCtx = persistenceBundle.getBundleContext();
         if(bCtx == null)
-          throw new IllegalStateException("The bundle " + 
-              persistenceBundle.getSymbolicName() + "_" + persistenceBundle.getVersion()
+ 
-              " is not started.");
+          throw new IllegalStateException(NLS.MESSAGES.getMessage("persistence.bundle.not.active",
persistenceBundle.getSymbolicName(), persistenceBundle.getVersion()));
         props.put("osgi.service.jndi.bundleContext", bCtx);
         InitialContext ctx = new InitialContext(props);
         ds = (DataSource) ctx.lookup(jndiName);
       } catch (NamingException e) {
-        _logger.error("No JTA datasource could be located using the JNDI name " + jndiName,
-            e);
-        throw new RuntimeException("The DataSource " + jndiName + " could not be used.",
e);
+        String message = NLS.MESSAGES.getMessage("no.data.source.found", jndiName, persistenceBundle.getSymbolicName(),
persistenceBundle.getVersion());
+        _logger.error(message, e);
+        throw new RuntimeException(message, e);
       }
     }
     return ds;

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
Sat Aug  6 12:10:18 2011
@@ -26,6 +26,7 @@ import java.util.concurrent.ConcurrentMa
 
 import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
 import org.apache.aries.jpa.container.ManagedPersistenceUnitInfoFactory;
+import org.apache.aries.jpa.container.impl.NLS;
 import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -49,15 +50,14 @@ public class ManagedPersistenceUnitInfoF
     
     Collection<?> existing = persistenceUnits.putIfAbsent(persistenceBundle, managedUnits);
     if(existing != null)
-      throw new IllegalStateException("Previous units were detected that have not been destroyed");
+      throw new IllegalStateException(NLS.MESSAGES.getMessage("previous.pus.have.not.been.destroyed",
persistenceBundle.getSymbolicName(), persistenceBundle.getVersion()));
     return Collections.unmodifiableCollection(managedUnits);
   }
 
   public void destroyPersistenceBundle(BundleContext containerContext, Bundle bundle) {
     Collection<ManagedPersistenceUnitInfoImpl> mpus = persistenceUnits.remove(bundle);
     if(mpus == null)
-      throw new IllegalStateException("No persistence units defined for bundle " +
-          bundle.getSymbolicName() + "_" + bundle.getVersion());
+      throw new IllegalStateException(NLS.MESSAGES.getMessage("no.persistence.units.for.bundle",
bundle.getSymbolicName(), bundle.getVersion()));
     for(ManagedPersistenceUnitInfoImpl impl : mpus) {
       impl.destroy();
     }

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
Sat Aug  6 12:10:18 2011
@@ -34,6 +34,7 @@ import javax.sql.DataSource;
 
 import org.apache.aries.jpa.container.annotation.impl.AnnotationScanner;
 import org.apache.aries.jpa.container.annotation.impl.AnnotationScannerFactory;
+import org.apache.aries.jpa.container.impl.NLS;
 import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
 import org.apache.aries.jpa.container.weaving.impl.TransformerRegistry;
 import org.apache.aries.jpa.container.weaving.impl.TransformerRegistryFactory;
@@ -100,9 +101,7 @@ public class PersistenceUnitInfoImpl imp
       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});
+          _logger.error(NLS.MESSAGES.getMessage("pu.not.found", getPersistenceUnitName(),
bundle.getSymbolicName(), bundle.getVersion(), jarFile));
         } else {
             urls.add(url);
         }

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
Sat Aug  6 12:10:18 2011
@@ -26,6 +26,7 @@ import java.util.concurrent.ConcurrentMa
 
 import javax.persistence.spi.ClassTransformer;
 
+import org.apache.aries.jpa.container.impl.NLS;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.hooks.weaving.WeavingException;
@@ -80,9 +81,10 @@ public class JPAWeavingHook implements W
             throw (ThreadDeath)t;
           else if (t instanceof OutOfMemoryError)
             throw (OutOfMemoryError) t;
-          else throw new WeavingException("There was an error attempting to weave " +
-              wovenClass.getClassName() + " using transformer " + transformer.toString()
-              , t);
+          else {
+            Bundle b = wovenClass.getBundleWiring().getBundle();
+            throw new WeavingException(NLS.MESSAGES.getMessage("jpa.weaving.failure", wovenClass.getClassName(),
b.getSymbolicName(), b.getVersion(), transformer), t);
+          }
         }
       }
     }
@@ -109,7 +111,7 @@ public class JPAWeavingHook implements W
     LinkedHashSet<WrappingTransformer> set = registeredTransformers.get(pBundle);
     
     if(set == null || !!!safeRemove(set, transformer))
-      throw new IllegalStateException("The transformer " + transformer + " is not registered");
+      throw new IllegalStateException(NLS.MESSAGES.getMessage("jpa.weaving.transformer.not.registered",
transformer));
     
     if(set.isEmpty())
       registeredTransformers.remove(pBundle);

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java?rev=1154500&r1=1154499&r2=1154500&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java
Sat Aug  6 12:10:18 2011
@@ -25,6 +25,7 @@ import java.util.HashSet;
 
 import javax.persistence.spi.ClassTransformer;
 
+import org.apache.aries.jpa.container.impl.NLS;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -40,10 +41,10 @@ class WrappingTransformer implements Cla
       ServiceReference<?> persistenceProvider) {
 
     if(delegate == null) 
-      throw new NullPointerException("Delegate transformer must not be null");
+      throw new NullPointerException(NLS.MESSAGES.getMessage("jpa.weaving.null.transformer"));
     
     if(persistenceProvider == null) {
-      throw new NullPointerException("Persistence Provider must not be null");
+      throw new NullPointerException(NLS.MESSAGES.getMessage("jpa.weaving.null.provider"));
     }
     
     this.delegate = delegate;

Added: aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties?rev=1154500&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties
(added)
+++ aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties
Sat Aug  6 12:10:18 2011
@@ -0,0 +1,138 @@
+#
+# 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.
+#
+
+# {0} The bundle identity
+# {1} OSGi unit provider
+# {2} The persistence provider service
+no.provider.specified=The PersistenceProvider for bundle {0} did not specify a provider name
in the \
+ "javax.persistence.provider" service property. As a result EntityManagerFactory objects
will not \
+ be registered with the {1} property. The Persistence Provider service is {2}.
+# {0} A unit test
+# {1} Bundle identity
+cannot.register.persistence.unit=There was an error registering the persistence unit {0}
defined by \
+ the bundle {1}.
+# {0} The bundle identity
+persistence.provider.gone.awol=The PersistenceProvider service hosting persistence units
in bundle {0} \
+ is no longer available. Persistence units defined by the bundle will not be available until
the bundle is refreshed.
+# {0} A property key
+# {1} The bundle identity
+could.not.close.persistence.unit=There was an exception when closing the EntityManagerFactory
for persistence unit \
+ {0} in bundle {1}.
+# {0} The combined version range
+no.overlap.for.version.range=There was no overlap between the specified version ranges. The
combined version range \
+ string would have been {0}.
+# {0} The bundle identity
+# {1} The Web-ContextPath header
+# {2} The Meta-Persistence header
+# {3} The locations
+wab.without.meta.persistence.header=The bundle {0} specifies the {1} header; it does not
specify the {2} header. \
+ This bundle will be scanned for persistence descriptors in the locations: {3} using the
rules defined by the \
+ JPA specification for finding persistence descriptors for web applications.
+# {0} The location
+# {1} The bundle identity
+exception.while.locating.descriptor=There was an exception while locating the persistence
descriptor at location \
+ {0} in bundle {1}. No persistence descriptors will be processed for this bundle.
+# {0} The bundle identity
+# {1} The locations
+no.persistence.descriptor=No persistence descriptors could be located in the bundle {0}.
The following locations were searched: \
+ {1}.
+
+# {0} The name of the ManagedPersistenceUnitInfoFactory class.
+unable.to.create.mpuif=There was a problem creating the custom ManagedPersistenceUnitInfoFactory
{0}. The default \
+ ManagedPersistenceUnitInfo factory will be used instead.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+unable.to.manage.pu=An error occurred trying to manage persistence units for bundle {0}/{1}.
+# {0} The file that was found.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+# {3} The properties that are being overridden.
+aries.jpa.config.file.found=A {0} file was found in bundle {1}/{2}. The default properties
{3} will be overridden."
+# {0} The file that was being read.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+aries.jpa.config.file.read.error=There was an error reading from file {0} in bundle {1}/{2}.
+# {0} The file that could not be found
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+# {3} The default properties.
+aries.jpa.config.file.not.found=The file {0} was not found in bundle {1}/{2}. The default
properties {3} will be used.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+jpa.bundle.active=The bundle {0}/{1} is already active, it may not be possible to create
managed persistence units for it.
+# {0} The file that could not be parsed.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+persistence.description.parse.error=There was an error while parsing the persistence descriptor
{0} in the bundle {1}/{2}. \
+ No persistence units will be managed for this bundle.
+# {0} The invalid version range.
+# {1} The persistent unit name.
+version.range.parse.failure=There was an error parsing the version range string {0} for persistence
unit {1}. It will be ignored.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+invalid.provider.version.ranges=The bundle {0}/{1} specified an invalid combination of provider
version ranges.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+# {2} Persistence providers specified.
+multiple.persistence.providers.specified=The bundle {0}/{1} specified more than one persistence
provider: {2}. \
+ This is not supported, so no persistence units will be created for this bundle.
+# {0} The provider class name
+# {1} The version range
+# {2} The bundle symbolic name.
+# {3} The bundle version.
+no.suitable.jpa.providers=There are no suitable providers for the provider class name {0}
and version range {1} to \
+ support the bundle {2}/{3}.
+no.jpa.providers=There are no providers available.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+pu.has.becomd.invalid=The persistence units for bundle {0}/{1} became invalid and will be
destroyed.
+quiesce.manager.not.there=No quiesce support is available, so managed persistence units will
not participate in quiesce operations.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+persistence.bundle.not.active=The bundle {0}/{1} is not started.
+# {0} The datasource JNDI name
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+no.data.source.found=The DataSource {0} required by bundle {1}/{2} could not be found.
+# {0} The persistence unit name
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+# {3} The jar name.
+pu.not.found=The persistence unit {0} in bundle {1}/{2} listed the jar file {3}, but {3}
could not be found in the bundle.
+# {0} The persistence descriptor location.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+persistence.descriptor.schema.not.found=A schema could be located for the persistence descriptor
{0} in bundle {1}/{2}.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+previous.pus.have.not.been.destroyed=Unable to create persistence units for the bundle {0}/{1}
as previous persistence units already exist.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+no.persistence.units.for.bundle=No persistence units defined for bundle {0}/{1}.
+# {0} The class that could not be weaved.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+# {3} The transformer that threw an exception.
+jpa.weaving.failure=There was an error attempting to weave the class {0} in the bundle {1}/{2}
using the transformer {3}.
+# {0} The transformer that was not registered.
+jpa.weaving.transformer.not.registered=The transformer {0} cannot be unregistered because
it has not been registered.
+jpa.weaving.null.transformer=The delegate transformer must not be null.
+jpa.weaving.null.provider=The persistence provider must not be null.
+
+

Propchange: aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message