You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2016/12/08 15:44:08 UTC

svn commit: r1773256 - in /qpid/java/branches/6.1.x: ./ broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/ broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/ broker-plugins/derby-store/src/main/...

Author: kwall
Date: Thu Dec  8 15:44:08 2016
New Revision: 1773256

URL: http://svn.apache.org/viewvc?rev=1773256&view=rev
Log:
QPID-7561 : Only make Derby backed VirtualHost(Node)s available if the derby driver is present

Merged from trunk with command:

svn merge -c 1772241  ^/qpid/java/trunk

Modified:
    qpid/java/branches/6.1.x/   (props changed)
    qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java
    qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java
    qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java

Propchange: qpid/java/branches/6.1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 15:44:08 2016
@@ -9,5 +9,5 @@
 /qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1766544,1766547,1766553,1766666,1766796-1766797,1766806,1767251,1767267-1767268,1767275,1767310,1767326,1767329,1767332,1767514,1767523,1767738,1767825,1767847-1767849,1767882,1767909,1767914,1768016-1768017,1768065,1768643,1768704,1768854,1768875,1768914,1768963,1768967,1768976,1769007,1769009,1769087,1769138-1769139,1769597,1769879,1770236,1770716
+/qpid/java/trunk:1766544,1766547,1766553,1766666,1766796-1766797,1766806,1767251,1767267-1767268,1767275,1767310,1767326,1767329,1767332,1767514,1767523,1767738,1767825,1767847-1767849,1767882,1767909,1767914,1768016-1768017,1768065,1768643,1768704,1768854,1768875,1768914,1768963,1768967,1768976,1769007,1769009,1769087,1769138-1769139,1769597,1769879,1770236,1770716,1772241
 /qpid/trunk/qpid:796646-796653

Modified: qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java?rev=1773256&r1=1773255&r2=1773256&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java (original)
+++ qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java Thu Dec  8 15:44:08 2016
@@ -24,7 +24,7 @@ package org.apache.qpid.server.store.der
 import java.io.File;
 import java.io.IOException;
 import java.io.Writer;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.sql.Blob;
 import java.sql.Connection;
 import java.sql.Driver;
@@ -40,15 +40,14 @@ import org.apache.qpid.server.store.Stor
 
 public class DerbyUtils
 {
-    public static final String MEMORY_STORE_LOCATION = ":memory:";
-    public static final String DERBY_SINGLE_DB_SHUTDOWN_CODE = "08006";
+    static final String MEMORY_STORE_LOCATION = ":memory:";
+    private static final String DERBY_SINGLE_DB_SHUTDOWN_CODE = "08006";
     private static final String SQL_DRIVER_NAME = "org.apache.derby.jdbc.EmbeddedDriver";
     private static final String TABLE_EXISTENCE_QUERY = "SELECT 1 FROM SYS.SYSTABLES WHERE TABLENAME = ?";
-    private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
 
     private static final Logger DERBY_LOG = LoggerFactory.getLogger("DERBY");
-    public static final DerbyLogWriter DERBY_LOG_WRITER = new DerbyLogWriter();
-    public static final String DERBY_STREAM_ERROR_METHOD = "derby.stream.error.method";
+    private static final DerbyLogWriter DERBY_LOG_WRITER = new DerbyLogWriter();
+    private static final String DERBY_STREAM_ERROR_METHOD = "derby.stream.error.method";
 
     public static void configureDerbyLogging()
     {
@@ -59,6 +58,19 @@ public class DerbyUtils
         }
     }
 
+    public static boolean isAvailable()
+    {
+        try
+        {
+            Class.forName(SQL_DRIVER_NAME);
+            return true;
+        }
+        catch (ClassNotFoundException | NoClassDefFoundError e)
+        {
+            return false;
+        }
+    }
+
     public static void loadDerbyDriver()
     {
         try
@@ -136,7 +148,7 @@ public class DerbyUtils
             return null;
         }
         byte[] bytes = blob.getBytes(1, (int) blob.length());
-        return new String(bytes, UTF8_CHARSET);
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 
     protected static byte[] getBlobAsBytes(ResultSet rs, int col) throws SQLException

Modified: qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java?rev=1773256&r1=1773255&r2=1773256&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java (original)
+++ qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java Thu Dec  8 15:44:08 2016
@@ -52,7 +52,7 @@ public class DerbyVirtualHostImpl extend
     @ManagedAttributeField
     private Long _storeOverfullSize;
 
-    @ManagedObjectFactoryConstructor
+    @ManagedObjectFactoryConstructor(conditionallyAvailable = true, condition = "org.apache.qpid.server.store.derby.DerbyUtils#isAvailable()")
     public DerbyVirtualHostImpl(final Map<String, Object> attributes,
                                 final VirtualHostNode<?> virtualHostNode)
     {

Modified: qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java?rev=1773256&r1=1773255&r2=1773256&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java (original)
+++ qpid/java/branches/6.1.x/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java Thu Dec  8 15:44:08 2016
@@ -54,7 +54,7 @@ public class DerbyVirtualHostNodeImpl ex
     @ManagedAttributeField
     private String _storePath;
 
-    @ManagedObjectFactoryConstructor
+    @ManagedObjectFactoryConstructor(conditionallyAvailable = true, condition = "org.apache.qpid.server.store.derby.DerbyUtils#isAvailable()")
     public DerbyVirtualHostNodeImpl(Map<String, Object> attributes, Broker<?> parent)
     {
         super(attributes, parent);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org