-
1. Re: Loading custom application configuration files
alesj Jan 26, 2010 10:06 AM (in response to tarcieri)It depends on what you're trying to do.
Be more exact, and we'll try to find the right approach.
e.g. could be custom deployer or just plain CL::getResource - as default domain is flat anyway
-
2. Re: Loading custom application configuration files
tarcieri Jan 26, 2010 10:17 AM (in response to alesj)More exact? Okay.
First, this is a JRuby application. Second, I don't really know a lot about JBoss. Oof.
Anyway we presently have a system in place in Ruby to deliver notifications about application errors to a number of different pluggable backends (e.g. SNMP, syslog, email)
I'm looking for a way to configure which backend to use, and what the endpoints for that particular backend should be.
Alternatively I suppose I could look for a way to thunk the JRuby error information back out into the JBoss environment, but that sounds a lot more difficult than using what we already have in place.
-
3. Re: Loading custom application configuration files
alesj Jan 26, 2010 10:24 AM (in response to tarcieri)Are you using TorqueBox?
-
4. Re: Loading custom application configuration files
tarcieri Jan 26, 2010 10:28 AM (in response to alesj)No, we can't use TorqueBox, because it requires Java 6 and JBoss 5, and we're stuck on Java 5 and JBoss EAP 4.3.0
We're using Warbler to package the application.
-
5. Re: Loading custom application configuration files
alesj Jan 27, 2010 9:44 AM (in response to tarcieri)We're using Warbler to package the application.
No idea what a Warbler is. :-)
Like I said, you can simply drop it in the deploy/ and
* find it with ClassLoader::getResource("my-resource.xml") -- if something like CL exists in Warbler/(J)Ruby
* create a custom deployer (which knows how to handle my-resource.xml) and integrate it with your existing logic
-
6. Re: Loading custom application configuration files
tarcieri Jan 27, 2010 9:50 AM (in response to alesj)I managed to get this solved using ClassLoader::getResourceAsStream() which allowed me to read the config file into the JRuby environment.
Thanks for the help!
And for anyone else who is interested in doing this sort of thing from JRuby, you can get the ClassLoader via:
java.lang.Thread.current_thread.context_class_loader
Then just invoke get_resource_as_stream("myresource").to_io to get a Ruby IO object
-
7. Re: Loading custom application configuration files
alesj Jan 27, 2010 10:02 AM (in response to tarcieri)I managed to get this solved using ClassLoader::getResourceAsStream() which allowed me to read the config file into the JRuby environment.
Just a side note.
This way you're a bit order dependent - classloaders for both deployments need to be created already.
This is usually the case when you're looking up things, hence just in case someone has some "earlier" resource lookup intentions. :-)