[Yanel-dev] redeploying WARs fully automatically

Guillaume Déflache guillaume.deflache at wyona.com
Tue May 25 10:19:56 CEST 2010


Hi!

Michael Wechner schrieb:
> Michael Wechner wrote:
>> Michael Wechner wrote:
>>> Michael Wechner wrote:
>>>>
>>>>>
>>>>> 4) Use environment variable which is configured under the user the 
>>>>> webapp-server (e.g. Tomcat) is running or configure it during 
>>>>> startup of the webapp-server (e.g. Tomcat/bin/catalina.sh)
>>>
>>> I will start working on this by trying to check on an environment 
>>> variable called
>>>
>>> YANEL_REALMS_HOME
>>>
>>> whereas this would be a directory, e.g.
>>>
>>> /home/foo/yanel-realms
>>>
>>> which could cotains realms, e.g.
>>>
>>> /home/foo/yanel-realms/my-realm1/...
>>> /home/foo/yanel-realms/my-realm2/...
>>>
>>> but also a realms config, e.g.
>>>
>>> /home/foo/yanel-realms/realms.xml
>>>
>>> WDYT?
>>
>> btw, the implementation would be rather straightforward:
>>
>> --- src/core/java/org/wyona/yanel/core/map/RealmManager.java    
>> (revision 49784)
>> +++ src/core/java/org/wyona/yanel/core/map/RealmManager.java    
>> (working copy)
>> @@ -83,6 +83,17 @@
>>      * @return Something like realms.xml
>>      */
>>     private File getSetRealmsConfigFile(String 
>> yanelConfigurationFilename) throws ConfigurationException {
>> +        java.util.Map<String, String> env = System.getenv();
>> +        for (String envName : env.keySet()) {
>> +            if (envName.equals("YANEL_REALMS_HOME")) {
>> +                File yanelRealmsHome = new File(env.get(envName));
>> +                if (yanelRealmsHome.isDirectory()) {
>> +                    log.warn("DEBUG: YANEL_REALMS_HOME: " + 
>> yanelRealmsHome);
>> +                    break;
>> +                }
>> +            }
>> +        }
>> +
>>         YANEL_CONFIGURATION_FILE = yanelConfigurationFilename;
>>
>>         if 
>> (RealmManager.class.getClassLoader().getResource(YANEL_CONFIGURATION_FILE) 
>> == null) {
> 
> I have implemented an improved version of this and all my tests are very 
> fine. Also I have added some documentation
> 
> http://127.0.0.1:8080/yanel/yanel-website/en/documentation/configuration/realms_xml.html 

Neat! Thanks for implementing it!
(Sorry I am so late in replying, I was packing for my flat move the 
whole week-end!)


I thought about defining a Java property in addition to the environment 
variable as in some situation (cloud environments, shared hosting) you 
may not have access to the environment variables at all but might 
nevertheless be able define some Java properties.

Although for Goggle App Engine for example neither of these would work 
as system environment variables do not exist and Java properties only 
come from files included in the WAR: WEB-INF/appengine-web.xml (cf. 
<http://code.google.com/intl/de-DE/appengine/docs/java/config/appconfig.html#System_Properties_and_Environment_Variables>) 
and WEB-INF/web.xml itself (cf. 
<http://code.google.com/intl/de-DE/appengine/docs/java/runtime.html#The_Environment>).

So I guess in some cases defining an API for loading the Yanel 
configuration and implementing it differently for each target platform 
(Tomcat, Google App Engine) may be the only choice!


You also implemented lookup using user.home from what I can see at <in 
http://www.yanel.org/en/documentation/configuration/realms_xml.html>.
This is not so nice for development because you might want to run 
several Yanels simultaneously, and then if you have a rogue ~/realms.xml 
things can get pretty confusing (I know there is documentation for that 
but not having to read it may be better IMHO).
For deployment this probably works nicely if you have shell access to 
your server, because the user would then probably only be used for 
running the server and cannot even log in, so one is free to use its 
home directory!


user.dir may be another solution but finding where it really is can be 
hard! But if one logs all searched-for locations at the INFO level it 
gets much easier! Cf. 
http://discuss.joelonsoftware.com/default.asp?joel.3.145249.13#discussTopic145324
But if this needs modifying the installed distribution of the appserver 
it is not ideal either: hopefully with Tomcat it would search under 
cataline.base and not catalina.home...


HTH,
    Guillaume


More information about the Yanel-development mailing list