What is the scope of static classes used in el language?
I assume application scope?
I tested it in debug mode and that lazy loaded attribute is only initialized once in multiple windows, browsers.
private static Object[] objects = null;
public static Object[] getObjects()
{
if(ElClass.objects == null)
//init objects
return ElClass.objects;
}
There is no means of a concrete instance. The EL functions class is not even constructed. EL functions are intented to be entirely stateless. Static variables are per definition JVM-wide (or application wide as you call it). In normal Java code you would also just do
ELClass.getObjects()instead ofnew ELClass().getObjects().As to your particular example, I recommend to do the initialization just in a static initializer block. That lazy loading is unnecessary.
I also recommend to add a private constructor so that you prevent that the functions class can ever be constructed.