[daisy] concurrent acces to the repository

Bruno Dumon bruno at outerthought.org
Wed Nov 22 04:26:54 CST 2006


On Tue, 2006-11-21 at 22:13 +0100, Simon Büttner wrote:
> Hi everybody,
> we are planning to use the daisy repository servers as our backend for
> document management  and storage.
> 
> The document access will be done by a webapplication. What is the best
> pratice for accessing the repository? (perhaps i should look at the
> wiki sources)
> 
> We plan to override the daisy usermanagement because all documents
> will be accessed by the system and not directly by users. (we have our
> own user management)
> 
> Is it a good way to solve this by creating a connection pool  which
> holds some active repository connections to avoid connection creating
> for every query?

Hi,

you need:

 - just one instance of RemoteRepositoryManager shared by everyone (all
threads).

 - from there you can get Repository instances. These are lightweight
objects, but are not thread safe (or in any case, shouldn't be assumed
to be thread safe). So you need separete/new instances for each usage.
However each time you call RepositoryManager.getRepository(credentials),
it will check the credentials with repository server.

To avoid this check (which is a HTTP call), you can call getRepository
just once, and then clone the repository object, like this:

Repository repository = (Repository)((RemoteRepositoryImpl)templateRepository).clone();

So you can just get a Repository instance once (e.g. during application
startup), and then return clones of that one instance. Pooling would
also be an option, but is not really needed (since they are lightweight
objects just holding the authentication data, actual connection pooling
is done by the RemoteRepositoryManager) and would require you to take
care to release the repository objects back to the pool etc.

PS: for publish-frontends, it might be interesting to look at the
'Publisher' component.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno at outerthought.org                          bruno at apache.org



More information about the daisy mailing list