You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2013/09/03 11:12:37 UTC

svn commit: r1519607 - in /tomee/tomee/trunk/container: openejb-core/src/main/java/org/apache/openejb/core/timer/quartz/PatchedStdJDBCDelegate.java openejb-loader/src/main/java/org/apache/openejb/loader/Options.java

Author: andygumbrecht
Date: Tue Sep  3 09:12:36 2013
New Revision: 1519607

URL: http://svn.apache.org/r1519607
Log:
Update PatchedStdJDBCDelegate.java
Finals.

Modified:
    tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/quartz/PatchedStdJDBCDelegate.java
    tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/quartz/PatchedStdJDBCDelegate.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/quartz/PatchedStdJDBCDelegate.java?rev=1519607&r1=1519606&r2=1519607&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/quartz/PatchedStdJDBCDelegate.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/quartz/PatchedStdJDBCDelegate.java Tue Sep  3 09:12:36 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.openejb.core.timer.quartz;
 
+import org.quartz.impl.jdbcjobstore.NoSuchDelegateException;
 import org.quartz.impl.jdbcjobstore.StdJDBCDelegate;
 import org.quartz.spi.ClassLoadHelper;
 import org.slf4j.Logger;
@@ -29,29 +30,46 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 
 public class PatchedStdJDBCDelegate extends StdJDBCDelegate {
-    public PatchedStdJDBCDelegate(final Logger logger, final String tablePrefix, final String schedName, final String instanceId, final ClassLoadHelper classLoadHelper) {
-        super(logger, tablePrefix, schedName, instanceId, classLoadHelper);
+
+    public PatchedStdJDBCDelegate(final Logger logger,
+                                  final String tablePrefix,
+                                  final String schedName,
+                                  final String instanceId,
+                                  final ClassLoadHelper classLoadHelper) throws NoSuchDelegateException {
+        initialize(logger, tablePrefix, schedName, instanceId, classLoadHelper, false, null);
+    }
+
+    public PatchedStdJDBCDelegate(final Logger logger,
+                                  final String tablePrefix,
+                                  final String schedName,
+                                  final String instanceId,
+                                  final ClassLoadHelper classLoadHelper,
+                                  final Boolean useProperties) throws NoSuchDelegateException {
+        initialize(logger, tablePrefix, schedName, instanceId, classLoadHelper, useProperties, null);
     }
 
-    public PatchedStdJDBCDelegate(final Logger logger, final String tablePrefix, final String schedName, final String instanceId, final ClassLoadHelper classLoadHelper, final Boolean useProperties) {
-        super(logger, tablePrefix, schedName, instanceId, classLoadHelper, useProperties);
+    public PatchedStdJDBCDelegate(final Logger logger,
+                                  final String tablePrefix,
+                                  final String schedName,
+                                  final String instanceId,
+                                  final ClassLoadHelper classLoadHelper,
+                                  final Boolean useProperties,
+                                  final String initString) throws NoSuchDelegateException {
+        initialize(logger, tablePrefix, schedName, instanceId, classLoadHelper, useProperties, initString);
     }
 
     @Override
     protected Object getObjectFromBlob(final ResultSet rs, final String colName)
-            throws ClassNotFoundException, IOException, SQLException {
+        throws ClassNotFoundException, IOException, SQLException {
         Object obj = null;
 
-        Blob blobLocator = rs.getBlob(colName);
+        final Blob blobLocator = rs.getBlob(colName);
         if (blobLocator != null && blobLocator.length() != 0) {
-            InputStream binaryInput = blobLocator.getBinaryStream();
+            final InputStream binaryInput = blobLocator.getBinaryStream();
 
             if (null != binaryInput) {
-                if (binaryInput instanceof ByteArrayInputStream
-                        && ((ByteArrayInputStream) binaryInput).available() == 0 ) {
-                    //do nothing
-                } else {
-                    ObjectInputStream in = new QuartzObjectInputStream(binaryInput, classLoadHelper);
+                if (!(binaryInput instanceof ByteArrayInputStream) || ((ByteArrayInputStream) binaryInput).available() != 0) {
+                    final ObjectInputStream in = new QuartzObjectInputStream(binaryInput, classLoadHelper);
                     try {
                         obj = in.readObject();
                     } finally {

Modified: tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java?rev=1519607&r1=1519606&r2=1519607&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java (original)
+++ tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java Tue Sep  3 09:12:36 2013
@@ -73,11 +73,11 @@ public class Options {
     private final Options parent;
     private final TomEEPropertyAdapter properties;
 
-    public Options(Properties properties) {
+    public Options(final Properties properties) {
         this(properties, new NullOptions());
     }
 
-    public Options(Properties properties, Options parent) {
+    public Options(final Properties properties, final Options parent) {
         this.parent = parent;
         this.properties = new TomEEPropertyAdapter(properties);
     }
@@ -86,7 +86,7 @@ public class Options {
         return properties.delegate;
     }
 
-    public void setLogger(Log logger) {
+    public void setLogger(final Log logger) {
         parent.setLogger(logger);
     }
 
@@ -94,27 +94,28 @@ public class Options {
         return parent.getLogger();
     }
 
-    public boolean has(String property) {
+    public boolean has(final String property) {
         return properties.containsKey(property) || parent.has(property);
     }
 
-    public String get(String property, String defaultValue) {
-        String value = properties.getProperty(property);
+    public String get(final String property, final String defaultValue) {
+        final String value = properties.getProperty(property);
 
         return value != null ? log(property, value) : parent.get(property, defaultValue);
     }
 
-    public <T> T get(String property, T defaultValue) {
+    @SuppressWarnings("unchecked")
+    public <T> T get(final String property, final T defaultValue) {
         if (defaultValue == null) throw new NullPointerException("defaultValue");
 
-        String value = properties.getProperty(property);
+        final String value = properties.getProperty(property);
 
         if (value == null || value.equals("")) return parent.get(property, defaultValue);
 
         try {
-            Class<?> type = defaultValue.getClass();
-            Constructor<?> constructor = type.getConstructor(String.class);
-            T t = (T) constructor.newInstance(value);
+            final Class<?> type = defaultValue.getClass();
+            final Constructor<?> constructor = type.getConstructor(String.class);
+            final T t = (T) constructor.newInstance(value);
             return log(property, t);
         } catch (Exception e) {
             e.printStackTrace();
@@ -123,8 +124,8 @@ public class Options {
         }
     }
 
-    public int get(String property, int defaultValue) {
-        String value = properties.getProperty(property);
+    public int get(final String property, final int defaultValue) {
+        final String value = properties.getProperty(property);
 
         if (value == null || value.equals("")) return parent.get(property, defaultValue);
 
@@ -136,8 +137,8 @@ public class Options {
         }
     }
 
-    public long get(String property, long defaultValue) {
-        String value = properties.getProperty(property);
+    public long get(final String property, final long defaultValue) {
+        final String value = properties.getProperty(property);
 
         if (value == null || value.equals("")) return parent.get(property, defaultValue);
 
@@ -149,8 +150,8 @@ public class Options {
         }
     }
 
-    public boolean get(String property, boolean defaultValue) {
-        String value = properties.getProperty(property);
+    public boolean get(final String property, final boolean defaultValue) {
+        final String value = properties.getProperty(property);
 
         if (value == null || value.equals("")) return parent.get(property, defaultValue);
 
@@ -162,12 +163,12 @@ public class Options {
         }
     }
 
-    public Class<?> get(String property, Class<?> defaultValue) {
-        String className = properties.getProperty(property);
+    public Class<?> get(final String property, final Class<?> defaultValue) {
+        final String className = properties.getProperty(property);
 
         if (className == null) return parent.get(property, defaultValue);
 
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         try {
             return log(property, classLoader.loadClass(className));
         } catch (Exception e) {
@@ -176,14 +177,14 @@ public class Options {
         }
     }
 
-    public <T extends Enum<T>> T get(String property, T defaultValue) {
-        String value = properties.getProperty(property);
+    public <T extends Enum<T>> T get(final String property, final T defaultValue) {
+        final String value = properties.getProperty(property);
 
         if (value == null || value.equals("")) return parent.get(property, defaultValue);
 
         if (defaultValue == null) throw new IllegalArgumentException("Must supply a default for property " + property);
 
-        Class<T> enumType = (Class<T>) defaultValue.getClass();
+        final Class<T> enumType = (Class<T>) defaultValue.getClass();
 
         try {
             return log(property, valueOf(enumType, value.toUpperCase()));
@@ -193,15 +194,15 @@ public class Options {
         }
     }
 
-    public <T extends Enum<T>> Set<T> getAll(String property, T... defaultValue) {
-        EnumSet<T> defaults = EnumSet.copyOf(Arrays.asList(defaultValue));
+    public <T extends Enum<T>> Set<T> getAll(final String property, final T... defaultValue) {
+        final EnumSet<T> defaults = EnumSet.copyOf(Arrays.asList(defaultValue));
         return getAll(property, defaults);
     }
 
-    public <T extends Enum<T>> Set<T> getAll(String property, Set<T> defaultValue) {
-        Class<T> enumType;
+    public <T extends Enum<T>> Set<T> getAll(final String property, final Set<T> defaultValue) {
+        final Class<T> enumType;
         try {
-            T t = defaultValue.iterator().next();
+            final T t = defaultValue.iterator().next();
             enumType = (Class<T>) t.getClass();
         } catch (Exception e) {
             throw new IllegalArgumentException("Must supply a default for property " + property);
@@ -210,12 +211,12 @@ public class Options {
         return getAll(property, defaultValue, enumType);
     }
 
-    public <T extends Enum<T>> Set<T> getAll(String property, Class<T> enumType) {
+    public <T extends Enum<T>> Set<T> getAll(final String property, final Class<T> enumType) {
         return getAll(property, Collections.EMPTY_SET, enumType);
     }
 
-    protected <T extends Enum<T>> Set<T> getAll(String property, Set<T> defaultValue, Class<T> enumType) {
-        String value = properties.getProperty(property);
+    protected <T extends Enum<T>> Set<T> getAll(final String property, final Set<T> defaultValue, final Class<T> enumType) {
+        final String value = properties.getProperty(property);
 
         if (value == null || value.equals("")) return parent.getAll(property, defaultValue, enumType);
 
@@ -230,8 +231,8 @@ public class Options {
         }
 
         try {
-            String[] values = value.split(",");
-            EnumSet<T> set = EnumSet.noneOf(enumType);
+            final String[] values = value.split(",");
+            final EnumSet<T> set = EnumSet.noneOf(enumType);
 
             for (String s : values) {
                 s = s.trim();
@@ -253,13 +254,13 @@ public class Options {
      * @param <T>
      * @return
      */
-    public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) {
-        Map<String, T> map = new HashMap<String, T>();
-        for (T t : enumType.getEnumConstants()) {
+    public static <T extends Enum<T>> T valueOf(final Class<T> enumType, final String name) {
+        final Map<String, T> map = new HashMap<String, T>();
+        for (final T t : enumType.getEnumConstants()) {
             map.put(t.name().toUpperCase(), t);
         }
 
-        T value = map.get(name.toUpperCase());
+        final T value = map.get(name.toUpperCase());
 
         // Call Enum.valueOf for the clean exception
         if (value == null || value.equals("")) Enum.valueOf(enumType, name);
@@ -267,19 +268,19 @@ public class Options {
         return value;
     }
 
-    private void warn(String property, String value) {
+    private void warn(final String property, final String value) {
         getLogger().warning("Cannot parse supplied value \"" + value + "\" for option \"" + property + "\"");
     }
 
-    private void warn(String property, String value, Exception e) {
+    private void warn(final String property, final String value, final Exception e) {
         getLogger().warning("Cannot parse supplied value \"" + value + "\" for option \"" + property + "\"", e);
     }
 
-    private <V> V log(String property, V value) {
+    private <V> V log(final String property, final V value) {
         if (!getLogger().isInfoEnabled()) return value;
 
         if (value instanceof Class) {
-            Class clazz = (Class) value;
+            final Class clazz = (Class) value;
             getLogger().info("Using \'" + property + "=" + clazz.getName() + "\'");
         } else {
             getLogger().info("Using \'" + property + "=" + value + "\'");
@@ -287,7 +288,7 @@ public class Options {
         return value;
     }
 
-    public <T extends Enum<T>> Set<T> logAll(String property, Set<T> value) {
+    public <T extends Enum<T>> Set<T> logAll(final String property, final Set<T> value) {
         if (!getLogger().isInfoEnabled()) return value;
 
         getLogger().info("Using \'" + property + "=" + join(", ", lowercase(value)) + "\'");
@@ -296,36 +297,36 @@ public class Options {
     }
 
 
-    protected static <T extends Enum<T>> String[] lowercase(T... items) {
-        String[] values = new String[items.length];
+    protected static <T extends Enum<T>> String[] lowercase(final T... items) {
+        final String[] values = new String[items.length];
         for (int i = 0; i < items.length; i++) {
             values[i] = items[i].name().toLowerCase();
         }
         return values;
     }
 
-    protected static <T extends Enum<T>> String[] lowercase(Collection<T> items) {
-        String[] values = new String[items.size()];
+    protected static <T extends Enum<T>> String[] lowercase(final Collection<T> items) {
+        final String[] values = new String[items.size()];
         int i = 0;
-        for (T item : items) {
+        for (final T item : items) {
             values[i++] = item.name().toLowerCase();
         }
         return values;
     }
 
-    protected static <V extends Enum<V>> String possibleValues(V v) {
-        Class<? extends Enum> enumType = v.getClass();
+    protected static <V extends Enum<V>> String possibleValues(final V v) {
+        final Class<? extends Enum> enumType = v.getClass();
         return possibleValues(enumType);
     }
 
-    protected static String possibleValues(Class<? extends Enum> enumType) {
+    protected static String possibleValues(final Class<? extends Enum> enumType) {
         return join(", ", lowercase(enumType.getEnumConstants()));
     }
 
 
-    public static String join(String delimiter, Object... collection) {
-        StringBuilder sb = new StringBuilder();
-        for (Object obj : collection) {
+    public static String join(final String delimiter, final Object... collection) {
+        final StringBuilder sb = new StringBuilder();
+        for (final Object obj : collection) {
             sb.append(obj).append(delimiter);
         }
         if (collection.length > 0) sb.delete(sb.length() - delimiter.length(), sb.length());
@@ -347,53 +348,53 @@ public class Options {
         }
 
         @Override
-        public void setLogger(Log logger) {
+        public void setLogger(final Log logger) {
             this.logger = logger;
         }
 
         @Override
-        public boolean has(String property) {
+        public boolean has(final String property) {
             return false;
         }
 
         @Override
-        public <T> T get(String property, T defaultValue) {
+        public <T> T get(final String property, final T defaultValue) {
             return log(property, defaultValue);
         }
 
         @Override
-        public int get(String property, int defaultValue) {
+        public int get(final String property, final int defaultValue) {
             return log(property, defaultValue);
         }
 
         @Override
-        public long get(String property, long defaultValue) {
+        public long get(final String property, final long defaultValue) {
             return log(property, defaultValue);
         }
 
         @Override
-        public boolean get(String property, boolean defaultValue) {
+        public boolean get(final String property, final boolean defaultValue) {
             return log(property, defaultValue);
         }
 
         @Override
-        public <T extends Enum<T>> T get(String property, T defaultValue) {
+        public <T extends Enum<T>> T get(final String property, final T defaultValue) {
             return log(property, defaultValue);
         }
 
         @Override
-        public <T extends Enum<T>> Set<T> getAll(String property, T... defaultValue) {
+        public <T extends Enum<T>> Set<T> getAll(final String property, final T... defaultValue) {
             return EnumSet.copyOf(Arrays.asList(defaultValue));
         }
 
         @Override
-        protected <T extends Enum<T>> Set<T> getAll(String property, Set<T> defaults, Class<T> enumType) {
+        protected <T extends Enum<T>> Set<T> getAll(final String property, final Set<T> defaults, final Class<T> enumType) {
             if (getLogger().isDebugEnabled()) {
                 String possibleValues = "  Possible values are: " + possibleValues(enumType);
 
                 possibleValues += " or NONE or ALL";
 
-                String defaultValues;
+                final String defaultValues;
 
                 if (defaults.size() == 0) {
                     defaultValues = "NONE";
@@ -410,22 +411,22 @@ public class Options {
         }
 
         @Override
-        public String get(String property, String defaultValue) {
+        public String get(final String property, final String defaultValue) {
             return log(property, defaultValue);
         }
 
         @Override
-        public Class<?> get(String property, Class<?> defaultValue) {
+        public Class<?> get(final String property, final Class<?> defaultValue) {
             return log(property, defaultValue);
         }
 
-        private <V> V log(String property, V value) {
+        private <V> V log(final String property, final V value) {
             if (getLogger().isDebugEnabled()) {
                 if (value instanceof Enum) {
-                    Enum anEnum = (Enum) value;
+                    final Enum anEnum = (Enum) value;
                     getLogger().debug("Using default \'" + property + "=" + anEnum.name().toLowerCase() + "\'.  Possible values are: " + possibleValues(anEnum));
                 } else if (value instanceof Class) {
-                    Class clazz = (Class) value;
+                    final Class clazz = (Class) value;
                     getLogger().debug("Using default \'" + property + "=" + clazz.getName() + "\'");
                 } else if (value != null) {
                     logger.debug("Using default \'" + property + "=" + value + "\'");
@@ -442,11 +443,11 @@ public class Options {
         public static final int OPENEJB_PREFIX_LENGHT = "openejb.".length();
         private Properties delegate;
 
-        public TomEEPropertyAdapter(Properties properties) {
+        public TomEEPropertyAdapter(final Properties properties) {
             this.delegate = properties;
         }
 
-        public String getProperty(String key) {
+        public String getProperty(final String key) {
             String value = delegate.getProperty(key);
 
             if (value == null && key.startsWith("openejb.")) {
@@ -456,12 +457,12 @@ public class Options {
             return value;
         }
 
-        public boolean containsKey(String key) {
+        public boolean containsKey(final String key) {
             return delegate.containsKey(key)
                     || delegate.containsKey(getTomeeKey(key));
         }
 
-        private String getTomeeKey(String key) {
+        private String getTomeeKey(final String key) {
             return "tomee." + key.substring(OPENEJB_PREFIX_LENGHT);
         }
     }
@@ -487,34 +488,43 @@ public class Options {
     }
 
     public static class NullLog implements Log {
+        @Override
         public boolean isDebugEnabled() {
             return false;
         }
 
+        @Override
         public boolean isInfoEnabled() {
             return false;
         }
 
+        @Override
         public boolean isWarningEnabled() {
             return false;
         }
 
-        public void warning(String message, Throwable t) {
+        @Override
+        public void warning(final String message, final Throwable t) {
         }
 
-        public void warning(String message) {
+        @Override
+        public void warning(final String message) {
         }
 
-        public void debug(String message, Throwable t) {
+        @Override
+        public void debug(final String message, final Throwable t) {
         }
 
-        public void debug(String message) {
+        @Override
+        public void debug(final String message) {
         }
 
-        public void info(String message, Throwable t) {
+        @Override
+        public void info(final String message, final Throwable t) {
         }
 
-        public void info(String message) {
+        @Override
+        public void info(final String message) {
         }
     }
 }