Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 73705 invoked from network); 19 May 2009 14:14:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 May 2009 14:14:35 -0000 Received: (qmail 53625 invoked by uid 500); 19 May 2009 14:14:35 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 53566 invoked by uid 500); 19 May 2009 14:14:35 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 53557 invoked by uid 99); 19 May 2009 14:14:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 May 2009 14:14:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 May 2009 14:14:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AE68D2388893; Tue, 19 May 2009 14:14:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r776322 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java Date: Tue, 19 May 2009 14:14:01 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090519141401.AE68D2388893@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Tue May 19 14:14:01 2009 New Revision: 776322 URL: http://svn.apache.org/viewvc?rev=776322&view=rev Log: JCR-2087: Upgrade to Java 5 as the base platform Use Java 5 features in TransientRepository. Also leverage the AbstractRepository class. Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java?rev=776322&r1=776321&r2=776322&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransientRepository.java Tue May 19 14:14:01 2009 @@ -19,10 +19,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Properties; @@ -33,6 +31,7 @@ import org.apache.commons.collections.map.ReferenceMap; import org.apache.jackrabbit.api.JackrabbitRepository; +import org.apache.jackrabbit.commons.AbstractRepository; import org.apache.jackrabbit.core.config.ConfigurationException; import org.apache.jackrabbit.core.config.RepositoryConfig; import org.slf4j.Logger; @@ -45,8 +44,8 @@ * when no longer used, this class can be used to avoid having to explicitly * shut down the repository. */ -public class TransientRepository - implements javax.jcr.Repository, JackrabbitRepository, SessionListener { +public class TransientRepository extends AbstractRepository + implements JackrabbitRepository, SessionListener { /** * The logger instance used to log the repository and session lifecycles. @@ -111,7 +110,8 @@ * repository instance is automatically shut down until a new session * is opened. */ - private final Map sessions = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK); + private final Map sessions = + new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK); /** * The static repository descriptors. The default {@link RepositoryImpl} @@ -271,15 +271,15 @@ * descriptor keys are returned. * * @return descriptor keys - * @see Repository#getDescriptorKeys() */ public synchronized String[] getDescriptorKeys() { if (repository != null) { return repository.getDescriptorKeys(); } else { - List keys = Collections.list(descriptors.propertyNames()); - Collections.sort(keys); - return (String[]) keys.toArray(new String[keys.size()]); + String[] keys = Collections.list( + descriptors.propertyNames()).toArray(new String[0]); + Arrays.sort(keys); + return keys; } } @@ -300,6 +300,33 @@ } } + public Value getDescriptorValue(String key) { + if (repository != null) { + return repository.getDescriptorValue(key); + } else { + throw new UnsupportedOperationException( + "not implemented yet - see JCR-2062"); + } + } + + public Value[] getDescriptorValues(String key) { + if (repository != null) { + return repository.getDescriptorValues(key); + } else { + throw new UnsupportedOperationException( + "not implemented yet - see JCR-2062"); + } + } + + public boolean isSingleValueDescriptor(String key) { + if (repository != null) { + return repository.isSingleValueDescriptor(key); + } else { + throw new UnsupportedOperationException( + "not implemented yet - see JCR-2062"); + } + } + /** * Logs in to the content repository. Initializes the underlying repository * instance if needed. The opened session is added to the set of open @@ -312,7 +339,8 @@ * @throws RepositoryException if the session could not be created * @see Repository#login(Credentials,String) */ - public synchronized Session login(Credentials credentials, String workspaceName) + public synchronized Session login( + Credentials credentials, String workspaceName) throws RepositoryException { // Start the repository if this is the first login if (sessions.isEmpty()) { @@ -321,7 +349,8 @@ try { logger.debug("Opening a new session"); - SessionImpl session = (SessionImpl) repository.login(credentials, workspaceName); + SessionImpl session = (SessionImpl) repository.login( + credentials, workspaceName); sessions.put(session, session); session.addListener(this); logger.info("Session opened"); @@ -336,61 +365,6 @@ } } - /** - * Calls {@link #login(Credentials, String)} with a null - * workspace name. - * - * @param credentials login credentials - * @return new session - * @throws RepositoryException if the session could not be created - * @see Repository#login(Credentials) - */ - public Session login(Credentials credentials) throws RepositoryException { - return login(credentials, null); - } - - /** - * Calls {@link #login(Credentials, String)} with null login - * credentials. - * - * @param workspaceName workspace name - * @return new session - * @throws RepositoryException if the session could not be created - * @see Repository#login(String) - */ - public Session login(String workspaceName) throws RepositoryException { - return login(null, workspaceName); - } - - /** - * Calls {@link #login(Credentials, String)} with null login - * credentials and a null workspace name. - * - * @return new session - * @throws RepositoryException if the session could not be created - * @see Repository#login(Credentials) - */ - public Session login() throws RepositoryException { - return login(null, null); - } - - - public Value getDescriptorValue(String key) { - throw new RuntimeException("not implemented yet - see JCR-2062"); - } - - public Value[] getDescriptorValues(String key) { - throw new RuntimeException("not implemented yet - see JCR-2062"); - } - - public boolean isSingleValueDescriptor(String key) { - throw new RuntimeException("not implemented yet - see JCR-2062"); - } - - public boolean isStandardDescriptor(String key) { - throw new RuntimeException("not implemented yet - see JCR-2062"); - } - //-------------------------------------------------- /** @@ -400,9 +374,8 @@ * @see Session#logout() */ public synchronized void shutdown() { - Iterator iterator = new HashSet(sessions.keySet()).iterator(); - while (iterator.hasNext()) { - Session session = (Session) iterator.next(); + Session[] copy = sessions.keySet().toArray(new Session[0]); + for (Session session : copy) { session.logout(); } } @@ -436,4 +409,5 @@ */ public void loggingOut(SessionImpl session) { } + }