Comments (5)
The ability to marshal/unmarshal XML documents is already implemented in JAXB, so maybe that can be a starting point.
from owner.
sure thing, but it's easier than that: java.util.Properties have the method already implemented, I just need to forward the method invokation. See PropertyInvocationHandler:
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// I just need to add something like:
// if (method == storeToXML()) {
// properties.storeToXML(args);
// return null;
// }
String key = key(method);
String defaultValue = defaultValue(method);
String value = properties.getProperty(key, defaultValue);
if (value == null)
return null;
return convert(method.getReturnType(), format(value, args)); // TODO: variable expansion here would be nice
}
Very simple.
Then change the Config interface to add the storeToXML() method.
It's a little bit more complicate intead for the load (which I should implement in the ConfigFactory.load(InputStream))
from owner.
Looking at how XML properties are implemented in Java, now I find the reason why not to have them in Owner API.
Not sure this will be available anytime soon.
from owner.
link to #14
from owner.
Almost done :)
on master branch OWNER is able to load xml files into properties. The format can be the one specified by the DTD of the properties class, or an xml specified by the user on his own taste.
Example of xml accepted, as specified by the DTD in properties class:
The ugly java format:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>this is an example</comment>
<entry key="server.ssh.alive.interval">60</entry>
<entry key="server.ssh.address">127.0.0.1</entry>
<entry key="server.http.port">80</entry>
<entry key="server.http.hostname">localhost</entry>
<entry key="server.ssh.user">admin</entry>
<entry key="server.ssh.port">22</entry>
</properties>
A better example (the content is the same as above, and both will work the same way for OWNER):
<server>
<http port="80">
<hostname>localhost</hostname>
</http>
<ssh port="22">
<address>127.0.0.1</address>
<alive interval="60"/>
<user>admin</user>
</ssh>
</server>
Example of the mapping interface for the above xml examples
interface ServerConfig extends Config {
@Key("server.http.port")
int httpPort();
@Key("server.http.hostname")
String httpHostname();
@Key("server.ssh.port")
int sshPort();
@Key("server.ssh.address")
String sshAddress();
@Key("server.ssh.alive.interval")
int aliveInterval();
@Key("server.ssh.user")
String sshUser();
}
from owner.
Related Issues (20)
- CVE-2020-8908 (Low) detected in guava-27.0.1-jre.jar
- CVE-2018-10237 (Medium) detected in guava-16.0.1.jar - autoclosed HOT 1
- CVE-2023-2976 (High) detected in guava-27.0.1-jre.jar
- CVE-2021-4104 (High) detected in log4j-1.2.17.jar
- CVE-2014-0193 (Medium) detected in netty-3.7.0.Final.jar - autoclosed HOT 1
- CVE-2023-26464 (High) detected in log4j-1.2.17.jar
- CVE-2018-8012 (High) detected in zookeeper-3.4.8.jar - autoclosed HOT 1
- CVE-2023-44981 (Critical) detected in zookeeper-3.5.7.jar
- CVE-2019-17571 (Critical) detected in log4j-1.2.17.jar
- CVE-2020-9493 (Critical) detected in log4j-1.2.17.jar
- CVE-2015-2156 (High) detected in netty-3.7.0.Final.jar - autoclosed HOT 1
- CVE-2022-24823 (Medium) detected in netty-common-4.1.45.Final.jar
- CVE-2023-34462 (Medium) detected in netty-handler-4.1.45.Final.jar
- CVE-2021-37136 (High) detected in netty-codec-4.1.45.Final.jar
- CVE-2021-37137 (High) detected in netty-codec-4.1.45.Final.jar
- CVE-2020-11612 (High) detected in netty-codec-4.1.45.Final.jar
- CVE-2021-21290 (Medium) detected in netty-handler-4.1.45.Final.jar
- WS-2020-0408 (High) detected in netty-handler-4.1.45.Final.jar
- Possibility to get only those properties that explicitly declared in MyProperties interface
- Property keys defined at methods overridden by sub-interface not mapped by PropertiesManager
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from owner.