PropertiesFactory is going through some refactoring to support i18n and
to allow for a more database/persistence layer driven forms and labels
(Hibernate migration).  Basically its does 3 things

a) On first load, it talks to a singleton class that gets initialize at
startup and reads in all config, properties, and xml files in a
specified directory

    Collection _props = new HashMap();
    String[] propFiles = Initializer.messagesFiles();
    if (propFiles != null)
      for (int i = 0; i < propFiles.length; i++){
        addPropsFile(propFiles[i]);
      } 

b) If a request comes in from any overloaded method requesting a
properties file at a different path or similar path, it
        1) checks to see if its already in the collection (requires a
key gets passed)
                i.e. to access our CriteriaDataService.properties  the
key would be CriteriaDataService
        2) if not it tries to look up the properties file from the
provided location or default location and then adds it to the map.

c) It has several other methods to get you a properties file property
either as is, quoted with double quotes or single quotes (usefull if you
want to pass back something to a database).  The ability to refresh a
single collection or clear out the entire properties map and start over
(done by a web config utility)

Unfortunately the PropertiesFactory source is not completely sharable as
it relies on other helper classes that I can not redistribute.  Feel
free to talk to me offline the ant user group.

-Eric
-----Original Message-----
From: Ivan Ivanov [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 28, 2005 7:25 PM
To: Ant Users List
Subject: RE: using buildnumber effectively

Eric,

This is pretty interesting. Several years I wrote a
similar taglib that showed localized messages in jsps
using the language set in the session. I used
java.util.ResourceBundle and worried about
performance, but ResourceBundle provides a way to
cache the (key,message) pairs so performance was not
an issue.

Anyway, I am pretty much curious about that Property
Factory and if it is not confidential could you please
show it?

Regards
Ivan

--- "Ferrer, Eric" <[EMAIL PROTECTED]> wrote:

> Ivan,
> 
> I have a Properties Factory where I plan to add the
> contents of the
> manifest.  Its ruffed up code to prove it can be
> done using the
> previously mention ant tasks.  The tld will invoke
> the read once and
> then add it to the Factory.
> 
> -----Original Message-----
> From: Ivan Ivanov
> [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 28, 2005 6:00 PM
> To: Ant Users List
> Subject: RE: using buildnumber effectively
> 
> Hello Eric,
> 
> this is fine. However, don't you think that it might
> slow down your web app, since every page you hit
> should retrieve the version from the manifest file
> again?
> 
> Regards
> Ivan
> 
> --- "Ferrer, Eric" <[EMAIL PROTECTED]>
> wrote:
> 
> > Ivan,
> > 
> > I quickly created this tag provided bellow and it
> > reads the manifest
> > file.  I do deploy to numerous webapps and the
> > deployment directory
> > differs between tomcat and websphere, I omitted
> > where I handle that
> > difference.  
> > 
> > Using the ant tasks, my manifest looks like this
> > 
> >     Manifest-Version: 1.0
> >     Ant-Version: Apache Ant 1.6.5
> >     Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)
> >     Author: admin
> >     Bundle-Name: DemoApp
> >     Bundle-Vendor: ABC Inc
> >     Bundle-Build: 20051123-bp1608
> >     Bundle-Version: 20051123-bp1608.019
> >     Bundle-Date: December 28 2005
> > 
> > My jsp calls <l:manifest
> > attributeName="Bundle-Build"/> to retrieve the
> > build and <l:manifest attributeName=" Bundle-Date
> > "/> to retrieve the
> > date.
> > 
> > Still needs more work, but it works.
> > 
> >  public class ManifestReaderTag extends TagSupport
> {
> > 
> >   private String _attributeName;
> > 
> > 
> >   /**
> >    * 
> >    */
> >   public ManifestReaderTag() {
> >     super();
> >   }
> > 
> > 
> >   /**
> >    * @return Returns the _attributeName.
> >    */
> >   public String getAttributeName() {
> >     return _attributeName;
> >   }
> >   /**
> >    * @param name The _attributeName to set.
> >    */
> >   public void setAttributeName(String name) {
> >     _attributeName = name;
> >   }
> >   
> >   public int doStartTag() throws JspException {
> >   
> >             readManifest();
> >       return SKIP_BODY;
> >   }
> > 
> > 
> > 
> >   /**
> >    * @see javax.servlet.jsp.tagext.Tag#doEndTag()
> >    */
> >   public int doEndTag() throws JspException {
> >   
> >   
> >     return super.doEndTag();
> >   }
> >   
> >   private void readManifest() {
> >     /* read our manifest and display values */
> >     JarFile jarFile = null;
> >     Attributes jarAttribs = null;
> >     if(getAttributeName() != null) {
> >       try{  
> >          
> >         Package thePackage =
> > getClass().getPackage();
> >         String theClass =
> > "/"+thePackage.getName().replace('.','/') +
> > "/ManifestReaderTag.class";
> >         URL turl =
> getClass().getResource(theClass);
> >               
> >           
> >         if(turl != null) {
> >           
> >           String pathToThisClass =
> turl.toString();
> > 
> >        /* appserver differences exists 
> >             code omitted
> >         */
> >     
> >             String manifestPath = pathToThisClass +
> > "/META-INF/MANIFEST.MF";
> >             
> >             //check if jar:file: present (shows up in
> > eclipse)
> >             int pos =
> > manifestPath.indexOf("jar:file:/"); 
> >             if(pos > -1)
> >               manifestPath =
> > manifestPath.substring(pos+10,
> > manifestPath.length());
> >             File theFile = new File(manifestPath);
> >             
> >             if(theFile != null) {
> >              FileInputStream fis = new
> > FileInputStream(theFile);
> >              
> >                     //Manifest manifest = new Manifest(new
> > URL(manifestPath).openStream());
> >                     Manifest manifest = new Manifest(fis);
> >                 
> >                           if(manifest != null) {
> >                             jarAttribs =
> > manifest.getMainAttributes();
> >                             
> >                             if(jarAttribs !=null) {
> >     
> > if(jarAttribs.containsKey(getAttributeName()))
> >     
> >
>
pageContext.getOut().write(jarAttribs.getValue(getAttributeName()));
> >                                     else
> >     
> > pageContext.getOut().write("Missing Attribute in
> > Manifest.MF");
> >                             }
> >                            
> >                             fis.close();
> >                           }
> >         }
> >            
> > 
> >         }
> >       }catch (IOException ioe) {
> >             System.err.println("Error reading
> manifest
> > file for
> > properties lookup : " + ioe.toString());
> >       } finally {
> >         if(jarFile != null)
> >           try{
> >             jarFile.close();
> >           } catch(java.io.IOException ioe) {
> >             //nothing to do
> >           }
> >       }
> >     }
> >   }
> > }
> > 
> > 
> > -----Original Message-----
> > From: Ivan Ivanov
> > [mailto:[EMAIL PROTECTED] 
> > Sent: Wednesday, December 28, 2005 4:57 PM
> > To: Ant Users List
> > Subject: Re: using buildnumber effectively
> > 
> > Hello Eric,
> > 
> > Using Alexey's code (I was going to provide
> similar
> 
=== message truncated ===



        
                
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to