use of org.apache.openejb.util.SuperProperties in project tomee by apache.
the class Info2Properties method printSystemProperties.
private static void printSystemProperties(final PrintStream out, final String cr) {
try {
final SuperProperties p = new SuperProperties();
p.setSpaceBetweenProperties(false);
p.setKeyValueSeparator(" = ");
p.setLineSeparator(cr);
copyOpenEjbProperties(JavaSecurityManagers.getSystemProperties(), p);
copyOpenEjbProperties(SystemInstance.get().getProperties(), p);
p.store(out, null);
final Properties p2 = JavaSecurityManagers.getSystemProperties();
final String[] misc = { "os.version", "os.name", "os.arch", "java.version", "java.vendor" };
for (final String prop : misc) {
comment(out, cr, prop + "=" + p2.get(prop));
}
} catch (final IOException e) {
e.printStackTrace(new PrintWriter(new CommentsFilter(out)));
}
}
use of org.apache.openejb.util.SuperProperties in project tomee by apache.
the class TomEEDataSourceCreator method createProperties.
private SuperProperties createProperties(final String name, final Properties properties) {
final SuperProperties converted = new SuperProperties() {
@Override
public Object setProperty(final String name, final String value) {
if (value == null) {
return super.getProperty(name);
}
return super.setProperty(name, value);
}
}.caseInsensitive(true);
converted.setProperty("name", name);
// very few properties have default = connection ones, so ensure to translate them with priority to specific ones
converted.setProperty("url", properties.getProperty("url", (String) properties.remove("JdbcUrl")));
converted.setProperty("driverClassName", properties.getProperty("driverClassName", (String) properties.remove("JdbcDriver")));
converted.setProperty("username", (String) properties.remove("username"));
converted.setProperty("password", (String) properties.remove("password"));
converted.putAll(properties);
final String passwordCipher = (String) converted.remove("PasswordCipher");
if (passwordCipher != null && !"PlainText".equals(passwordCipher)) {
converted.setProperty("password", PasswordCipherFactory.getPasswordCipher(passwordCipher).decrypt(converted.getProperty("Password").toCharArray()));
}
return converted;
}
use of org.apache.openejb.util.SuperProperties in project tomee by apache.
the class AutoConfig method copy.
private ResourceInfo copy(final ResourceInfo a) {
final ResourceInfo b = new ResourceInfo();
b.id = a.id;
b.service = a.service;
b.className = a.className;
b.codebase = a.codebase;
b.displayName = a.displayName;
b.description = a.description;
b.factoryMethod = a.factoryMethod;
b.constructorArgs.addAll(a.constructorArgs);
b.originAppName = a.originAppName;
b.types.addAll(a.types);
b.properties = new SuperProperties();
b.properties.putAll(a.properties);
if (a.classpath != null) {
b.classpath = new URI[a.classpath.length];
System.arraycopy(a.classpath, 0, b.classpath, 0, a.classpath.length);
}
return b;
}
use of org.apache.openejb.util.SuperProperties in project tomee by apache.
the class Info2Properties method print.
private static void print(final PrintStream out, final String cr, final ServiceInfo info) {
try {
println(out, cr, "");
comment(out, cr, info.service + "(id=" + info.id + ")");
comment(out, cr, "className: " + info.className);
// TODO: the codebase value usually isn't filled in, we should do that.
// comment("codebase: " + info.codebase);
comment(out, cr, "");
final SuperProperties p = new SuperProperties();
p.setSpaceBetweenProperties(false);
p.setKeyValueSeparator(" = ");
p.setLineSeparator(cr);
String uri = "new://" + info.service;
if (info.service.matches("Container|Resource|Connector")) {
try {
final Map query = new HashMap();
query.put("type", info.types.get(0));
uri += "?" + URISupport.createQueryString(query);
} catch (final Exception e) {
// no-op
}
}
p.put(info.id, uri);
for (final Map.Entry<Object, Object> entry : info.properties.entrySet()) {
if (!(entry.getKey() instanceof String)) {
continue;
}
if (!(entry.getValue() instanceof String)) {
continue;
}
// If property name is 'password' replace value with 'xxxx' to protect it
if ("password".equalsIgnoreCase((String) entry.getKey())) {
p.put(info.id + "." + entry.getKey(), "xxxx");
} else {
p.put(info.id + "." + entry.getKey(), entry.getValue());
}
}
p.store(out, null);
} catch (final IOException e) {
out.println("# Printing service(id=" + info.id + ") failed.");
e.printStackTrace(new PrintWriter(new CommentsFilter(out)));
}
}
use of org.apache.openejb.util.SuperProperties in project tomee by apache.
the class WikiGenerator method generateService.
private void generateService(final ServiceProvider provider, final String serviceType) {
final String type = provider.getTypes().get(0);
out.println("# " + type + " <small>" + serviceType + " </small>");
out.println();
out.println("Declarable in openejb.xml via");
out.println();
out.println(" <" + provider.getService() + " id=\"Foo\" type=\"" + type + "\">");
out.println(" </" + provider.getService() + ">");
out.println();
out.println("Declarable in properties via");
out.println();
out.println(" Foo = new://" + provider.getService() + "?type=" + type);
out.println();
final SuperProperties properties = (SuperProperties) provider.getProperties();
final Map<String, String> defaults = new LinkedHashMap<String, String>();
if (properties.size() > 0) {
out.println("## Properties");
out.println();
for (final Object key : properties.keySet()) {
if (key instanceof String) {
final String name = (String) key;
final Map<String, String> attributes = properties.getAttributes(name);
if (attributes.containsKey("hidden")) {
continue;
}
out.println("### " + key);
out.println();
final String value = properties.getProperty(name);
String comment = properties.getComment(name);
comment = scrubText(comment);
defaults.put(name, String.valueOf(value));
if (comment.length() == 0) {
comment = "No description.";
}
out.println(comment);
out.println();
}
}
out.println("## Default declaration");
out.println(" <" + provider.getService() + " id=\"" + provider.getId() + "\" type=\"" + type + "\">");
for (final Map.Entry<String, String> entry : defaults.entrySet()) {
out.print(" ");
out.print(entry.getKey());
out.print(" = ");
out.println(entry.getValue());
}
out.println(" </" + provider.getService() + ">");
} else {
out.println("No properties.");
}
out.println();
}
Aggregations