You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by sk...@apache.org on 2015/09/04 13:21:19 UTC
cayenne git commit: CAY-2025 | Support for DBCP2
Repository: cayenne
Updated Branches:
refs/heads/master 60479b71f -> 40320f036
CAY-2025 | Support for DBCP2
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/40320f03
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/40320f03
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/40320f03
Branch: refs/heads/master
Commit: 40320f03663f1a5aca5aea1c56f874764e56715f
Parents: 60479b7
Author: Savva Kolbachev <s....@gmail.com>
Authored: Fri Sep 4 14:19:31 2015 +0300
Committer: Savva Kolbachev <s....@gmail.com>
Committed: Fri Sep 4 14:19:31 2015 +0300
----------------------------------------------------------------------
assembly/pom.xml | 14 +++
cayenne-dbcp2/pom.xml | 93 ++++++++++++++++++++
.../server/DBCP2DataSourceFactory.java | 93 ++++++++++++++++++++
.../server/DBCP2DataSourceFactoryTest.java | 91 +++++++++++++++++++
.../configuration/server/testDBCP2.properties | 24 +++++
docs/doc/src/main/resources/RELEASE-NOTES.txt | 1 +
docs/doc/src/main/resources/UPGRADE.txt | 5 +-
.../editor/datanode/DBCP2DataSourceEditor.java | 51 +++++++++++
.../editor/datanode/DBCP2DataSourceView.java | 54 ++++++++++++
.../editor/datanode/MainDataNodeEditor.java | 33 ++++---
pom.xml | 11 ++-
11 files changed, 454 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/assembly/pom.xml
----------------------------------------------------------------------
diff --git a/assembly/pom.xml b/assembly/pom.xml
index 7a4e6f3..9b2b630 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -369,5 +369,19 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <!-- DBCP2 assembly (can only be run on Java7 and higher) -->
+ <id>dbcp2</id>
+ <activation>
+ <jdk>[1.7,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cayenne</groupId>
+ <artifactId>cayenne-dbcp2</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
</profiles>
</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/cayenne-dbcp2/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-dbcp2/pom.xml b/cayenne-dbcp2/pom.xml
new file mode 100644
index 0000000..41fde60
--- /dev/null
+++ b/cayenne-dbcp2/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>cayenne-parent</artifactId>
+ <groupId>org.apache.cayenne</groupId>
+ <version>4.0.M3-SNAPSHOT</version>
+ </parent>
+ <artifactId>cayenne-dbcp2</artifactId>
+ <name>Cayenne DBCP2 Extension</name>
+ <packaging>jar</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-dbcp2</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-pool2</artifactId>
+ <version>2.4.2</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <!-- Compile dependencies -->
+ <dependency>
+ <groupId>org.apache.cayenne</groupId>
+ <artifactId>cayenne-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-dbcp2</artifactId>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cayenne.build-tools</groupId>
+ <artifactId>cayenne-test-utilities</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <!--<configuration> <suppressionsLocation>${project.basedir}/cayenne-checkstyle-suppression.xml</suppressionsLocation>
+ </configuration> -->
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/cayenne-dbcp2/src/main/java/org/apache/cayenne/configuration/server/DBCP2DataSourceFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-dbcp2/src/main/java/org/apache/cayenne/configuration/server/DBCP2DataSourceFactory.java b/cayenne-dbcp2/src/main/java/org/apache/cayenne/configuration/server/DBCP2DataSourceFactory.java
new file mode 100644
index 0000000..e530bf9
--- /dev/null
+++ b/cayenne-dbcp2/src/main/java/org/apache/cayenne/configuration/server/DBCP2DataSourceFactory.java
@@ -0,0 +1,93 @@
+/*****************************************************************
+ * 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.cayenne.configuration.server;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.resource.Resource;
+import org.apache.commons.dbcp2.BasicDataSourceFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.sql.DataSource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * A {@link DataSourceFactory} based on DBCP2 connection pool library.
+ *
+ * @since 4.0.M3
+ */
+public class DBCP2DataSourceFactory implements DataSourceFactory {
+
+ private static final String DBCP2_PROPERTIES = "dbcp2.properties";
+
+ private static final Log logger = LogFactory.getLog(DBCP2DataSourceFactory.class);
+
+ @Override
+ public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
+
+ String location = nodeDescriptor.getParameters();
+ if (location == null) {
+ logger.debug("No explicit DBCP2 config location, will use default location: "
+ + DBCP2_PROPERTIES);
+ location = DBCP2_PROPERTIES;
+ }
+
+ Resource baseConfiguration = nodeDescriptor.getConfigurationSource();
+ if (baseConfiguration == null) {
+ throw new CayenneRuntimeException(
+ "Null 'configurationSource' for nodeDescriptor '%s'",
+ nodeDescriptor.getName());
+ }
+
+ Resource dbcp2Configuration = baseConfiguration.getRelativeResource(location);
+ if (dbcp2Configuration == null) {
+ throw new CayenneRuntimeException(
+ "Missing DBCP2 configuration '%s' for nodeDescriptor '%s'",
+ location,
+ nodeDescriptor.getName());
+ }
+
+ Properties properties = getProperties(dbcp2Configuration);
+ if (logger.isDebugEnabled()) {
+ logger.debug("DBCP2 Properties: " + properties);
+ }
+
+ return BasicDataSourceFactory.createDataSource(properties);
+ }
+
+ private Properties getProperties(Resource dbcp2Configuration) throws IOException {
+ Properties properties = new Properties();
+ InputStream in = dbcp2Configuration.getURL().openStream();
+ try {
+ properties.load(in);
+ }
+ finally {
+ try {
+ in.close();
+ }
+ catch (IOException e) {
+ }
+ }
+
+ return properties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/cayenne-dbcp2/src/test/java/org/apache/cayenne/configuration/server/DBCP2DataSourceFactoryTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbcp2/src/test/java/org/apache/cayenne/configuration/server/DBCP2DataSourceFactoryTest.java b/cayenne-dbcp2/src/test/java/org/apache/cayenne/configuration/server/DBCP2DataSourceFactoryTest.java
new file mode 100644
index 0000000..3a5516b
--- /dev/null
+++ b/cayenne-dbcp2/src/test/java/org/apache/cayenne/configuration/server/DBCP2DataSourceFactoryTest.java
@@ -0,0 +1,91 @@
+/*****************************************************************
+ * 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.cayenne.configuration.server;
+
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.resource.URLResource;
+import org.apache.commons.dbcp2.BasicDataSource;
+import org.junit.Test;
+
+import javax.sql.DataSource;
+import java.io.IOException;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class DBCP2DataSourceFactoryTest {
+
+ @Test
+ public void testGetDataSource() throws Exception {
+
+ String baseUrl = getClass().getPackage().getName().replace('.', '/');
+ URL url = getClass().getClassLoader().getResource(baseUrl + "/");
+ assertNotNull(url);
+
+ DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+ nodeDescriptor.setConfigurationSource(new URLResource(url));
+ nodeDescriptor.setParameters("testDBCP2.properties");
+
+ DBCP2DataSourceFactory factory = new DBCP2DataSourceFactory();
+ DataSource dataSource = factory.getDataSource(nodeDescriptor);
+ assertNotNull(dataSource);
+
+ assertTrue(dataSource instanceof BasicDataSource);
+ BasicDataSource basicDataSource = (BasicDataSource) dataSource;
+ assertEquals("com.example.jdbc.Driver", basicDataSource.getDriverClassName());
+ assertEquals("jdbc:somedb://localhost/cayenne", basicDataSource.getUrl());
+ assertEquals("john", basicDataSource.getUsername());
+ assertEquals("secret", basicDataSource.getPassword());
+ assertEquals(20, basicDataSource.getMaxTotal());
+ assertEquals(5, basicDataSource.getMinIdle());
+ assertEquals(8, basicDataSource.getMaxIdle());
+ assertEquals(10000, basicDataSource.getMaxWaitMillis());
+ assertEquals("select 1 from xyz;", basicDataSource.getValidationQuery());
+
+
+ System.out.println(DBCP2DataSourceFactory.class.getName());
+ }
+
+ @Test
+ public void testGetDataSource_InvalidLocation() throws Exception {
+
+ String baseUrl = getClass().getPackage().getName().replace('.', '/');
+ URL url = getClass().getClassLoader().getResource(baseUrl + "/");
+ assertNotNull(url);
+
+ DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+ nodeDescriptor.setConfigurationSource(new URLResource(url));
+ nodeDescriptor.setParameters("testDBCP2.properties.nosuchfile");
+
+ DBCP2DataSourceFactory factory = new DBCP2DataSourceFactory();
+
+ try {
+ factory.getDataSource(nodeDescriptor);
+ fail("didn't throw on absent config file");
+ }
+ catch (IOException ex) {
+ // expected
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/cayenne-dbcp2/src/test/resources/org/apache/cayenne/configuration/server/testDBCP2.properties
----------------------------------------------------------------------
diff --git a/cayenne-dbcp2/src/test/resources/org/apache/cayenne/configuration/server/testDBCP2.properties b/cayenne-dbcp2/src/test/resources/org/apache/cayenne/configuration/server/testDBCP2.properties
new file mode 100644
index 0000000..a61f397
--- /dev/null
+++ b/cayenne-dbcp2/src/test/resources/org/apache/cayenne/configuration/server/testDBCP2.properties
@@ -0,0 +1,24 @@
+# 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.
+
+driverClassName=com.example.jdbc.Driver
+url=jdbc:somedb://localhost/cayenne
+username=john
+password=secret
+maxTotal=20
+minIdle=5
+maxIdle=8
+maxWaitMillis=10000
+validationQuery=select 1 from xyz;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index 9e4b338..abec1cd 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -29,6 +29,7 @@ CAY-2011 Support for Java 8 date and time types
CAY-2012 ObjectSelect, SelectById: eliminating methods that reset query state
CAY-2013 In-memory evaluation of DB expressions - non-id attributes
CAY-2023 Decouple the use of ResourceLocator
+CAY-2025 Support for DBCP2
Bug Fixes:
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/docs/doc/src/main/resources/UPGRADE.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/UPGRADE.txt b/docs/doc/src/main/resources/UPGRADE.txt
index 6499e47..ea6f088 100644
--- a/docs/doc/src/main/resources/UPGRADE.txt
+++ b/docs/doc/src/main/resources/UPGRADE.txt
@@ -6,7 +6,7 @@ IMPORTANT: be sure to read all notes for the intermediate releases between your
-------------------------------------------------------------------------------
UPGRADING TO 4.0.M3
-* We no lobger add @Deprecated annotation to generated String property names in entity superclasses.
+* We no longer add @Deprecated annotation to generated String property names in entity superclasses.
Instead String property names inclusion
became optional, controlled with "createPropertyNames" flag in cgen ("false" by default). Also a similar option
was added to Advanced Type of CayenneModeler class generation dialog.
@@ -21,6 +21,9 @@ UPGRADING TO 4.0.M3
'orderBy' that would previously reset the corresponding option state now work as "append". Methods that would previously append to the
option state were removed as redundant. Please revisit your code if you previously relied on the reset behavior.
+* Per CAY-2025 DBCP2DataSourceFactory does not support deprecated properties. So if you want to upgrade from commons-dbcp to commons-dbcp2,
+ you should replace all old-style properties with the newer ones.
+
UPGRADING TO 4.0.M2
* Note that 3.2 line of development was renamed to 4.0. So 4.0.M2 is a straight descendant of
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCP2DataSourceEditor.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCP2DataSourceEditor.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCP2DataSourceEditor.java
new file mode 100644
index 0000000..39ce394
--- /dev/null
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCP2DataSourceEditor.java
@@ -0,0 +1,51 @@
+/*****************************************************************
+ * 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.cayenne.modeler.editor.datanode;
+
+import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.swing.BindingBuilder;
+import org.apache.cayenne.swing.BindingDelegate;
+import org.apache.cayenne.swing.ObjectBinding;
+
+import java.awt.Component;
+
+public class DBCP2DataSourceEditor extends DataSourceEditor {
+
+ protected DBCP2DataSourceView view;
+
+ public DBCP2DataSourceEditor(ProjectController controller,
+ BindingDelegate nodeChangeProcessor) {
+ super(controller, nodeChangeProcessor);
+ }
+
+ protected void prepareBindings(BindingBuilder builder) {
+ this.view = new DBCP2DataSourceView();
+
+ fieldAdapters = new ObjectBinding[1];
+ fieldAdapters[0] = builder.bindToTextField(
+ view.getPropertiesFile(),
+ "node.parameters");
+ }
+
+ public Component getView() {
+ return view;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCP2DataSourceView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCP2DataSourceView.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCP2DataSourceView.java
new file mode 100644
index 0000000..b5e3eab
--- /dev/null
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCP2DataSourceView.java
@@ -0,0 +1,54 @@
+/*****************************************************************
+ * 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.cayenne.modeler.editor.datanode;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.FormLayout;
+import org.apache.cayenne.modeler.util.JTextFieldUndoable;
+
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import java.awt.BorderLayout;
+
+public class DBCP2DataSourceView extends JPanel {
+
+ protected JTextField propertiesFile;
+
+ public DBCP2DataSourceView() {
+
+ propertiesFile = new JTextFieldUndoable();
+
+ // assemble
+ FormLayout layout = new FormLayout("right:80dlu, 3dlu, fill:200dlu", "");
+ DefaultFormBuilder builder = new DefaultFormBuilder(layout);
+ builder.setDefaultDialogBorder();
+
+ builder.appendSeparator("Apache DBCP2 Configuration");
+
+ builder.append("DBCP2 Properties File:", propertiesFile);
+
+ setLayout(new BorderLayout());
+ add(builder.getPanel(), BorderLayout.CENTER);
+ }
+
+ public JTextField getPropertiesFile() {
+ return propertiesFile;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java
index fa7dbf1..affba0d 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeEditor.java
@@ -19,18 +19,6 @@
package org.apache.cayenne.modeler.editor.datanode;
-import java.awt.Component;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.swing.DefaultComboBoxModel;
-
import org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy;
import org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy;
import org.apache.cayenne.access.dbsync.ThrowOnPartialOrCreateSchemaStrategy;
@@ -54,6 +42,17 @@ import org.apache.cayenne.swing.BindingDelegate;
import org.apache.cayenne.swing.ObjectBinding;
import org.apache.cayenne.validation.ValidationException;
+import javax.swing.DefaultComboBoxModel;
+import java.awt.Component;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
/**
* A controller for the main tab of the DataNode editor panel.
*
@@ -61,10 +60,11 @@ import org.apache.cayenne.validation.ValidationException;
public class MainDataNodeEditor extends CayenneController {
protected static final String NO_LOCAL_DATA_SOURCE = "Select DataSource for Local Work...";
+ private static final String DBCP2_DATA_SOURCE_FACTORY = "org.apache.cayenne.configuration.server.DBCP2DataSourceFactory";
final static String[] standardDataSourceFactories = new String[] {
- XMLPoolingDataSourceFactory.class.getName(),
- JNDIDataSourceFactory.class.getName(), DBCPDataSourceFactory.class.getName()
+ XMLPoolingDataSourceFactory.class.getName(), JNDIDataSourceFactory.class.getName(),
+ DBCPDataSourceFactory.class.getName(), DBCP2_DATA_SOURCE_FACTORY
};
final static String[] standardSchemaUpdateStrategy = new String[] {
@@ -314,6 +314,11 @@ public class MainDataNodeEditor extends CayenneController {
(ProjectController) getParent(),
nodeChangeProcessor);
}
+ else if (DBCP2_DATA_SOURCE_FACTORY.equals(factoryName)) {
+ c = new DBCP2DataSourceEditor(
+ (ProjectController) getParent(),
+ nodeChangeProcessor);
+ }
else {
// special case - no detail view, just show it and bail..
defaultSubeditor.setNode(node);
http://git-wip-us.apache.org/repos/asf/cayenne/blob/40320f03/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7f250d7..787d971 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@
<module>tutorials</module>
<module>docs</module>
<module>assembly</module>
- </modules>
+ </modules>
<issueManagement>
<system>jira</system>
<url>https://issues.apache.org/jira/browse/CAY</url>
@@ -1480,6 +1480,15 @@
<module>cayenne-java8</module>
</modules>
</profile>
+ <profile>
+ <id>cayenne-dbcp2-module-to-build</id>
+ <activation>
+ <jdk>[1.7,)</jdk>
+ </activation>
+ <modules>
+ <module>cayenne-dbcp2</module>
+ </modules>
+ </profile>
</profiles>
<reporting>