cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: Life cycle of a producer
Date Mon, 15 May 2000 09:28:37 GMT
P.S. To have init code shared between servlet contexts, if you're using more 
than one Cocoon servlet context, use static fields and static initializers 
instead. I thought I'd mention this because the distinction between static 
and non-static fields and methods is often not immediately clear to 
newcomers to Java (it even took me a while to figure out! ;)

(What really confuses some people, is that this static technique doesn't 
work for applets. That's because applets are a special case, for security 
reasons - there, classloaders are used to prevent sharing static stuff 
accross applets.)

class ... {

  private static Hashtable swedishWords;

  static {
    doMySetup ();
  }

  private static void doMySetup () {
    // ...
  }

  // ...
}
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


Mime
View raw message