You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2016/12/01 17:48:56 UTC

svn commit: r1772241 - in /qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server: store/derby/DerbyUtils.java virtualhost/derby/DerbyVirtualHostImpl.java virtualhostnode/derby/DerbyVirtualHostNodeImpl.java

Author: rgodfrey
Date: Thu Dec  1 17:48:56 2016
New Revision: 1772241

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

Modified:
    qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java
    qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java
    qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java

Modified: qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java?rev=1772241&r1=1772240&r2=1772241&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java (original)
+++ qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyUtils.java Thu Dec  1 17:48:56 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/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java?rev=1772241&r1=1772240&r2=1772241&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java (original)
+++ qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHostImpl.java Thu Dec  1 17:48:56 2016
@@ -50,7 +50,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/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java?rev=1772241&r1=1772240&r2=1772241&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java (original)
+++ qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java Thu Dec  1 17:48:56 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