use of org.apache.cayenne.conn.DataSourceInfo in project cayenne by apache.
the class PasswordEncoderEditor method passwordLocationChangedAction.
public void passwordLocationChangedAction() {
if (node == null || node.getDataSourceDescriptor() == null)
return;
DataSourceInfo dsi = node.getDataSourceDescriptor();
String selectedItem = (String) view.getPasswordLocation().getSelectedItem();
if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_CLASSPATH))
updatePasswordElements(true, true, dsi.getPassword(), "Password Filename:", dsi.getPasswordSourceFilename());
else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_EXECUTABLE))
updatePasswordElements(false, true, null, "Password Executable:", dsi.getPasswordSourceExecutable());
else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_MODEL))
updatePasswordElements(true, false, dsi.getPassword(), "Password Source:", dsi.getPasswordSourceModel());
else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_URL))
updatePasswordElements(false, true, null, "Password URL:", dsi.getPasswordSourceUrl());
}
use of org.apache.cayenne.conn.DataSourceInfo in project cayenne by apache.
the class CreateNodeAction method buildDataNode.
/**
* Creates a new DataNode, adding to the current domain, but doesn't send
* any events.
*/
public DataNodeDescriptor buildDataNode() {
ProjectController mediator = getProjectController();
DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
DataNodeDescriptor node = buildDataNode(domain);
DataSourceInfo src = new DataSourceInfo();
node.setDataSourceDescriptor(src);
// by default create JDBC Node
node.setDataSourceFactoryType(XMLPoolingDataSourceFactory.class.getName());
node.setSchemaUpdateStrategyType(SkipSchemaUpdateStrategy.class.getName());
return node;
}
use of org.apache.cayenne.conn.DataSourceInfo in project cayenne by apache.
the class ImportEOModelAction method loadDataNode.
protected void loadDataNode(Map eomodelIndex) {
// if this is JDBC or JNDI node and connection dictionary is specified, load a
// DataNode, otherwise ignore it (meaning that pre 5.* EOModels will not have a
// node).
String adapter = (String) eomodelIndex.get("adaptorName");
Map connection = (Map) eomodelIndex.get("connectionDictionary");
if (adapter != null && connection != null) {
CreateNodeAction nodeBuilder = (CreateNodeAction) getApplication().getActionManager().getAction(CreateNodeAction.class);
// this should make created node current, resulting in the new map being added
// to the node automatically once it is loaded
DataNodeDescriptor node = nodeBuilder.buildDataNode();
// configure node...
if ("JNDI".equalsIgnoreCase(adapter)) {
node.setDataSourceFactoryType(JNDIDataSourceFactory.class.getName());
node.setParameters((String) connection.get("serverUrl"));
} else {
// guess adapter from plugin or driver
AdapterMapping adapterDefaults = getApplication().getAdapterMapping();
String cayenneAdapter = adapterDefaults.adapterForEOFPluginOrDriver((String) connection.get("plugin"), (String) connection.get("driver"));
if (cayenneAdapter != null) {
try {
Class<DbAdapter> adapterClass = getApplication().getClassLoadingService().loadClass(DbAdapter.class, cayenneAdapter);
node.setAdapterType(adapterClass.toString());
} catch (Throwable ex) {
// ignore...
}
}
node.setDataSourceFactoryType(XMLPoolingDataSourceFactory.class.getName());
DataSourceInfo dsi = node.getDataSourceDescriptor();
dsi.setDataSourceUrl(keyAsString(connection, "URL"));
dsi.setJdbcDriver(keyAsString(connection, "driver"));
dsi.setPassword(keyAsString(connection, "password"));
dsi.setUserName(keyAsString(connection, "username"));
}
DataChannelDescriptor domain = (DataChannelDescriptor) getProjectController().getProject().getRootNode();
domain.getNodeDescriptors().add(node);
// send events after the node creation is complete
getProjectController().fireDataNodeEvent(new DataNodeEvent(this, node, MapEvent.ADD));
getProjectController().fireDataNodeDisplayEvent(new DataNodeDisplayEvent(this, (DataChannelDescriptor) getProjectController().getProject().getRootNode(), node));
}
}
use of org.apache.cayenne.conn.DataSourceInfo in project cayenne by apache.
the class ConnectionProperties method buildDataSourceInfo.
/**
* Creates a DataSourceInfo object from a set of properties.
*/
private DataSourceInfo buildDataSourceInfo(Map<String, String> props) {
DataSourceInfo dsi = new DataSourceInfo();
String adapter = props.get(ADAPTER_KEY);
// try legacy adapter key
if (adapter == null) {
adapter = props.get(ADAPTER20_KEY);
}
dsi.setAdapterClassName(adapter);
dsi.setUserName(props.get(USER_NAME_KEY));
dsi.setPassword(props.get(PASSWORD_KEY));
dsi.setDataSourceUrl(props.get(URL_KEY));
dsi.setJdbcDriver(props.get(DRIVER_KEY));
dsi.setMinConnections(MIN_CONNECTIONS);
dsi.setMaxConnections(MAX_CONNECTIONS);
return dsi;
}
use of org.apache.cayenne.conn.DataSourceInfo in project cayenne by apache.
the class ServerCaseDataSourceInfoProvider method applyOverrides.
private DataSourceInfo applyOverrides(DataSourceInfo connectionInfo) {
String adapter = property(ADAPTER_KEY_MAVEN);
String user = property(USER_NAME_KEY_MAVEN);
String pass = property(PASSWORD_KEY_MAVEN);
String url = property(URL_KEY_MAVEN);
String driver = property(DRIVER_KEY_MAVEN);
if (connectionInfo == null) {
// only create a brand new DSI if overrides contains a DB url...
if (url == null) {
return null;
}
connectionInfo = new DataSourceInfo();
connectionInfo.setMinConnections(ConnectionProperties.MIN_CONNECTIONS);
connectionInfo.setMaxConnections(ConnectionProperties.MAX_CONNECTIONS);
}
connectionInfo = connectionInfo.cloneInfo();
if (adapter != null) {
connectionInfo.setAdapterClassName(adapter);
}
if (user != null) {
connectionInfo.setUserName(user);
}
if (pass != null) {
connectionInfo.setPassword(pass);
}
if (url != null) {
connectionInfo.setDataSourceUrl(url);
}
if (driver != null) {
connectionInfo.setJdbcDriver(driver);
}
return connectionInfo;
}
Aggregations