db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1432380 - in /db/derby/code/trunk: java/client/org/apache/derby/jdbc/ java/drda/org/apache/derby/impl/drda/ java/engine/org/apache/derby/ java/engine/org/apache/derby/iapi/services/info/ java/engine/org/apache/derby/jdbc/ java/testing/org/...
Date Sat, 12 Jan 2013 04:16:49 GMT
Author: dag
Date: Sat Jan 12 04:16:49 2013
New Revision: 1432380

URL: http://svn.apache.org/viewvc?rev=1432380&view=rev
Log:
DERBY-5955 Prepare Derby to run with Compact Profiles (JEP 161)

Patch derby-5955-new-non-jndi-ds-02. This introduced the six (three
for embedded, three for client drivers) new reduced functionality data
sources that will work in the absence of JNDI. It adds a sanity test
which will run even on a full Java SE platform. Full tests to be
exercised when running in a constrained environment will follow in a
subsequent patch.



Added:
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientConnectionPoolDataSource40.java
  (with props)
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientDataSource40.java 
 (with props)
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientXADataSource40.java
  (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedConnectionPoolDataSource40.java
  (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedDataSource40.java
  (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedXADataSource40.java
  (with props)
Modified:
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/XADatabase.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java
    db/derby/code/trunk/java/engine/org/apache/derby/modules.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
    db/derby/code/trunk/tools/jar/dnc.properties
    db/derby/code/trunk/tools/jar/extraDBMSclasses.properties
    db/derby/code/trunk/tools/javadoc/publishedapi_jdbc4.ant

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java?rev=1432380&r1=1432379&r2=1432380&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java Sat
Jan 12 04:16:49 2013
@@ -52,7 +52,7 @@ import org.apache.derby.shared.common.re
 public abstract class ClientBaseDataSourceRoot implements
         Serializable, ClientDataSourceInterface {
 
-    static final long serialVersionUID = -7660172643035173693L;
+    private static final long serialVersionUID = -7660172643035173693L;
 
     // Spec requires DH algorithm with 32bytes prime to be used
     // Not all JCE implementations have support for this. E.g.

Added: db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientConnectionPoolDataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientConnectionPoolDataSource40.java?rev=1432380&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientConnectionPoolDataSource40.java
(added)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientConnectionPoolDataSource40.java
Sat Jan 12 04:16:49 2013
@@ -0,0 +1,154 @@
+/*
+
+   Derby - Class org.apache.derby.jdbc.NonJNDIClientConnectionPoolDataSource40
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+*/
+
+package org.apache.derby.jdbc;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.sql.SQLException;
+import javax.sql.PooledConnection;
+import org.apache.derby.shared.common.i18n.MessageUtil;
+import org.apache.derby.shared.common.reference.MessageId;
+
+/**
+ * NonJNDIClientConnectionPoolDataSource40 is similar to
+ * ClientConnectionPoolDataSource40 except that it does not support JNDI,
+ * i.e. it does not implement {@code javax.naming.Referenceable}.
+ *
+ * @see ClientConnectionPoolDataSource40
+ */
+public class NonJNDIClientConnectionPoolDataSource40
+        extends NonJNDIClientDataSource40
+        implements javax.sql.ConnectionPoolDataSource,
+                   ClientConnectionPoolDataSourceInterface {
+
+    private static final long serialVersionUID = -539234282156481378L;
+
+    /** Message utility used to obtain localized messages. */
+    private static final MessageUtil msgUtil =
+            new MessageUtil("org.apache.derby.loc.clientmessages");
+
+    public static final String className__ =
+            "org.apache.derby.jdbc.NonJNDIClientConnectionPoolDataSource40";
+
+    /**
+     * Specifies the maximum number of statements that can be cached per
+     * connection by the JDBC driver.
+     * <p>
+     * A value of {@code 0} disables statement caching, negative values
+     * are not allowed. The default is that caching is disabled.
+     *
+     * @serial
+     */
+    private int maxStatements = 0;
+
+    public NonJNDIClientConnectionPoolDataSource40() {
+        super();
+    }
+
+    // ---------------------------interface methods----------------------------
+
+    /**
+     * @see javax.sql.ConnectionPoolDataSource#getPooledConnection()
+     */
+    public PooledConnection getPooledConnection() throws SQLException {
+        return getPooledConnectionMinion();
+    }
+
+    /**
+     * @see javax.sql.ConnectionPoolDataSource#getPooledConnection(
+     *      java.lang.String, java.lang.String)
+     */
+    public PooledConnection getPooledConnection(String user, String password)
+            throws SQLException {
+
+        return getPooledConnectionMinion(user, password);
+    }
+
+
+    /**
+     * Specifies the maximum size of the statement cache.
+     *
+     * @param maxStatements maximum number of cached statements
+     *
+     * @throws IllegalArgumentException if {@code maxStatements} is
+     *      negative
+     */
+    public void setMaxStatements(int maxStatements) {
+        // Disallow negative values.
+        if (maxStatements < 0) {
+            throw new IllegalArgumentException(msgUtil.getTextMessage(
+                    MessageId.CONN_NEGATIVE_MAXSTATEMENTS, maxStatements));
+        }
+
+        this.maxStatements = maxStatements;
+    }
+
+    /**
+     * Returns the maximum number of JDBC prepared statements a connection is
+     * allowed to cache.
+     *
+     * @return Maximum number of statements to cache, or {@code 0} if
+     *      caching is disabled (default).
+     */
+    public int getMaxStatements() {
+        return this.maxStatements;
+    }
+
+    /**
+     * Internally used method.
+     *
+     * @see ClientBaseDataSourceRoot#maxStatementsToPool
+     */
+    public int maxStatementsToPool() {
+        return this.maxStatements;
+    }
+
+    /**
+     * Make sure the state of the de-serialized object is valid.
+     */
+    private final void validateState() {
+        // Make sure maxStatements is zero or higher.
+        if (maxStatements < 0) {
+            throw new IllegalArgumentException(msgUtil.getTextMessage(
+                    MessageId.CONN_NEGATIVE_MAXSTATEMENTS, maxStatements));
+        }
+    }
+
+    /**
+     * Read an object from the ObjectInputStream.
+     * <p>
+     * This implementation differs from the default one by initiating state
+     * validation of the object created.
+     *
+     * @param inputStream data stream to read objects from
+     * @throws ClassNotFoundException if instantiating a class fails
+     * @throws IOException if reading from the stream fails
+     */
+    private void readObject(ObjectInputStream inputStream)
+            throws ClassNotFoundException, IOException {
+        // Always perform the default de-serialization first
+        inputStream.defaultReadObject();
+
+        // Ensure that object state has not been corrupted or tampered with.
+        validateState();
+    }
+}

Propchange: db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientConnectionPoolDataSource40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientDataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientDataSource40.java?rev=1432380&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientDataSource40.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientDataSource40.java Sat
Jan 12 04:16:49 2013
@@ -0,0 +1,72 @@
+/*
+
+   Derby - Class org.apache.derby.jdbc.NonJNDIClientDataSource40
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.jdbc;
+
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.logging.Logger;
+import javax.sql.DataSource;
+import org.apache.derby.client.am.ClientMessageId;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.shared.common.reference.SQLState;
+
+/**
+ * NonJNDIClientDataSource40 is similar to ClientDataSource40 except it
+ * can not be used with JNDI, i.e. it does not implement
+ * {@code javax.naming.Referenceable}.
+ */
+public class NonJNDIClientDataSource40
+    extends ClientBaseDataSourceRoot implements DataSource {
+
+    private final static long serialVersionUID = 1894299584216955554L;
+    public final static String className__ =
+            "org.apache.derby.jdbc.NonJNDIClientDataSource40";
+
+    /**
+     * Creates a simple DERBY data source with default property values
+     * for a non-pooling, non-distributed environment.  No particular
+     * DatabaseName or other properties are associated with the data
+     * source.
+     * <p/>
+     * Every Java Bean should provide a constructor with no arguments
+     * since many beanboxes attempt to instantiate a bean by invoking
+     * its no-argument constructor.
+     */
+    public NonJNDIClientDataSource40() {
+        super();
+    }
+
+
+    ////////////////////////////////////////////////////////////////////
+    //
+    // INTRODUCED BY JDBC 4.1 IN JAVA 7
+    //
+    ////////////////////////////////////////////////////////////////////
+
+    public  Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        SqlException e = new SqlException(
+                null,
+                new ClientMessageId(SQLState.NOT_IMPLEMENTED),
+                "getParentLogger");
+
+        throw (SQLFeatureNotSupportedException)e.getSQLException();
+    }
+}

Propchange: db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientDataSource40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientXADataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientXADataSource40.java?rev=1432380&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientXADataSource40.java
(added)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientXADataSource40.java
Sat Jan 12 04:16:49 2013
@@ -0,0 +1,56 @@
+/*
+
+   Derby - Class org.apache.derby.jdbc.NonJNDIClientXADataSource40
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+*/
+
+package org.apache.derby.jdbc;
+
+import java.sql.SQLException;
+import javax.sql.XAConnection;
+import javax.sql.XADataSource;
+
+/**
+ * Similar to ClientXADataSource40 except it does not support JNDI,
+ * i.e. it does not implement {@code javax.naming.Referenceable}.
+ */
+public class NonJNDIClientXADataSource40
+    extends NonJNDIClientDataSource40
+    implements ClientXADataSourceInterface,
+               XADataSource /* compile-time check of 41 extensions */ {
+
+    public static final String className__ =
+        "org.apache.derby.jdbc.NonJNDIClientXADataSource40";
+
+    // following serialVersionUID was generated by the JDK's serialver program
+    // verify it everytime that ClientXADataSource is modified
+    private static final long serialVersionUID = 7057075094707674881L;
+
+    public NonJNDIClientXADataSource40() {
+    }
+
+    public XAConnection getXAConnection() throws SQLException {
+        return getXAConnectionMinion();
+    }
+
+    public XAConnection getXAConnection(String user, String password)
+        throws SQLException {
+
+        return getXAConnectionMinion(user, password);
+    }
+}

Propchange: db/derby/code/trunk/java/client/org/apache/derby/jdbc/NonJNDIClientXADataSource40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/XADatabase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/XADatabase.java?rev=1432380&r1=1432379&r2=1432380&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/XADatabase.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/XADatabase.java Sat Jan 12 04:16:49
2013
@@ -62,9 +62,28 @@ class XADatabase extends Database {
     synchronized void makeConnection(Properties p) throws
  SQLException
     {
-        if (xaDataSource == null)
-        {
-            xaDataSource = new EmbeddedXADataSource();
+        if (xaDataSource == null) {
+            try {
+                if (JVMInfo.hasJNDI()) {
+                    xaDataSource =
+                        (EmbeddedXADataSourceInterface)Class.forName(
+                        "org.apache.derby.jdbc.EmbeddedXADataSource").
+                        newInstance();
+                } else {
+                    xaDataSource =
+                        (EmbeddedXADataSourceInterface)Class.forName(
+                        "org.apache.derby.jdbc.NonJNDIEmbeddedXADataSource40").
+                        newInstance();
+                }
+            } catch (Exception e) {
+                SQLException ne = new SQLException(
+                        MessageService.getTextMessage(
+                            MessageId.CORE_DATABASE_NOT_AVAILABLE),
+                        "08006",
+                        ExceptionSeverity.DATABASE_SEVERITY);
+                ne.initCause(e);
+                throw ne;
+            }
         }
 
         xaDataSource.setDatabaseName(getShortDbName());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java?rev=1432380&r1=1432379&r2=1432380&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java Sat Jan
12 04:16:49 2013
@@ -254,4 +254,17 @@ public abstract class JVMInfo
             }
         }
     }
+
+    /**
+     * Determine whether we are running in a constrained environment.
+     * @return true if JNDI is available
+     */
+    public static boolean hasJNDI() {
+        try {
+            Class.forName("javax.naming.Referenceable");
+        } catch (ClassNotFoundException e) {
+            return false;
+        }
+        return true;
+    }
 }

Added: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedConnectionPoolDataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedConnectionPoolDataSource40.java?rev=1432380&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedConnectionPoolDataSource40.java
(added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedConnectionPoolDataSource40.java
Sat Jan 12 04:16:49 2013
@@ -0,0 +1,88 @@
+/*
+
+   Derby - Class org.apache.derby.jdbc.NonJNDIEmbeddedConnectionPoolDataSource40
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.derby.jdbc;
+
+import java.sql.SQLException;
+import javax.sql.PooledConnection;
+
+/**
+ * NonJNDIEmbeddedConnectionPoolDataSource40 is similar to
+ * EmbeddedConnectionPoolDataSource40 except it does not support JNDI naming,
+ * i.e. it does not implement {@code javax.naming.Referenceable}.
+ *
+ * @see EmbeddedConnectionPoolDataSource40
+ */
+public class NonJNDIEmbeddedConnectionPoolDataSource40
+    extends NonJNDIEmbeddedDataSource40
+    implements javax.sql.ConnectionPoolDataSource,
+        EmbeddedConnectionPoolDataSourceInterface {
+
+    private static final long serialVersionUID = 7852784308039674161L;
+
+    /**
+     *  No-argument constructor.
+     */
+    public NonJNDIEmbeddedConnectionPoolDataSource40() {
+        super();
+    }
+
+    /*
+     * Implementation of ConnectionPoolDataSource interface methods
+     */
+
+    /**
+     * @see javax.sql.ConnectionPoolDataSource#getPooledConnection()
+     */
+    public final PooledConnection getPooledConnection() throws SQLException {
+        return createPooledConnection (getUser(), getPassword(), false);
+    }
+
+    /**
+     * @see javax.sql.ConnectionPoolDataSource#getPooledConnection(
+     *      String, String)
+     */
+    public final PooledConnection getPooledConnection(
+            String username,
+            String password) throws SQLException {
+
+        return createPooledConnection (username, password, true);
+    }
+
+    /**
+     * Minion helper method. Create and return a pooled connection
+     *
+     * @param user the user name used to authenticate the connection
+     * @param password the user's password
+     * @param requestPassword {@code false} if original call is from a
+     *        no-argument constructor, otherwise {@code true}
+     *
+     * @return a connection to the database
+     * @throws SQLException if a database-access error occurs
+     */
+    private PooledConnection createPooledConnection (
+            String user,
+            String password,
+            boolean requestPassword) throws SQLException {
+
+        return ((Driver30) findDriver()).getNewPooledConnection(
+            this, user, password, requestPassword);
+    }
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedConnectionPoolDataSource40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedDataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedDataSource40.java?rev=1432380&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedDataSource40.java
(added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedDataSource40.java
Sat Jan 12 04:16:49 2013
@@ -0,0 +1,53 @@
+/*
+
+   Derby - Class org.apache.derby.jdbc.NonJNDIEmbeddedDataSource40
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.jdbc;
+
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.logging.Logger;
+import org.apache.derby.impl.jdbc.Util;
+
+/**
+ *
+ * NonJNDIEmbeddedDataSource40 is similar to EmbeddedDataSource40, but does
+ * not support JNDI naming, i.e. it does not implement
+ * {@code javax.naming.Referenceable}.
+ *
+ * @see EmbeddedDataSource40
+ */
+ public class NonJNDIEmbeddedDataSource40 extends EmbeddedBaseDataSource
+    implements javax.sql.DataSource {
+
+   private static final long serialVersionUID = -4945135214995641182L;
+
+    public NonJNDIEmbeddedDataSource40() {}
+
+    ////////////////////////////////////////////////////////////////////
+    //
+    // INTRODUCED BY JDBC 4.1 IN JAVA 7
+    //
+    ////////////////////////////////////////////////////////////////////
+
+    public  Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        throw (SQLFeatureNotSupportedException)Util.notImplemented(
+                "getParentLogger()");
+    }
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedDataSource40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedXADataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedXADataSource40.java?rev=1432380&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedXADataSource40.java
(added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedXADataSource40.java
Sat Jan 12 04:16:49 2013
@@ -0,0 +1,115 @@
+/*
+
+   Derby - Class org.apache.derby.jdbc.NonJNDIEmbeddedXADataSource40
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.jdbc;
+
+import java.sql.SQLException;
+import javax.sql.XAConnection;
+import org.apache.derby.iapi.jdbc.ResourceAdapter;
+
+/**
+ *
+ * NonJNDIEmbeddedXADataSource40 is similar to
+ * EmbeddedXADataSource40, except that it does not support JNDI
+ * naming, i.e. it does not implement {@code javax.naming.Referenceable}.
+ *
+ * @see EmbeddedXADataSource40
+ */
+public class NonJNDIEmbeddedXADataSource40
+    extends NonJNDIEmbeddedDataSource40
+    implements
+        EmbeddedXADataSourceInterface,
+        javax.sql.XADataSource /* compile time check of 41 extensions */
+{
+
+    private static final long serialVersionUID = -5715798975598379739L;
+
+    // link to the database
+    private transient ResourceAdapter ra;
+
+    public NonJNDIEmbeddedXADataSource40() {
+        super();
+    }
+
+    /*
+     * Implementation of XADataSource interface methods
+     */
+
+    /**
+     * @see javax.sql.XADataSource#getXAConnection()
+     */
+    public final XAConnection getXAConnection() throws SQLException     {
+
+        if (ra == null || !ra.isActive()) {
+            ra = setupResourceAdapter(this, ra, null, null, false);
+        }
+
+        return createXAConnection (ra, getUser(), getPassword(), false);
+    }
+
+    /**
+     * @see javax.sql.XADataSource#getXAConnection(String, String)
+     */
+    public final XAConnection getXAConnection(String user, String password)
+         throws SQLException {
+
+        if (ra == null || !ra.isActive()) {
+            ra = setupResourceAdapter(this, ra, user, password, true);
+        }
+
+        return createXAConnection (ra, user, password, true);
+    }
+
+    // implementation methods
+    protected void update() {
+        ra = null;
+        super.update();
+    }
+
+
+    /**
+     * Instantiate and return an EmbedXAConnection from this instance
+     * of EmbeddedXADataSource.
+     *
+     * @param user
+     * @param password
+     * @return XAConnection
+     * @throws SQLException if a connection can't be created
+     */
+    private XAConnection createXAConnection(
+            ResourceAdapter ra,
+            String user,
+            String password,
+            boolean requestPassword) throws SQLException {
+
+        // See comment for EmbeddedXADataSource#createXAConnection
+        return ((Driver30) findDriver()).getNewXAConnection(
+            this, ra, user, password, requestPassword);
+    }
+
+
+    /**
+     * @return The ResourceAdapter instance for the underlying database
+     */
+    public ResourceAdapter getResourceAdapter() {
+        return ra;
+    }
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/NonJNDIEmbeddedXADataSource40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/modules.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/modules.properties?rev=1432380&r1=1432379&r2=1432380&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/modules.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/modules.properties Sat Jan 12 04:16:49
2013
@@ -193,7 +193,7 @@ cloudscape.config.jdbcJ6=derby
 #
 derby.module.resourceAdapterJ2=org.apache.derby.jdbc.ResourceAdapterImpl
 derby.env.jdk.resourceAdapterJ2=2
-derby.env.classes.resourceAdapterJ2=javax.transaction.xa.Xid,javax.transaction.xa.XAResource,javax.transaction.xa.XAException,javax.sql.DataSource,javax.sql.ConnectionPoolDataSource,javax.sql.PooledConnection,javax.sql.XAConnection,javax.sql.XADataSource,javax.naming.spi.Resolver,javax.naming.Referenceable,javax.naming.directory.Attribute
+derby.env.classes.resourceAdapterJ2=javax.transaction.xa.Xid,javax.transaction.xa.XAResource,javax.transaction.xa.XAException,javax.sql.DataSource,javax.sql.ConnectionPoolDataSource,javax.sql.PooledConnection,javax.sql.XAConnection,javax.sql.XADataSource
 cloudscape.config.resourceAdapterJ2=derby
 
 derby.module.streams=org.apache.derby.impl.services.stream.SingleStream

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java?rev=1432380&r1=1432379&r2=1432380&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
Sat Jan 12 04:16:49 2013
@@ -38,6 +38,7 @@ import junit.framework.TestSuite;
 import org.apache.derby.jdbc.ClientDataSource;
 import org.apache.derby.jdbc.EmbeddedDataSource;
 import org.apache.derby.jdbc.EmbeddedSimpleDataSource;
+import org.apache.derby.jdbc.NonJNDIEmbeddedDataSource40;
 import org.apache.derbyTesting.functionTests.util.SecurityCheck;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
@@ -216,6 +217,13 @@ public class DataSourceTest extends Base
             assertConnectionOK(
                 expectedValues, "SimpleDataSource", ds.getConnection());
         }
+
+        if (JDBC.vmSupportsJDBC4()) {
+            NonJNDIEmbeddedDataSource40 nds = new NonJNDIEmbeddedDataSource40();
+            nds.setDatabaseName(dbName);
+            assertConnectionOK(
+                    expectedValues, "NonJNDIDataSource", nds.getConnection());
+        }
     }            
     
     // test jira-derby 95 - a NullPointerException was returned when passing

Modified: db/derby/code/trunk/tools/jar/dnc.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/dnc.properties?rev=1432380&r1=1432379&r2=1432380&view=diff
==============================================================================
--- db/derby/code/trunk/tools/jar/dnc.properties (original)
+++ db/derby/code/trunk/tools/jar/dnc.properties Sat Jan 12 04:16:49 2013
@@ -21,17 +21,20 @@ derby.module.client.dsfactory=org.apache
 
 # Plain data sources
 derby.module.client.40ds=org.apache.derby.jdbc.ClientDataSource40
+derby.module.client.40njds=org.apache.derby.jdbc.NonJNDIClientDataSource40
 
 # Pooled data source
 derby.module.client.cpds=org.apache.derby.jdbc.ClientConnectionPoolDataSource
 derby.module.client.40cpds=org.apache.derby.jdbc.ClientConnectionPoolDataSource40
+derby.module.client.40njcpds=org.apache.derby.jdbc.NonJNDIClientConnectionPoolDataSource40
 
 # XA data sources
 derby.module.client.xads=org.apache.derby.jdbc.ClientXADataSource
 derby.module.client.40xads=org.apache.derby.jdbc.ClientXADataSource40
+derby.module.client.40njxads=org.apache.derby.jdbc.NonJNDIClientXADataSource40
 
 derby.module.client.40cp=org.apache.derby.client.ClientPooledConnection40
 derby.module.client.40nc=org.apache.derby.client.net.NetConnection40
 derby.module.client.40cjof=org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40
 
-derby.module.shared.threaddump=org.apache.derby.shared.common.sanity.ThreadDump
\ No newline at end of file
+derby.module.shared.threaddump=org.apache.derby.shared.common.sanity.ThreadDump

Modified: db/derby/code/trunk/tools/jar/extraDBMSclasses.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/extraDBMSclasses.properties?rev=1432380&r1=1432379&r2=1432380&view=diff
==============================================================================
--- db/derby/code/trunk/tools/jar/extraDBMSclasses.properties (original)
+++ db/derby/code/trunk/tools/jar/extraDBMSclasses.properties Sat Jan 12 04:16:49 2013
@@ -51,8 +51,11 @@ derby.module.core.cscpds=org.apache.derb
 derby.module.core.csxad=org.apache.derby.jdbc.EmbeddedXADataSource
 derby.module.core.csds_simple=org.apache.derby.jdbc.EmbeddedSimpleDataSource
 derby.module.core.csds.jdk16=org.apache.derby.jdbc.EmbeddedDataSource40
+derby.module.core.csds.jdk16n=org.apache.derby.jdbc.NonJNDIEmbeddedDataSource40
 derby.module.core.csxads.jdk16=org.apache.derby.jdbc.EmbeddedXADataSource40
+derby.module.core.csxads.jdk16n=org.apache.derby.jdbc.NonJNDIEmbeddedXADataSource40
 derby.module.core.cscpds.jdk16=org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40
+derby.module.core.cscpds.jdk16n=org.apache.derby.jdbc.NonJNDIEmbeddedConnectionPoolDataSource40
 derby.module.core.ad.jdk16=org.apache.derby.jdbc.AutoloadedDriver40
 
 derby.module.database.consistency.checker=org.apache.derby.iapi.db.ConsistencyChecker

Modified: db/derby/code/trunk/tools/javadoc/publishedapi_jdbc4.ant
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/javadoc/publishedapi_jdbc4.ant?rev=1432380&r1=1432379&r2=1432380&view=diff
==============================================================================
--- db/derby/code/trunk/tools/javadoc/publishedapi_jdbc4.ant (original)
+++ db/derby/code/trunk/tools/javadoc/publishedapi_jdbc4.ant Sat Jan 12 04:16:49 2013
@@ -36,7 +36,16 @@
 org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java
 org/apache/derby/jdbc/ClientDataSource40.java
 org/apache/derby/jdbc/ClientXADataSource40.java
+
 org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
 org/apache/derby/jdbc/EmbeddedDataSource40.java
 org/apache/derby/jdbc/EmbeddedXADataSource40.java
 
+org/apache/derby/jdbc/NonJNDIClientConnectionPoolDataSource40.java
+org/apache/derby/jdbc/NonJNDIClientDataSource40.java
+org/apache/derby/jdbc/NonJNDIClientXADataSource40.java
+
+org/apache/derby/jdbc/NonJNDIEmbeddedConnectionPoolDataSource40.java
+org/apache/derby/jdbc/NonJNDIEmbeddedDataSource40.java
+org/apache/derby/jdbc/NonJNDIEmbeddedXADataSource40.java
+



Mime
View raw message