|
23 | 23 | import org.apache.cayenne.configuration.DataChannelDescriptor; |
24 | 24 | import org.apache.cayenne.configuration.DataNodeDescriptor; |
25 | 25 | import org.apache.cayenne.configuration.DataSourceDescriptor; |
26 | | -import org.apache.cayenne.configuration.runtime.JNDIDataSourceFactory; |
27 | 26 | import org.apache.cayenne.configuration.runtime.XMLPoolingDataSourceFactory; |
28 | 27 | import org.apache.cayenne.dba.DbAdapter; |
29 | 28 | import org.apache.cayenne.dba.db2.DB2Adapter; |
@@ -158,51 +157,43 @@ protected void importEOModel() { |
158 | 157 | } |
159 | 158 |
|
160 | 159 | 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). |
164 | 162 |
|
165 | 163 | String adapter = (String) eomodelIndex.get("adaptorName"); |
166 | 164 | Map<?, ?> connection = (Map) eomodelIndex.get("connectionDictionary"); |
167 | 165 |
|
168 | | - if (adapter != null && connection != null) { |
| 166 | + if (adapter != null && connection != null && !"JNDI".equalsIgnoreCase(adapter)) { |
169 | 167 | CreateNodeAction nodeBuilder = app.getActionManager().getAction(CreateNodeAction.class); |
170 | 168 |
|
171 | 169 | // this should make created node current, resulting in the new map being added |
172 | 170 | // to the node automatically once it is loaded |
173 | 171 | DataNodeDescriptor node = nodeBuilder.buildDataNode(); |
174 | 172 |
|
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 | + } |
186 | 178 |
|
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... |
196 | 187 | } |
| 188 | + } |
197 | 189 |
|
198 | | - node.setDataSourceFactoryType(XMLPoolingDataSourceFactory.class.getName()); |
| 190 | + node.setDataSourceFactoryType(XMLPoolingDataSourceFactory.class.getName()); |
199 | 191 |
|
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")); |
206 | 197 |
|
207 | 198 | DataChannelDescriptor domain = (DataChannelDescriptor) getProjectSession() |
208 | 199 | .project() |
@@ -334,7 +325,7 @@ public JFileChooser getEOModelChooser() { |
334 | 325 | */ |
335 | 326 | static class EOModelChooser extends JFileChooser { |
336 | 327 |
|
337 | | - private static final FileFilter eomodelFilter = new EOModelFileFilter(); |
| 328 | + static final FileFilter eomodelFilter = new EOModelFileFilter(); |
338 | 329 |
|
339 | 330 | private JDialog cachedDialog; |
340 | 331 |
|
|
0 commit comments