-
1. Re: Reference a JSON document in a fabric profile
jastrachan May 20, 2014 10:29 AM (in response to xavierbutt)Have you tried using a URL handler?
new URL("profile:config.json")
instead of using a File? For more see the url handlers: http://fabric8.io/#/site/book/doc/index.md?chapter=urlHandlers_md
-
2. Re: Reference a JSON document in a fabric profile
xavierbutt May 20, 2014 11:38 AM (in response to xavierbutt)It works! Thanks James. I was really glad to find out the URL Handlers resolve at runtime and not at startup. Great work!
-
3. Re: Reference a JSON document in a fabric profile
jastrachan May 20, 2014 11:47 AM (in response to xavierbutt)Glad to hear it works
BTW I raised an issue so that when folks are not inside Karaf (e.g. they are inside a Java Container with no fabric8 code inside) we could have a similar way to access configuration using the file system and a system property / environment variable too: https://github.com/fabric8io/fabric8/issues/1452
-
4. Re: Reference a JSON document in a fabric profile
davsclaus May 21, 2014 1:58 AM (in response to jastrachan)Yeah I am not sure there is a non invasive way of registering custom url handlers in a JVM that would could leverage for JVMs with no fabric-agent inside.
Though I wonder if using a java-agent can be considered a non invasive way? Though I like the idea of copying those profile resources to a known location, then the url is just standard file based, and you do not have to use "profile:" which would tie the code to fabric.
-
5. Re: Reference a JSON document in a fabric profile
jastrachan May 21, 2014 2:04 AM (in response to davsclaus)Yeah - another approach could be a canonical REST API which includes the current container's ID in the URL so that the JVM doesn't need to try guess what its contianer ID and profiles are etc.
something like new URL(System.getProperty("fabric8.container.url") + "/profile/mythingy.json")
where the system property fabric8.container.url could be something like "http://localhost:8181/fabric8/containers/mycontainerid" or something.
The REST API might be a bit nicer really; as its a bit more flexible then and we can expose any information at all from the fabric cleanly as a little REST API.