DynamicResourceDispatcher.java depends on ICEfacesResourceHandler.java. It is straightforward to remove some of the thread-blocking related code from ICEfacesResourceHandler, however the resource dispatching infrastructure appears to require more significant changes.
The current implementation made use of a WeakHashMap to hold weak references to the paths to the resources. Unfortunately, the lifetime of the path String in the heap is not strongly associated with the lifetime of the resource.
It will be necessary to define a new resource API that allows the developer to indicate the scope of the resource (typically Application or Session) or to store that resource under an EL accessible name in their desired scope.
public URI addResource(String name, Resource resource) //developer manages the scope
public URI addApplicationResource(Resource resource)
public URI addSessionResource(Resource resource)
The two convenience methods are optional, but if desired, would return a unique, automatically assigned name for resolving the resource.
Resource resolution would not require any persistent objects other than the resources themselves – the URI is sufficient to resolve the resource when requested.
Careful attention must be paid to security to ensure that an attacker is not able to request arbitrary session or application objects over the network. It may be sufficient that the resource object must be of a Resource type.
Try to remove ThreadLocal-s and threads.