Skip to main content

Custom Facelet cache and Project Stage

1 reply [Last post]
yannsimon
Offline
Joined: 2007-08-14
Points: 0

Hi,

I wrote a custom facelet cache (based on ehcache) to handle a very important number of xhtml without making the memory explode.
(if you are interested: the cache simply uses a SelfPopulatingCache configured with a LFU (Less Frequently Used) eviction policy)

On the development stage, I would like to deactivate this cache, so that the changes made to a xhtml is immediately re-compiled and shown.

In the constructor of my custom facelet cache, I tried to access the project stage with FacesContext.getCurrentInstance().getApplication().getProjectStage().

But I suppose that the application is still not completely configured at this point.
I got the following exception:
26.07.2010 11:43:52 org.apache.catalina.core.StandardContext listenerStart
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.StackOverflowError
at java.util.concurrent.locks.ReentrantLock$Sync.(ReentrantLock.java:91)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.(ReentrantLock.java:175)
at java.util.concurrent.locks.ReentrantLock.(ReentrantLock.java:234)
at java.util.concurrent.ConcurrentHashMap$Segment.(ConcurrentHashMap.java:289)
at java.util.concurrent.ConcurrentHashMap.(ConcurrentHashMap.java:613)
at java.util.concurrent.ConcurrentHashMap.(ConcurrentHashMap.java:652)
at com.sun.faces.util.Cache.(Cache.java:69)
at com.sun.faces.application.ApplicationImpl$SystemEventHelper.(ApplicationImpl.java:2164)
at com.sun.faces.application.ApplicationImpl.(ApplicationImpl.java:195)
at com.sun.faces.application.ApplicationFactoryImpl.getApplication(ApplicationFactoryImpl.java:103)
at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:106)

Can somebody confirm that it is too "early" to get the project stage?
Should I use a system event listener (type PostConstructApplicationEvent) to achieve what I want to?

Thanks in advance
Yann

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Edward Burns

On 7/26/10 6:05 , webtier@javadesktop.org wrote:

> Can somebody confirm that it is too "early" to get the project stage?
> Should I use a system event listener (type PostConstructApplicationEvent) to achieve what I want to?

I'm really glad to hear of your optimization. It sounds very useful. I
hope you blog about it so more can share it's benefits.

Now, regarding your question, yes, I have used a
PostConstructApplicationEvent, or even an eager ApplicationScoped bean
to do this sort of thing.

Ed

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net