XSQL: cache ClasLoader reference 52/16952/1
authorRobert Varga <rovarga@cisco.com>
Sun, 22 Mar 2015 13:50:23 +0000 (14:50 +0100)
committerRobert Varga <rovarga@cisco.com>
Sun, 22 Mar 2015 13:51:17 +0000 (14:51 +0100)
Instead of looking up the class loader on each invocation, cache it
once. Same goes for the list of interfaces being instantiated.

Change-Id: I3954f65e167c57d090579eeef8924e5cc6fedfed
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCResultSet.java

index dd9972f47c8e250755ad96ed47569ea696a31ff3..6689908204e19e9aced43dccbb28d2dd5a8f2c07 100644 (file)
@@ -41,6 +41,8 @@ import org.opendaylight.controller.md.sal.dom.xsql.XSQLODLUtils;
 public class JDBCResultSet implements Serializable, ResultSet,
         ResultSetMetaData {
     private static final long serialVersionUID = -7450200738431047057L;
+    private static final ClassLoader CLASS_LOADER = JDBCResultSet.class.getClassLoader();
+    private static final Class<?>[] PROXY_INTERFACES = new Class[] { ResultSet.class };
     private static int nextID = 0;
 
     private String sql = null;
@@ -58,7 +60,7 @@ public class JDBCResultSet implements Serializable, ResultSet,
     private transient Map<String,JDBCResultSet> subQueries = new HashMap<String,JDBCResultSet>();
 
     public ResultSet getProxy() {
-         return (ResultSet) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {ResultSet.class }, new JDBCProxy(this));
+         return (ResultSet) Proxy.newProxyInstance(CLASS_LOADER, PROXY_INTERFACES, new JDBCProxy(this));
     }
 
     public void setSQL(String _sql) {