David Sean Taylor escribió:
> > I am not very good at explaining these things. :-)
>
> Not true. I've never been sure about how the DiskCache was meant to work,
> and now I think I understand better, thanks to you.
> I've been using the disk cache to resolve local, relative urls, and perhaps
> I shouldn't be.
> For ex.
>
> url = JetspeedDiskCache.getInstance().getEntry(url).getURL();
It is much better to get a Reader from the cache like:
Reader rdr = JetspeedDiskCache.getInstance().getEntry(url).getReader();
and process it later. This is why the service should be called ResourceManager
or URLManager:
Resource res = JetspeedResourceManafer.getResource( url );
if( res.isBad() ) {
Throw new Error();
}
try {
Reader rdr = res.getReader();
...
} catch (IOException ioe) { do whatever }
looks much cleaner and reads like what it really is.
The service is supposed to hide knowledge about which services are cached or
not, even knowledge about protocols. It is also supposed to synchronise access,
to avoid accessing the same external resource in parallel, and cache external
resources to avoid DOS attacks or network saturation.
I have thought about implementing it as a URL ProtocolHandler, but this has
Security problems (i.e. not every java program is allowed to change the
property needed to enable this). But this way usage would be much more
transparent, like
URL url = new URL("jrmgr:http://www.10.am/extra/ocsdirectory.xml");
URLConnection conn = url.getConnection();
Reader rdr = new InputStreamReader( conn.getInputStream(),
conn.getContentEncoding() );
or the more sophisticated
Class[] class = new Class[1];
class[0] = Registry.class;
Registry reg = ( Registry )conn.getObject( class );
if we implement ContentHandlers for several xml schemas, like registry, rss,
etc.
But I think it is invading too much the competences of a Content Management
System. In the long term, and for production quality sites, the basic cache we
have should be substituted by a good CMS, that would take care of all the
issues we are attacking here. Nevertheless, it is good to have it as a basic
reference implementation.
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Santiago Gala
> > Sent: Wednesday, January 10, 2001 12:50 AM
> > To: JetSpeed
> > Subject: Re: XSLPortlet , JetspeedContent
> >
> >
> > David Sean Taylor escribió:
> >
> > > Thanks Santiago, I believe the Observer pattern to be a good choice.
> > >
> > > The old system never really worked for me, there's either a bug
> > in expire()
> > > or its too complicated for my feeble mind...
> > > Anyway, Im very glad to hear you are working on a new impl.
> > >
> > > Im now discussing how the new system will work, please excuse
> > me if Im being
> > > redundant, but I really want to understand how this works!
> > >
> > > How will the cache determine when a file is modified on the file system?
> >
> > The DiskCache is NOT for caching local files, but for caching
> > external URLs.
> > One of the main problems that we faced is that it is difficult to know the
> > difference. Currently, everthing local is served "as is" i.e. as
> > a url, while
> > every resource coming from a different server is cached in the
> > WEB-INF/cache
> > subdirectory.
> >
> >
> > >
> > > Will it run a daemon, which will periodically poll the file
> > system and check
> > > the modified date?
> >
> > The Disk Cache has a Daemon, that runs every so and so, and checks the
> > lastModified and Expires fields of each URL. If the URL was
> > modified, it is
> > reloaded and all portlets depending on this url are expired (at
> > least it was
> > like this)
> >
> >
> > >
> > > Or is this controlled by the expire method() - is the expire
> > method used to
> > > set the polling frequency?
> > > Alternatively, I assume this can be done by someone 'deploying'
> > an updated
> > > file, and then calling the refresh() method
> >
> > The DiskCache does not handle files.
> >
> > >
> > > > You should think of the disk cache as URLManager, or
> > ResourceManager. It
> > > > is on
> > > > charge of synchronising fetching and caching of external
> > resources, more
> > > > or
> > > > less like what a HTTP proxy would do.
> > >
> > > when you say caching, where is the caching occurring? Is the
> > DiskCache also
> > > for resources on other html servers?
> > > I thought it was only for local files. If its for local files,
> > what exactly
> > > is being cached if it doesn't use a memory cache?
> > >
> > > > The portlet used a memory cache, so your portlet should be cached in
> > > > memory,
> > > > until it expires. Once it expires, it will be reinstantiated. Look at
> > > > the
> > > > code in PortletFactory.
> > >
> >
> > The memory cache is a different one. It is used to cache objects
> > in memory. It
> > is governed by an expiration mechanism. Portlets use this kind of
> > memory cache
> > to avoid recomputing them, while the remote rss url that defines
> > RSSPortlets is
> > stored by the disk cache to avoid going to the network every time..
> >
> > >
> > > yes, i need to look at this.
> > > Im not quite sure of the purpose of expiring portlets
> >
> > It is so that the items in the portlets can be recalculated from
> > the url. If
> > the url was refreshed by the DiskCacheDaemon in the while, the
> > portlet will
> > have new content. If not, it will simply be recalculated.
> >
> > I am not very good at explaining these things. :-)
> >
> > >
> > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED]
> > > > [mailto:[EMAIL PROTECTED]]On Behalf Of Santiago Gala
> > > > Sent: Tuesday, January 09, 2001 5:55 PM
> > > > To: JetSpeed
> > > > Subject: RE: XSLPortlet , JetspeedContent
> > > >
> > > >
> > > > David Sean Taylor escribió:
> > > >
> > > >
> > > > I'll send it CC to the list, with the old subject, so that
> > the answer is
> > > > public and other people can contribute.
> > > >
> > > > > Hi Santiago,
> > > > >
> > > > > I think you may have missed my email yesterday on the mailing
> > > > list, so Im
> > > > > including it again below.
> > > > > Hope you don't mind me asking you directly, but I often do
> > not receive
> > > > > responses to threads that I start on the mailing list, for what
> > > > reasons I
> > > > > really dont know.
> > > > >
> > > >
> > > > I was waiting until now, that I'm back in the office, to answer. This
> > > > time I
> > > > even flagged it to make sure I would remember,
> > > >
> > > > >
> > > > > On a more serious subject :), I believe that you and I have
> > broken the
> > > > > build.
> > > > > On your part, NewRSSPortlet uses the
> > JetspeedXMLReaderFactory, which was
> > > > > deleted.
> > > > >
> > > >
> > > > It seems that I forgot to commit this one. I have just done it. Sorry
> > > > aboutthat one :-(
> > > >
> > > >
> > > >
> > > > >
> > > > > Here is the email from yesterday:
> > > > >
> > > > > "
> > > > > Santiago, could you help me in understanding how the
> > DiskCache works?
> > > > > What I'd like to do is cache content in memory, but when
> > the resource
> > > > > changes on the disk, then refresh it.
> > > >
> > > > With the old cache, entries are checked only when the DiskCacheDaemon
> > > > runs.
> > > > The method "hasExpired" for a cache entry tells wether it has expired,
> > > > and
> > > > something like:
> > > >
> > > > URLFetcher.refresh( url ) should try to refresh (in the same thread)
> > > > and
> > > > return true, if it got refreshed, or false, if either it was
> > not expired
> > > > or
> > > > there was some problem, or it was not modified in the server.
> > > >
> > > > The whole interface is changing. For the new version, I am
> > implementing
> > > > the
> > > > cache entries as java.util.Observable, so that any object can declare
> > > > itself
> > > > as an observer of the entry, and be notified either when it expires or
> > > > when it
> > > > gets refreshed. Also, the entries will have a refresh method that will
> > > > handle
> > > > the refresh, if needed.
> > > >
> > > > I'm using Observable for tests, but we can change this class by some
> > > > other
> > > > interface if needed after the concept is tested. I will look
> > for similar
> > > > patterns in Turbine/Avalon code.
> > > >
> > > > >
> > > > > Like the XSLPortlet. To optimize its performance it shouldn't
> > > > have to run
> > > > > the transform everytime.
> > > > > Is caching content something that the DiskCache should be
> > providing, or
> > > > > should we be writing that code in our portlets (like the
> > XSLPortlet)?
> > > > >
> > > > > Or for a simple html file. Is the DiskCache supposed to cache
> > > > the file in
> > > > > memory, and then figure out when its been modified and keep the
> > > > memory copy
> > > > > sychronized?
> > > >
> > > > The actual disk cache does not handle caching in memory. For what you
> > > > want, we
> > > > should probably have a "glue" object that contains the object, caches
> > > > itself
> > > > in memory using the memory cache, and takes care of the
> > interaction with
> > > > the
> > > > disk cache.
> > > >
> > > > The portlet used a memory cache, so your portlet should be cached in
> > > > memory,
> > > > until it expires. Once it expires, it will be reinstantiated. Look at
> > > > the
> > > > code in PortletFactory.
> > > >
> > > > You should think of the disk cache as URLManager, or
> > ResourceManager. It
> > > > is on
> > > > charge of synchronising fetching and caching of external
> > resources, more
> > > > or
> > > > less like what a HTTP proxy would do.
> > > >
> > > > I think that the portlet expiration mechanism has some flaws, and
> > > > possibly
> > > > also the Disk Cache.
> > > >
> > > > I don't look at it very much, since the code is very messy and I'm
> > > > working in
> > > > a replacement. It has to be ready "real soon now". :-)
> > > >
> > > > >
> > > > > "
> > > > >
> > > > > Thanks,
> > > > >
> > > > > David
> > > >
> > > >
> > > > --
> > > > --------------------------------------------------------------
> > > > To subscribe: [EMAIL PROTECTED]
> > > > To unsubscribe: [EMAIL PROTECTED]
> > > > Search: <http://www.mail-archive.com/[email protected]/>
> > > > List Help?: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > > --
> > > --------------------------------------------------------------
> > > To subscribe: [EMAIL PROTECTED]
> > > To unsubscribe: [EMAIL PROTECTED]
> > > Search: <http://www.mail-archive.com/[email protected]/>
> > > List Help?: [EMAIL PROTECTED]
> >
> >
> >
> > --
> > --------------------------------------------------------------
> > To subscribe: [EMAIL PROTECTED]
> > To unsubscribe: [EMAIL PROTECTED]
> > Search: <http://www.mail-archive.com/[email protected]/>
> > List Help?: [EMAIL PROTECTED]
> >
> >
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/[email protected]/>
> List Help?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/[email protected]/>
List Help?: [EMAIL PROTECTED]