[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Heavy usage of VirtualFileURLConnection

alesj do-not-reply at jboss.com
Thu Oct 30 10:50:55 EDT 2008


I've implemented simple vfs cache:

  | public interface VFSCache
  | {
  |    /**
  |     * Get the file.
  |     *
  |     * @param uri the file's uri
  |     * @return virtual file instance
  |     * @throws IOException for any error
  |     */
  |    VirtualFile getFile(URI uri) throws IOException;
  | 
  |    /**
  |     * Get the file.
  |     *
  |     * @param url the file's url
  |     * @return virtual file instance
  |     * @throws IOException for any error
  |     */
  |    VirtualFile getFile(URL url) throws IOException;
  | 
  |    /**
  |     * Put vfs context to cache.
  |     *
  |     * @param context the vfs context
  |     */
  |    void putContext(VFSContext context);
  | 
  |    /**
  |     * Remove vfs context from cache.
  |     *
  |     * @param context the vfs context
  |     */
  |    void removeContext(VFSContext context);
  | 
  |    /**
  |     * Start the cache.
  |     *
  |     * @throws Exception for any error
  |     */
  |    void start() throws Exception;
  | 
  |    /**
  |     * Stop the cache.
  |     */
  |    void stop();
  | }
  | 

As you can see it caches VFSContex.
Every time VFSContext is created, it is put into cache.
This creation only happens - if you use VFS API - in VFS class.

When you demand VirtualFile for given URI/URL,
I match VFSContex's rootURI to get the right context for URI/URL.
Then it's plain navigation from VFSContext to the actual relative VirtualFile.
Relative path == URI/URL path - context's path.

VFSCache comes in different impls: LRU, Timed, Soft, Weak.
It's all configurable over jboss.vfs.cache System property.

There is also optional CacheStatistics interface,
which knows how to return:
- cached contexts (unfortunately not for CachePolicy based cache)
- cache size
- last insert

I expect only a dozen contexts in this cache when running JBossAS.
e.g. deployers and deploy dir should be among them

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4185753#4185753

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4185753



More information about the jboss-dev-forums mailing list