本文整理了Java中org.codehaus.cargo.container.configuration.entry.DataSource.getConnectionProperties()
方法的一些代码示例,展示了DataSource.getConnectionProperties()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataSource.getConnectionProperties()
方法的具体详情如下:
包路径:org.codehaus.cargo.container.configuration.entry.DataSource
类名称:DataSource
方法名:getConnectionProperties
[英]Extra properties passed to the JDBC Driver.
[中]传递给JDBC驱动程序的额外属性。
代码示例来源:origin: org.codehaus.cargo/cargo-core-container-orion
/**
* adds the driver-specific properties to the data-source tag.
*/
private void addNestedDriverPropertyTags()
{
if (ds.getConnectionProperties() != null && ds.getConnectionProperties().size() != 0)
{
Iterator<Object> i = ds.getConnectionProperties().keySet().iterator();
while (i.hasNext())
{
String key = i.next().toString();
buffer.append(" <property name=\"").append(key);
buffer.append("\" value=\"")
.append(ds.getConnectionProperties().getProperty(key)).append("\" />\n");
}
}
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* adds the driver-specific properties to the data-source tag.
*/
private void addNestedDriverPropertyTags()
{
if (ds.getConnectionProperties() != null && ds.getConnectionProperties().size() != 0)
{
Iterator<Object> i = ds.getConnectionProperties().keySet().iterator();
while (i.hasNext())
{
String key = i.next().toString();
buffer.append(" <property name=\"").append(key);
buffer.append("\" value=\"")
.append(ds.getConnectionProperties().getProperty(key)).append("\" />\n");
}
}
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* if the enclosed driver properties object is set, and also contains the user and password
* properties, set the corresponding member values.
*/
private void setCredentialsIfInsideDriverProperties()
{
if (getConnectionProperties() != null)
{
if (getConnectionProperties().containsKey("user"))
{
setUsername(getConnectionProperties().getProperty("user"));
}
if (getConnectionProperties().containsKey("password"))
{
setPassword(getConnectionProperties().getProperty("password"));
}
}
}
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* tests to see if the value is null before attempting to join the database properties on a
* semicolon.
*
* @param data DataSource to parse connection properties from.
* @return property string delimited by semicolon, or null, if they cannot be parsed because the
* input properties weren't set or empty
*/
public String getConnectionPropertiesAsASemicolonDelimitedString(DataSource data)
{
if (data.getConnectionProperties() != null && data.getConnectionProperties().size() != 0)
{
return PropertyUtils.joinOnSemicolon(PropertyUtils.toMap(
data.getConnectionProperties()));
}
else
{
return null;
}
}
代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic
/**
* @param ds DataSource.
* @return Create datasource WLST script.
*/
public Collection<ScriptCommand> dataSourceScript(DataSource ds)
{
Collection<ScriptCommand> script = new ArrayList<ScriptCommand>();
script.add(new DataSourceScriptCommand(configuration, RESOURCE_PATH, ds));
for (Entry<Object, Object> driverProperty : ds.getConnectionProperties().entrySet())
{
script.add(new DataSourceConnectionPropertyScriptCommand(configuration, RESOURCE_PATH,
ds, driverProperty));
}
return script;
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* @param ds DataSource.
* @return Create datasource WLST script.
*/
public Collection<ScriptCommand> dataSourceScript(DataSource ds)
{
Collection<ScriptCommand> script = new ArrayList<ScriptCommand>();
script.add(new DataSourceScriptCommand(configuration, RESOURCE_PATH, ds));
for (Entry<Object, Object> driverProperty : ds.getConnectionProperties().entrySet())
{
script.add(new DataSourceConnectionPropertyScriptCommand(configuration, RESOURCE_PATH,
ds, driverProperty));
}
return script;
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* @param dataSource DataSource to be created.
* @param sharedLibraries Shared libraries containing database drivers.
* @return Create datasource jython script.
*/
public List<ScriptCommand> createDataSourceScript(DataSource dataSource,
Collection<String> sharedLibraries)
{
List<ScriptCommand> scriptCommands = new ArrayList<ScriptCommand>();
scriptCommands.add(new DataSourceScriptCommand(configuration, RESOURCE_PATH, dataSource,
sharedLibraries));
for (Entry<Object, Object> property : dataSource.getConnectionProperties().entrySet())
{
scriptCommands.add(new DataSourceConnectionPropertyScriptCommand(configuration,
RESOURCE_PATH, dataSource, property));
}
return scriptCommands;
}
代码示例来源:origin: org.codehaus.cargo/cargo-core-container-resin
if (ds.getConnectionProperties() != null && ds.getConnectionProperties().size() != 0)
for (Object parameter : ds.getConnectionProperties().keySet())
.append(ds.getConnectionProperties().getProperty(key));
dataSourceString.append("</").append(key).append(">\n");
代码示例来源:origin: codehaus-cargo/cargo
if (ds.getConnectionProperties() != null && ds.getConnectionProperties().size() != 0)
for (Object parameter : ds.getConnectionProperties().keySet())
.append(ds.getConnectionProperties().getProperty(key));
dataSourceString.append("</").append(key).append(">\n");
代码示例来源:origin: org.codehaus.cargo/cargo-core-container-wildfly
@Override
protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
{
Map<String, String> datasourceProperties = new HashMap<String, String>();
datasourceProperties.put("name", ds.getId());
datasourceProperties.put("jndi-name", getDataSourceJndi(ds));
datasourceProperties.put("driver-name", ds.getDriverClass());
datasourceProperties.put("user-name", ds.getUsername());
datasourceProperties.put("password", ds.getPassword());
char delimiter = ',';
Map<String, String> conProperties = PropertyUtils.toMap(ds.getConnectionProperties());
String customProperties = PropertyUtils.joinOnDelimiter(conProperties, delimiter);
datasourceProperties.put("xa-datasource-properties", customProperties);
String dsProps = mapResourceProperties(datasourceProperties);
propertiesMap.put("cargo.datasource.properties", dsProps);
}
}
代码示例来源:origin: codehaus-cargo/cargo
@Override
protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
{
Map<String, String> datasourceProperties = new HashMap<String, String>();
datasourceProperties.put("name", ds.getId());
datasourceProperties.put("jndi-name", getDataSourceJndi(ds));
datasourceProperties.put("driver-name", ds.getDriverClass());
datasourceProperties.put("user-name", ds.getUsername());
datasourceProperties.put("password", ds.getPassword());
char delimiter = ',';
Map<String, String> conProperties = PropertyUtils.toMap(ds.getConnectionProperties());
String customProperties = PropertyUtils.joinOnDelimiter(conProperties, delimiter);
datasourceProperties.put("xa-datasource-properties", customProperties);
String dsProps = mapResourceProperties(datasourceProperties);
propertiesMap.put("cargo.datasource.properties", dsProps);
}
}
代码示例来源:origin: codehaus-cargo/cargo
writer.print("\" ");
writeProperties(writer, ds.getConnectionProperties());
writer.println("/>");
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test the setting of multiple properties delimited by a semicolon.
*/
public void testMultipleDriverPropertiesDelimitedBySemiColon()
{
Properties driverProperties = new Properties();
driverProperties.setProperty("user", "APP");
driverProperties.setProperty("CreateDatabase", "create");
String driverPropertyString = "user=APP;CreateDatabase=create";
String propertyString =
DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString;
DataSource ds = dataSourceConverter.fromPropertyString(propertyString);
assertEquals(driverProperties, ds.getConnectionProperties());
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test the empty driver properties getter.
*/
public void testGetEmptyDriverProperties()
{
String propertyString = "";
String driverPropertyString =
DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + propertyString;
DataSource ds = dataSourceConverter.fromPropertyString(driverPropertyString);
assertEquals(0, ds.getConnectionProperties().size());
}
代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic
connectionPool.setAttribute("Password", ds.getPassword());
ds.getConnectionProperties().setProperty("user", ds.getUsername());
connectionPool.setAttribute("Properties", new DataSourceConverter()
.getConnectionPropertiesAsASemicolonDelimitedString(ds));
代码示例来源:origin: org.codehaus.cargo/cargo-core-container-glassfish
firstDS.getDriverClass(), firstDS.getUrl(), firstDS.getUsername(),
firstDS.getPassword(), "DummyCargoDefaultDS-" + firstDS.getId(),
new Properties(firstDS.getConnectionProperties()));
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test the {@link Properties} constructor.
*/
public void testPropertiesConstructor()
{
Properties props = new Properties();
props.setProperty(DatasourcePropertySet.ID, "rudolf");
props.setProperty(DatasourcePropertySet.TRANSACTION_SUPPORT,
TransactionSupport.NO_TRANSACTION.toString());
props.setProperty(DatasourcePropertySet.JNDI_LOCATION, "jdbc/JiraDS");
props
.setProperty(DatasourcePropertySet.CONNECTION_TYPE, ConfigurationEntryType.JDBC_DRIVER);
props.setProperty(DatasourcePropertySet.DRIVER_CLASS, "org.hsqldb.jdbcDriver");
props.setProperty(DatasourcePropertySet.URL, "postresql:localhost:jirads");
props.setProperty(DatasourcePropertySet.USERNAME, "sa");
props.setProperty(DatasourcePropertySet.PASSWORD, "");
DataSource ds = dataSourceConverter.fromProperties(props);
assertEquals(0, ds.getConnectionProperties().size());
assertEquals("", ds.getPassword());
assertEquals(props, dataSourceConverter.toProperties(ds));
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* This method converts the DataSource to a Resource used in Tomcat.
*
* @return a Resource that can be used in Tomcat.
* @param ds the DataSource we are configuring.
*/
protected Resource convertToResource(DataSource ds)
{
Properties parameters = new Properties();
PropertyUtils.setPropertyIfNotNull(parameters, "url", ds.getUrl());
PropertyUtils.setPropertyIfNotNull(parameters, "username", ds.getUsername());
PropertyUtils.setPropertyIfNotNull(parameters, "password", ds.getPassword());
parameters.putAll(ds.getConnectionProperties());
Resource resource = new Resource(ds.getJndiLocation(), ConfigurationEntryType.DATASOURCE);
PropertyUtils.setPropertyIfNotNull(parameters, "driverClassName", ds.getDriverClass());
resource.setParameters(PropertyUtils.toMap(parameters));
return resource;
}
代码示例来源:origin: org.codehaus.cargo/cargo-core-container-tomcat
/**
* This method converts the DataSource to a Resource used in Tomcat.
*
* @return a Resource that can be used in Tomcat.
* @param ds the DataSource we are configuring.
*/
protected Resource convertToResource(DataSource ds)
{
Properties parameters = new Properties();
PropertyUtils.setPropertyIfNotNull(parameters, "url", ds.getUrl());
PropertyUtils.setPropertyIfNotNull(parameters, "username", ds.getUsername());
PropertyUtils.setPropertyIfNotNull(parameters, "password", ds.getPassword());
parameters.putAll(ds.getConnectionProperties());
Resource resource = new Resource(ds.getJndiLocation(), ConfigurationEntryType.DATASOURCE);
PropertyUtils.setPropertyIfNotNull(parameters, "driverClassName", ds.getDriverClass());
resource.setParameters(PropertyUtils.toMap(parameters));
return resource;
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* This method converts the DataSource to a Resource.
*
* @param ds DataSource to convert to a resource.
* @param resourceType the type of the Resource to convert to. ex.
* <code>javax.sql.DataSource</code>
* @param driverParameter the name of the parameter to store {@link DataSource#getDriverClass()
* driverClass}.
* @return a Resource representing the assignable fields of the DataSource.
*/
public Resource convertToResource(DataSource ds, String resourceType, String driverParameter)
{
Properties parameters = new Properties();
if (ds.getUrl() != null)
{
PropertyUtils.setPropertyIfNotNull(parameters, "url", ds.getUrl());
}
PropertyUtils.setPropertyIfNotNull(parameters, "user", ds.getUsername());
PropertyUtils.setPropertyIfNotNull(parameters, "password", ds.getPassword());
PropertyUtils.setPropertyIfNotNull(parameters, driverParameter, ds.getDriverClass());
parameters.putAll(ds.getConnectionProperties());
Resource resource = new Resource(ds.getJndiLocation(), resourceType);
resource.setParameters(PropertyUtils.toMap(parameters));
return resource;
}
内容来源于网络,如有侵权,请联系作者删除!