Hello, I have an application that transforms HTML documents at run time using the Jakarta ORO library. I have created a number of Perl5Patterns and I would like to place them in a singleton class and have all threads share these patterns rather than compile them every time an html file is requested from the web server.
Is it safe/recommended to place patterns in a singleton and use the Perl5Compiler.READ_ONLY_MASK? The singleton class would behave as follows..... class PatternSingleton { private Pattern htmlPattern ; private PatternSingleton ( ) { PatternCompiler compiler = new Perl5Compiler(); htmlPattern = compiler.compile( someExpression, Perl5Compiler.READ_ONLY_MASK); } //.... OTHER methods here public Pattern getPattern ( ) { return htmlPattern; } } Thank You, Cassandra