Issue Details (XML | Word | Printable)

Key: JCR-245
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jukka Zitting
Reporter: Jukka Zitting
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Jackrabbit Content Repository

Automatic repository shutdown

Created: 06/Oct/05 08:05 PM   Updated: 08/Mar/06 01:24 AM
Return to search
Component/s: jackrabbit-core
Affects Version/s: None
Fix Version/s: 1.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works TransientRepository.patch 2005-12-07 08:38 AM Jukka Zitting 9 kB
Issue Links:
Reference
 

Resolution Date: 09/Dec/05 06:53 PM


 Description  « Hide
Currently Jackrabbit relies on two mechanisms for safely shutting down a repository:

    1) client application invoking RepositoryImpl.shutdown(), or
    2) the shutdown hook installed by RepositoryImpl being run

Both of these mechanisms have problems:

    1) The shutdown() method is not a part of the JCR API, thus making the client application depend on a Jackrabbit-specific feature
    2) In some cases the shutdown hook is not properly run (see issues JCR-120 and JCR-233)

I think the JCR spec thinks of the Repository and Session interfaces as being somewhat similar to the JDBC DataSource and Connection interfaces. The Repository instances have no real lifecycle methods while the Session instances have clearly specified login and logout steps. (DataSource.getConnection() = Repository.login(), Session.logout() = Connection.close()) However the Jackrabbit implementation defines an explicit lifecycle for the RepositoryImpl instances.

This causes problems especially for container environments (JNDI, Spring) where it is hard or even impossible to specify a shutdown mechanism for resource factories like the Repository instances. The current solution for such environments is to use a shutdown hook, but as reported this solution does not work perfectly in all cases.

How about if we bound the RepositoryImpl lifecycle to the lifecycles of the instantiated Sessions. A RepositoryImpl instance could initialize (and lock) the repository when the first session is opened and automatically shut down when the last session has logged out. As long as the sessions are properly logged out (or finalized by the garbage collector) there would be no need for an explicitly RepositoryImpl.shutdown() call. The current behaviour of pre-initializing the repository and shutting down during a shutdown hook could be enabled with a configuration option for environments (like global JNDI resources) in which the shutdown hooks work well.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #355430 Fri Dec 09 09:48:18 UTC 2005 jukka JCR-245: Added the TransientRepository utility class and an initial test case.
Files Changed
MODIFY /incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/TestAll.java
ADD /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
ADD /incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/TransientRepositoryTest.java

Repository Revision Date User Message
ASF #355439 Fri Dec 09 10:27:47 UTC 2005 jukka JCR-245: Removed the Java 5 Collections.addAll() call.
Files Changed
MODIFY /incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/TransientRepositoryTest.java