T
Timo Nentwig
Hi!
I'm somewhat confused:
class Foo
{
private static final ConditionalPropertiesReader PROPERTIES =
ConditionalPropertiesReader.getInstance();
private static final String defaultCacheStrategy =
PROPERTIES.getProperty( "jcms.cache.strategy" );
static
{
System.out.println("1 static{}"+defaultCacheStrategy);
}
....
public static IJCMSCacheStrategy getDefaultCacheStrategy()
{
System.out.println("2 getDefaultCacheStrategy()
"+defaultCacheStrategy);
return JCMSCacheStrategy.Factory.make( defaultCacheStrategy != null
? defaultCacheStrategy
:
JCMSCacheStrategy.Factory.CACHESTRATEGY_DEFAULT );
}
}
This prints:
2 getDefaultCacheStrategy() null
1 static{} myvalue
Why is that?? If I create an instance of the class prior to calling the
method defaultCacheStrategy in getDefaultCacheStrategy() *does* have the
supposed value. And why is 2 printed first??
Can somebody explain?
I'm somewhat confused:
class Foo
{
private static final ConditionalPropertiesReader PROPERTIES =
ConditionalPropertiesReader.getInstance();
private static final String defaultCacheStrategy =
PROPERTIES.getProperty( "jcms.cache.strategy" );
static
{
System.out.println("1 static{}"+defaultCacheStrategy);
}
....
public static IJCMSCacheStrategy getDefaultCacheStrategy()
{
System.out.println("2 getDefaultCacheStrategy()
"+defaultCacheStrategy);
return JCMSCacheStrategy.Factory.make( defaultCacheStrategy != null
? defaultCacheStrategy
:
JCMSCacheStrategy.Factory.CACHESTRATEGY_DEFAULT );
}
}
This prints:
2 getDefaultCacheStrategy() null
1 static{} myvalue
Why is that?? If I create an instance of the class prior to calling the
method defaultCacheStrategy in getDefaultCacheStrategy() *does* have the
supposed value. And why is 2 printed first??
Can somebody explain?