Skip to content

Commit 9008d8c

Browse files
committed
Stop supporting (ignore) JNDI option for EOModel imports
1 parent 1169a25 commit 9008d8c

1 file changed

Lines changed: 24 additions & 33 deletions

File tree

modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/ImportEOModelAction.java

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.apache.cayenne.configuration.DataChannelDescriptor;
2424
import org.apache.cayenne.configuration.DataNodeDescriptor;
2525
import org.apache.cayenne.configuration.DataSourceDescriptor;
26-
import org.apache.cayenne.configuration.runtime.JNDIDataSourceFactory;
2726
import org.apache.cayenne.configuration.runtime.XMLPoolingDataSourceFactory;
2827
import org.apache.cayenne.dba.DbAdapter;
2928
import org.apache.cayenne.dba.db2.DB2Adapter;
@@ -158,51 +157,43 @@ protected void importEOModel() {
158157
}
159158

160159
protected void loadDataNode(Map eomodelIndex) {
161-
// if this is JDBC or JNDI node and connection dictionary is specified, load a
162-
// DataNode, otherwise ignore it (meaning that pre 5.* EOModels will not have a
163-
// node).
160+
// if this is a JDBC node and connection dictionary is specified, load a DataNode,
161+
// otherwise ignore it (meaning that pre 5.* EOModels will not have a node).
164162

165163
String adapter = (String) eomodelIndex.get("adaptorName");
166164
Map<?, ?> connection = (Map) eomodelIndex.get("connectionDictionary");
167165

168-
if (adapter != null && connection != null) {
166+
if (adapter != null && connection != null && !"JNDI".equalsIgnoreCase(adapter)) {
169167
CreateNodeAction nodeBuilder = app.getActionManager().getAction(CreateNodeAction.class);
170168

171169
// this should make created node current, resulting in the new map being added
172170
// to the node automatically once it is loaded
173171
DataNodeDescriptor node = nodeBuilder.buildDataNode();
174172

175-
// configure node...
176-
if ("JNDI".equalsIgnoreCase(adapter)) {
177-
node.setDataSourceFactoryType(JNDIDataSourceFactory.class.getName());
178-
node.setParameters((String) connection.get("serverUrl"));
179-
} else {
180-
181-
// guess adapter from plugin or driver
182-
String cayenneAdapter = adaptersByEofPlugin.get(connection.get("plugin"));
183-
if (cayenneAdapter == null) {
184-
cayenneAdapter = adaptersByDriver.get(connection.get("driver"));
185-
}
173+
// guess adapter from plugin or driver
174+
String cayenneAdapter = adaptersByEofPlugin.get(connection.get("plugin"));
175+
if (cayenneAdapter == null) {
176+
cayenneAdapter = adaptersByDriver.get(connection.get("driver"));
177+
}
186178

187-
if (cayenneAdapter != null) {
188-
try {
189-
Class<DbAdapter> adapterClass = app
190-
.getClassLoader()
191-
.loadClass(DbAdapter.class, cayenneAdapter);
192-
node.setAdapterType(adapterClass.toString());
193-
} catch (Throwable ex) {
194-
// ignore...
195-
}
179+
if (cayenneAdapter != null) {
180+
try {
181+
Class<DbAdapter> adapterClass = app
182+
.getClassLoader()
183+
.loadClass(DbAdapter.class, cayenneAdapter);
184+
node.setAdapterType(adapterClass.toString());
185+
} catch (Throwable ex) {
186+
// ignore...
196187
}
188+
}
197189

198-
node.setDataSourceFactoryType(XMLPoolingDataSourceFactory.class.getName());
190+
node.setDataSourceFactoryType(XMLPoolingDataSourceFactory.class.getName());
199191

200-
DataSourceDescriptor dsi = node.getDataSourceDescriptor();
201-
dsi.setDataSourceUrl(keyAsString(connection, "URL"));
202-
dsi.setJdbcDriver(keyAsString(connection, "driver"));
203-
dsi.setPassword(keyAsString(connection, "password"));
204-
dsi.setUserName(keyAsString(connection, "username"));
205-
}
192+
DataSourceDescriptor dsi = node.getDataSourceDescriptor();
193+
dsi.setDataSourceUrl(keyAsString(connection, "URL"));
194+
dsi.setJdbcDriver(keyAsString(connection, "driver"));
195+
dsi.setPassword(keyAsString(connection, "password"));
196+
dsi.setUserName(keyAsString(connection, "username"));
206197

207198
DataChannelDescriptor domain = (DataChannelDescriptor) getProjectSession()
208199
.project()
@@ -334,7 +325,7 @@ public JFileChooser getEOModelChooser() {
334325
*/
335326
static class EOModelChooser extends JFileChooser {
336327

337-
private static final FileFilter eomodelFilter = new EOModelFileFilter();
328+
static final FileFilter eomodelFilter = new EOModelFileFilter();
338329

339330
private JDialog cachedDialog;
340331

0 commit comments

Comments
 (0)