aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1695955 - in /aries/trunk/transaction/transaction-blueprint/src/main: java/org/apache/aries/transaction/ java/org/apache/aries/transaction/parsing/ resources/org/apache/aries/transaction/nls/
Date Fri, 14 Aug 2015 18:22:15 GMT
Author: cschneider
Date: Fri Aug 14 18:22:14 2015
New Revision: 1695955

URL: http://svn.apache.org/r1695955
Log:
[ARIES-1379] Remove remaining NLS usage

Removed:
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/Constants.java
    aries/trunk/transaction/transaction-blueprint/src/main/resources/org/apache/aries/transaction/nls/blueprintTx.properties
Modified:
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxDataUtil.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationParser.java
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxDataUtil.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxDataUtil.java?rev=1695955&r1=1695954&r2=1695955&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxDataUtil.java
(original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/BundleWideTxDataUtil.java
Fri Aug 14 18:22:14 2015
@@ -18,6 +18,8 @@
  */
 package org.apache.aries.transaction;
 
+import static java.lang.String.format;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -26,6 +28,7 @@ import java.util.regex.Pattern;
 import org.apache.aries.transaction.annotations.TransactionPropagationType;
 
 public class BundleWideTxDataUtil {
+    public static final Pattern WILDCARD = Pattern.compile("\\Q.*\\E");
     
     
     /**
@@ -171,7 +174,10 @@ public class BundleWideTxDataUtil {
             return bundleDataNoRestriction.get(0).getValue();
         } else {
             // cannot have more than 1 transaction element that has no method or bean attribute
-            throw new IllegalStateException(Constants.MESSAGES.getMessage("bundle.wide.tx",
bundleDataNoRestriction));
+            String msg = format("There are more than one bundle wide transaction elements
" 
+                                + "that have no method or bean attribute specified %s.",
+                                bundleDataNoRestriction);
+            throw new IllegalStateException(msg);
         }
         
     }
@@ -200,8 +206,7 @@ public class BundleWideTxDataUtil {
                         if (matchesMethod2.size() == 1) {
                             return matchesMethod2.get(0).getValue();
                         } else {
-                            // unable to find the best match!!
-                            throw new IllegalStateException(Constants.MESSAGES.getMessage("unable.to.apply.patterns",
matchedTxData));
+                            throw unableToApply(matchedTxData);
                         }
                     }
                 }
@@ -225,8 +230,7 @@ public class BundleWideTxDataUtil {
                 if (matchesBean2.size() == 1) {
                     return matchesBean2.get(0).getValue();
                 } else {
-                    // unable to find the best match!!
-                    throw new IllegalStateException(Constants.MESSAGES.getMessage("unable.to.apply.patterns",
matchedTxData));                  
+                    throw unableToApply(matchedTxData);
                 }
             }
         }
@@ -248,14 +252,17 @@ public class BundleWideTxDataUtil {
                 if (matchesMethod2.size() == 1) {
                     return matchesMethod2.get(0).getValue();
                 } else {
-                    // unable to find the best match!!
-                    throw new IllegalStateException(Constants.MESSAGES.getMessage("unable.to.apply.patterns",
matchedTxData));                  
+                    throw unableToApply(matchedTxData);
                 }
             }
         }
 
     }
     
+    static IllegalStateException unableToApply(List<?> matchedTxData) {
+        return new IllegalStateException("Unable to apply patterns " + matchedTxData);
+    }
+    
     private static List<MatchedTxData> selectPatternsWithFewestWildcards(List<MatchedTxData>
matchedTxData, boolean isBean) {
         List<MatchedTxData> remainingMatches = new ArrayList<MatchedTxData>();
         int minWildcards = Integer.MAX_VALUE;
@@ -269,7 +276,7 @@ public class BundleWideTxDataUtil {
             }
             String pattern = p.pattern();
             
-            Matcher m = Constants.WILDCARD.matcher(pattern);
+            Matcher m = WILDCARD.matcher(pattern);
             int count = 0;
             
             while (m.find()) {

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java?rev=1695955&r1=1695954&r2=1695955&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java
(original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TransactionAttribute.java
Fri Aug 14 18:22:14 2015
@@ -36,7 +36,7 @@ public enum TransactionAttribute {
       public TransactionToken begin(TransactionManager man) throws SystemException
       {
         if (man.getStatus() == Status.STATUS_NO_TRANSACTION) {
-          throw new IllegalStateException(Constants.MESSAGES.getMessage("tran.not.found"));
+          throw new IllegalStateException("No transaction present when calling method that
mandates a transaction.");
         }
 
         return new TransactionToken(man.getTransaction(), null, MANDATORY);
@@ -47,7 +47,7 @@ public enum TransactionAttribute {
       public TransactionToken begin(TransactionManager man) throws SystemException
       {
         if (man.getStatus() == Status.STATUS_ACTIVE) {
-          throw new IllegalStateException(Constants.MESSAGES.getMessage("tran.found.never"));
+          throw new IllegalStateException("Transaction present when calling method that forbids
a transaction.");
         }
 
         return new TransactionToken(null, null, NEVER);

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java?rev=1695955&r1=1695954&r2=1695955&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java
(original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxComponentMetaDataHelperImpl.java
Fri Aug 14 18:22:14 2015
@@ -82,9 +82,7 @@ public class TxComponentMetaDataHelperIm
                 if (size == 1) {
                     txAttribute = map.get(matches.get(0));
                 } else {
-                    throw new IllegalStateException(
-                                                    Constants.MESSAGES
-                                                        .getMessage("unable.to.apply.patterns",
matches));
+                    throw BundleWideTxDataUtil.unableToApply(matches);
                 }
             }
         }
@@ -117,7 +115,7 @@ public class TxComponentMetaDataHelperIm
           
           for (Pattern p : matches) {
               String pattern = p.pattern();
-              Matcher m = Constants.WILDCARD.matcher(pattern);
+              Matcher m = BundleWideTxDataUtil.WILDCARD.matcher(pattern);
               int count = 0;
               
               while (m.find()) {

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java?rev=1695955&r1=1695954&r2=1695955&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
(original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
Fri Aug 14 18:22:14 2015
@@ -103,7 +103,7 @@ public class TxInterceptorImpl implement
                 token.getTransactionAttribute().finish(tm, token);
             } catch (Exception e) {
                 // We are throwing an exception, so we don't error it out
-                LOGGER.debug(Constants.MESSAGES.getMessage("exception.during.tx.finish"),
e);
+                LOGGER.debug("Exception while completing transaction.", e);
                 throw new TransactionRollbackException(e);
             }
         } else {

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationParser.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationParser.java?rev=1695955&r1=1695954&r2=1695955&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationParser.java
(original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/AnnotationParser.java
Fri Aug 14 18:22:14 2015
@@ -19,13 +19,13 @@
 package org.apache.aries.transaction.parsing;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 import javax.transaction.Transactional;
 
 import org.apache.aries.blueprint.BeanProcessor;
 import org.apache.aries.blueprint.ComponentDefinitionRegistry;
 import org.apache.aries.blueprint.Interceptor;
-import org.apache.aries.transaction.Constants;
 import org.apache.aries.transaction.TxComponentMetaDataHelper;
 import org.apache.aries.transaction.annotations.Transaction;
 import org.apache.aries.transaction.annotations.TransactionPropagationType;
@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
  * on bean class or superclasses.
  */
 public class AnnotationParser implements BeanProcessor {
+    private static final int BANNED_MODIFIERS = Modifier.PRIVATE | Modifier.STATIC;
     private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationParser.class);
 
     private final ComponentDefinitionRegistry cdr;
@@ -137,9 +138,9 @@ public class AnnotationParser implements
     }
 
     private void assertAllowedModifier(Method m) {
-        int modifiers = m.getModifiers();
-        if ((modifiers & Constants.BANNED_MODIFIERS) != 0)
-            throw new IllegalArgumentException(Constants.MESSAGES.getMessage("private.or.static.method",
m));
+        if ((m.getModifiers() & BANNED_MODIFIERS) != 0) {
+            throw new IllegalArgumentException("Transaction annotation is not allowed on
private or static method " + m);
+        }
     }
 
 }

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java?rev=1695955&r1=1695954&r2=1695955&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java
(original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/parsing/TxNamespaceHandler.java
Fri Aug 14 18:22:14 2015
@@ -40,7 +40,6 @@ import org.apache.aries.blueprint.PassTh
 import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
 import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
 import org.apache.aries.transaction.BundleWideTxData;
-import org.apache.aries.transaction.Constants;
 import org.apache.aries.transaction.TxComponentMetaDataHelper;
 import org.apache.aries.transaction.annotations.TransactionPropagationType;
 import org.osgi.framework.Bundle;
@@ -190,7 +189,8 @@ public class TxNamespaceHandler implemen
                 id = props.getProperty(INTERCEPTOR_BLUEPRINT_ID);
             }
         } catch (IOException e) {
-            LOGGER.error(Constants.MESSAGES.getMessage("unable.to.load.provider.props"),
e);
+            LOGGER.error("An IOException occurred while loading the provider "
+                         + "properties. Using the default provider.", e);
         } finally {
             safeClose(is);
         }



Mime
View raw message