ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: Specifying build properties
Date Mon, 24 Oct 2005 15:44:44 GMT
Rakesh Patel wrote:
> Thanks for that Steve. I would like to know more about "having the
> webapp load these dynamically 
> based on their hostname"....
> 
> Thanks
> 
> Rakesh
> 


1. work out your hostname. easy-ish to do, though multiple network cards 
can trick you. gethostbyname() is the

String hostname=java.net.InetAddress.getLocalHost().getHostName();

2. look for a properties resource with that name

string resource="/config/hosts/"+hostname+".properties";

3. load it.

InputStream in;
in=this.getClassloader().getResourceAsStream(resource);
if(in==null) {
  //no such resource
}

This design doesnt actually scale that well, for reasons I wont go in to 
here. Left as an exercise for the reader. Think about clusters.

Its sometimes better to host settings in a database table or on an LDAP 
server; then all the options needed in a WAR are the URL/login info of 
the database or LDAP box. But by offloading your options to the 
infrastructure, you have just taken them off revision control. So you 
cannot rollback a big set of changes, maybe not even audit when 
something changed and why. Ops will deny the change leaving the dev team 
to field the blame (or vice versa, depending on what changed)

When we use smartfrog (disclaimer, the project I work on) to do 
deployments, we keep the set of entire deployment descriptors locked 
down in subversion, tagged with releases. So we have different 
configurations for different targets, one war file and dynamically 
deploy the appserver, the war and the database all in one go. Its 
fiddlier to start with, but scales much better. http://smartfrog.org/

-stve


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message