B
bugbear
My application is currently configured by giving it
a URL pointing to complex config data (which is in XML,
and parsed using Xerces).
For Testing (JUnit) purposes, I would very much like
to be able to throw small (going on tiny) configs
around.
So I have come up with the idea of using a trivial
protocol (e.g. "string:") where the URL *itself*
is (or contains?) the data.
Thus, if I had some config data in configString
private final String configString =
"<?xml version='1.0' encoding='UTF-8' ?>" +
"<config>" +
"<config_elem name=\"henry\">" +
" <other_elem>" +
" </other_elem>" +
"</config_elem" +
"</config>";
I would like to do:
URL url = "string:" + escapeForURL(configString);
And have a suitable ("string:") protocol handler take over in
the "real" code, and give access to an InputStream
formed from the String.
Has anyone else already done this?
The learning curve looks pretty steep to me:
http://java.sun.com/developer/onlineTraining/protocolhandlers/
BugBear
a URL pointing to complex config data (which is in XML,
and parsed using Xerces).
For Testing (JUnit) purposes, I would very much like
to be able to throw small (going on tiny) configs
around.
So I have come up with the idea of using a trivial
protocol (e.g. "string:") where the URL *itself*
is (or contains?) the data.
Thus, if I had some config data in configString
private final String configString =
"<?xml version='1.0' encoding='UTF-8' ?>" +
"<config>" +
"<config_elem name=\"henry\">" +
" <other_elem>" +
" </other_elem>" +
"</config_elem" +
"</config>";
I would like to do:
URL url = "string:" + escapeForURL(configString);
And have a suitable ("string:") protocol handler take over in
the "real" code, and give access to an InputStream
formed from the String.
Has anyone else already done this?
The learning curve looks pretty steep to me:
http://java.sun.com/developer/onlineTraining/protocolhandlers/
BugBear