Author: cziegeler
Date: Thu Jul  7 06:55:42 2011
New Revision: 1143678

URL: http://svn.apache.org/viewvc?rev=1143678&view=rev
Log:
SLING-2128 : Provide plain Repository services as SlingRepository services

Added:
    
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractNamespaceMappingRepository.java
   (with props)
    
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryProvider.java
   (with props)
    
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryWrapper.java
   (with props)
Modified:
    
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
    
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/SessionProxyHandler.java
    
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/loader/Loader.java

Added: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractNamespaceMappingRepository.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractNamespaceMappingRepository.java?rev=1143678&view=auto
==============================================================================
--- 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractNamespaceMappingRepository.java
 (added)
+++ 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractNamespaceMappingRepository.java
 Thu Jul  7 06:55:42 2011
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.base;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.jcr.api.NamespaceMapper;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.base.internal.loader.Loader;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * The <code>AbstractSlingRepository</code> is an abstract implementation of
+ * the {@link SlingRepository} interface which provides default support for
+ * attached repositories as well as ensuring live repository connection,
+ * reconnecting if needed. Implementations of the <code>SlingRepository</code>
+ * interface may wish to extend this class to benefit from a default
+ * implementation.
+ *
+ */
+public abstract class AbstractNamespaceMappingRepository implements 
SlingRepository {
+
+    /** Namespace handler. */
+    private Loader namespaceHandler;
+
+    /** Session proxy handler. */
+    private SessionProxyHandler sessionProxyHandler;
+
+    private ServiceTracker namespaceMapperTracker;
+
+    protected void setup(final BundleContext bundleContext) {
+        this.namespaceMapperTracker = new ServiceTracker(bundleContext, 
NamespaceMapper.class.getName(), null);
+        this.namespaceMapperTracker.open();
+        this.namespaceHandler = new Loader(this, bundleContext);
+        this.sessionProxyHandler = new SessionProxyHandler(this);
+    }
+
+    protected void tearDown() {
+        if ( this.namespaceMapperTracker != null ) {
+            this.namespaceMapperTracker.close();
+            this.namespaceMapperTracker = null;
+        }
+        if (this.namespaceHandler != null) {
+            this.namespaceHandler.dispose();
+            this.namespaceHandler = null;
+        }
+        this.sessionProxyHandler = null;
+    }
+
+    void defineNamespacePrefixes(final Session session) throws 
RepositoryException {
+        final Loader localHandler = this.namespaceHandler;
+        if (localHandler != null) {
+            // apply namespace mapping
+            localHandler.defineNamespacePrefixes(session);
+        }
+
+        // call namespace mappers
+        final Object[] nsMappers = namespaceMapperTracker.getServices();
+        if (nsMappers != null) {
+            for (int i = 0; i < nsMappers.length; i++) {
+                ((NamespaceMapper) 
nsMappers[i]).defineNamespacePrefixes(session);
+            }
+        }
+    }
+
+    protected Session getNamespaceAwareSession(final Session session) throws 
RepositoryException {
+        if ( session == null ) {  // sanity check
+            return null;
+        }
+        defineNamespacePrefixes(session);
+
+        // to support namespace prefixes if session.impersonate is called
+        // we have to use a proxy
+        final SessionProxyHandler localHandler = this.sessionProxyHandler;
+        if ( localHandler != null ) {
+            return localHandler.createProxy(session);
+        }
+        return session;
+    }
+}

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractNamespaceMappingRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractNamespaceMappingRepository.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractNamespaceMappingRepository.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java?rev=1143678&r1=1143677&r2=1143678&view=diff
==============================================================================
--- 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
 (original)
+++ 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
 Thu Jul  7 06:55:42 2011
@@ -33,15 +33,11 @@ import javax.jcr.Workspace;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Reference;
-import org.apache.sling.jcr.api.NamespaceMapper;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.base.internal.loader.Loader;
 import org.apache.sling.jcr.base.util.RepositoryAccessor;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * The <code>AbstractSlingRepository</code> is an abstract implementation of
@@ -53,8 +49,9 @@ import org.osgi.util.tracker.ServiceTrac
  *
  */
 @Component(componentAbstract=true)
-public abstract class AbstractSlingRepository implements SlingRepository,
-        Runnable {
+public abstract class AbstractSlingRepository
+    extends AbstractNamespaceMappingRepository
+    implements SlingRepository, Runnable {
 
     public static final String DEFAULT_ANONYMOUS_USER = "anonymous";
 
@@ -119,12 +116,6 @@ public abstract class AbstractSlingRepos
 
     private char[] adminPass;
 
-    /** Namespace handler. */
-    private Loader namespaceHandler;
-
-    /** Session proxy handler. */
-    private SessionProxyHandler sessionProxyHandler;
-
     // the poll interval used while the repository is not active
     private long pollTimeInActiveSeconds;
 
@@ -138,8 +129,6 @@ public abstract class AbstractSlingRepos
     // the background thread constantly checking the repository
     private Thread repositoryPinger;
 
-    private ServiceTracker namespaceMapperTracker;
-
     protected AbstractSlingRepository() {
     }
 
@@ -224,14 +213,7 @@ public abstract class AbstractSlingRepos
                 setDefaultWorkspace(defaultWorkspace);
             }
 
-            defineNamespacePrefixes(session);
-
-            // to support namespace prefixes if session.impersonate is called
-            // we have to use a proxy
-            if ( this.sessionProxyHandler != null ) {
-                return this.sessionProxyHandler.createProxy(session);
-            }
-            return session;
+            return this.getNamespaceAwareSession(session);
 
         } catch (NoSuchWorkspaceException nswe) {
             // if the desired workspace is the default workspace, try to create
@@ -441,9 +423,7 @@ public abstract class AbstractSlingRepos
      * @param repository The JCR <code>Repository</code> to setup.
      */
     protected void setupRepository(Repository repository) {
-        BundleContext bundleContext = componentContext.getBundleContext();
-        this.namespaceHandler = new Loader(this, bundleContext);
-        this.sessionProxyHandler = new SessionProxyHandler(this);
+        this.setup(componentContext.getBundleContext());
     }
 
     /**
@@ -549,11 +529,7 @@ public abstract class AbstractSlingRepos
      * @param repository
      */
     protected void tearDown(Repository repository) {
-        if (this.namespaceHandler != null) {
-            this.namespaceHandler.dispose();
-            this.namespaceHandler = null;
-        }
-        this.sessionProxyHandler = null;
+        this.tearDown();
     }
 
     /**
@@ -578,10 +554,7 @@ public abstract class AbstractSlingRepos
      *
      * @throws nothing, but allow derived classes to throw any Exception
      */
-    protected void activate(ComponentContext componentContext) throws 
Exception {
-        this.namespaceMapperTracker = new 
ServiceTracker(componentContext.getBundleContext(), 
NamespaceMapper.class.getName(), null);
-        this.namespaceMapperTracker.open();
-
+    protected void activate(final ComponentContext componentContext) throws 
Exception {
         this.componentContext = componentContext;
 
         @SuppressWarnings("unchecked")
@@ -625,9 +598,7 @@ public abstract class AbstractSlingRepos
      *
      * @param componentContext
      */
-    protected void deactivate(ComponentContext componentContext) {
-        this.namespaceMapperTracker.close();
-
+    protected void deactivate(final ComponentContext componentContext) {
         // stop the background thread
         stopRepositoryPinger();
 
@@ -706,21 +677,6 @@ public abstract class AbstractSlingRepos
         return false;
     }
 
-    void defineNamespacePrefixes(final Session session) throws 
RepositoryException {
-        if (this.namespaceHandler != null) {
-            // apply namespace mapping
-            this.namespaceHandler.defineNamespacePrefixes(session);
-        }
-
-        // call namespace mappers
-        Object[] nsMappers = namespaceMapperTracker.getServices();
-        if (nsMappers != null) {
-            for (int i = 0; i < nsMappers.length; i++) {
-                ((NamespaceMapper) 
nsMappers[i]).defineNamespacePrefixes(session);
-            }
-        }
-    }
-
     // ---------- Background operation checking repository availability 
--------
 
     private void setPollTimeActive(int seconds) {

Modified: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/SessionProxyHandler.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/SessionProxyHandler.java?rev=1143678&r1=1143677&r2=1143678&view=diff
==============================================================================
--- 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/SessionProxyHandler.java
 (original)
+++ 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/SessionProxyHandler.java
 Thu Jul  7 06:55:42 2011
@@ -39,9 +39,9 @@ public class SessionProxyHandler  {
     private Class<?>[] interfaces;
 
     /** The repository */
-    private final AbstractSlingRepository repository;
+    private final AbstractNamespaceMappingRepository repository;
 
-    public SessionProxyHandler(final AbstractSlingRepository repo) {
+    public SessionProxyHandler(final AbstractNamespaceMappingRepository repo) {
         this.repository = repo;
     }
 
@@ -81,11 +81,11 @@ public class SessionProxyHandler  {
 
     public static final class SessionProxyInvocationHandler implements 
InvocationHandler {
         private final Session delegatee;
-        private final AbstractSlingRepository repository;
+        private final AbstractNamespaceMappingRepository repository;
         private final Class<?>[] interfaces;
 
         public SessionProxyInvocationHandler(final Session delegatee,
-                            final AbstractSlingRepository repo,
+                            final AbstractNamespaceMappingRepository repo,
                             final Class<?>[] interfaces) {
             this.delegatee = delegatee;
             this.repository = repo;

Added: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryProvider.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryProvider.java?rev=1143678&view=auto
==============================================================================
--- 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryProvider.java
 (added)
+++ 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryProvider.java
 Thu Jul  7 06:55:42 2011
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.base.internal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Repository;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(specVersion="1.1")
+@Reference(name="repository",
+           referenceInterface=Repository.class,
+            policy=ReferencePolicy.DYNAMIC,
+            cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE)
+public class SlingRepositoryProvider {
+
+    private static final String SLING_REPOSITORY = 
SlingRepository.class.getName();
+
+    /** The logger. */
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private final Map<Long, RepositoryRegistration> registrations = new 
HashMap<Long, RepositoryRegistration>();
+
+    private BundleContext bundleContext;
+
+    private final List<Registration> repositories = new 
ArrayList<Registration>();
+
+    protected void activate(final BundleContext ctx) {
+        final List<Registration> copyList;
+        synchronized ( repositories ) {
+            this.bundleContext = ctx;
+            copyList = new ArrayList<Registration>(this.repositories);
+            this.repositories.clear();
+        }
+        for(final Registration reg : copyList) {
+            this.bindRepository(reg.repository, reg.properties);
+        }
+    }
+
+    protected void deactivate() {
+        synchronized ( repositories ) {
+            this.bundleContext = null;
+        }
+    }
+
+    private boolean isSlingRepository(final Map<String, Object> props) {
+        final String[] interfaces = (String[]) 
props.get(Constants.OBJECTCLASS);
+        if ( interfaces != null ) { // sanity check
+            for(final String name : interfaces) {
+                if ( SLING_REPOSITORY.equals(name) ) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    protected void bindRepository(final Repository repo, final Map<String, 
Object> props) {
+        if ( !isSlingRepository(props) ) {
+            final BundleContext processContext;
+            synchronized ( repositories ) {
+                processContext = this.bundleContext;
+                if ( processContext == null ) {
+                    this.repositories.add(new Registration(repo, props));
+                }
+            }
+            if ( processContext != null ) {
+                logger.info("Binding repository!");
+                final Long key = (Long)props.get(Constants.SERVICE_ID);
+                final RepositoryRegistration reg = new 
RepositoryRegistration();
+                reg.wrapper = new SlingRepositoryWrapper(repo, processContext);
+                reg.registration = 
processContext.registerService(SLING_REPOSITORY, reg.wrapper, null);
+                synchronized ( this.registrations ) {
+                    this.registrations.put(key, reg);
+                }
+            }
+        }
+    }
+
+    protected void unbindRepository(final Repository repo, final Map<String, 
Object> props) {
+        if ( !isSlingRepository(props) ) {
+            logger.info("Unbinding repository!");
+            synchronized ( repositories ) {
+                this.repositories.remove(new Registration(repo, props));
+            }
+            final Long key = (Long)props.get(Constants.SERVICE_ID);
+            final RepositoryRegistration slingRepo;
+            synchronized ( this.registrations ) {
+                slingRepo = this.registrations.remove(key);
+            }
+            if ( slingRepo != null ) {
+                slingRepo.wrapper.dispose();
+                slingRepo.registration.unregister();
+            }
+        }
+    }
+
+    private static final class Registration {
+        public final Repository repository;
+        public final Map<String, Object> properties;
+
+        private final long key;
+
+        public Registration(final Repository r, final Map<String, Object> p) {
+            this.repository = r;
+            this.properties = p;
+            this.key = (Long) this.properties.get(Constants.SERVICE_ID);
+        }
+
+        @Override
+        public int hashCode() {
+            return this.repository.hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if ( this == obj ) {
+                return true;
+            }
+            if ( ! (obj instanceof Registration ) ) {
+                return false;
+            }
+            return this.key == ((Registration)obj).key;
+        }
+    }
+
+    private static final class RepositoryRegistration {
+        public ServiceRegistration registration;
+        public SlingRepositoryWrapper wrapper;
+    }
+}

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryProvider.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryWrapper.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryWrapper.java?rev=1143678&view=auto
==============================================================================
--- 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryWrapper.java
 (added)
+++ 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryWrapper.java
 Thu Jul  7 06:55:42 2011
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.base.internal;
+
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Value;
+
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.base.AbstractNamespaceMappingRepository;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ */
+public class SlingRepositoryWrapper
+    extends AbstractNamespaceMappingRepository
+    implements SlingRepository {
+
+    private final Repository delegatee;
+
+    public SlingRepositoryWrapper(final Repository delegatee, final 
BundleContext bundleContext) {
+        this.delegatee = delegatee;
+        this.setup(bundleContext);
+    }
+
+    public void dispose() {
+        this.tearDown();
+    }
+
+    /**
+     * Return <code>null</code> to indicate the default workspace
+     * of the repository is used.
+     * @see org.apache.sling.jcr.api.SlingRepository#getDefaultWorkspace()
+     */
+    public String getDefaultWorkspace() {
+        return null;
+    }
+
+    /**
+     * @see 
org.apache.sling.jcr.api.SlingRepository#loginAdministrative(java.lang.String)
+     */
+    public Session loginAdministrative(String workspace)
+    throws RepositoryException {
+        return this.login(new SimpleCredentials("admin", 
"admin".toCharArray()), workspace);
+    }
+
+    /**
+     * @see javax.jcr.Repository#getDescriptorKeys()
+     */
+    public String[] getDescriptorKeys() {
+        return delegatee.getDescriptorKeys();
+    }
+
+    /**
+     * @see javax.jcr.Repository#isStandardDescriptor(java.lang.String)
+     */
+    public boolean isStandardDescriptor(String key) {
+        return delegatee.isStandardDescriptor(key);
+    }
+
+    /**
+     * @see javax.jcr.Repository#isSingleValueDescriptor(java.lang.String)
+     */
+    public boolean isSingleValueDescriptor(String key) {
+        return delegatee.isSingleValueDescriptor(key);
+    }
+
+    /**
+     * @see javax.jcr.Repository#getDescriptorValue(java.lang.String)
+     */
+    public Value getDescriptorValue(String key) {
+        return delegatee.getDescriptorValue(key);
+    }
+
+    /**
+     * @see javax.jcr.Repository#getDescriptorValues(java.lang.String)
+     */
+    public Value[] getDescriptorValues(String key) {
+        return delegatee.getDescriptorValues(key);
+    }
+
+    /**
+     * @see javax.jcr.Repository#getDescriptor(java.lang.String)
+     */
+    public String getDescriptor(String key) {
+        return delegatee.getDescriptor(key);
+    }
+
+    /**
+     * @see javax.jcr.Repository#login(javax.jcr.Credentials, java.lang.String)
+     */
+    public Session login(Credentials credentials, String workspaceName)
+            throws LoginException, NoSuchWorkspaceException,
+            RepositoryException {
+        return this.getNamespaceAwareSession(delegatee.login(credentials, 
workspaceName));
+    }
+
+    /**
+     * @see javax.jcr.Repository#login(javax.jcr.Credentials)
+     */
+    public Session login(Credentials credentials) throws LoginException,
+            RepositoryException {
+        return this.getNamespaceAwareSession(delegatee.login(credentials));
+    }
+
+    /**
+     * @see javax.jcr.Repository#login(java.lang.String)
+     */
+    public Session login(String workspaceName) throws LoginException,
+            NoSuchWorkspaceException, RepositoryException {
+        return this.getNamespaceAwareSession(delegatee.login(workspaceName));
+    }
+
+    /**
+     * @see javax.jcr.Repository#login()
+     */
+    public Session login() throws LoginException, RepositoryException {
+        return this.getNamespaceAwareSession(delegatee.login());
+    }
+}

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryWrapper.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SlingRepositoryWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/loader/Loader.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/loader/Loader.java?rev=1143678&r1=1143677&r2=1143678&view=diff
==============================================================================
--- 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/loader/Loader.java
 (original)
+++ 
sling/trunk/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/loader/Loader.java
 Thu Jul  7 06:55:42 2011
@@ -34,7 +34,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.sling.jcr.api.NamespaceMapper;
-import org.apache.sling.jcr.base.AbstractSlingRepository;
+import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.base.NodeTypeLoader;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -54,11 +54,11 @@ public class Loader implements Namespace
     public static final String NAMESPACES_BUNDLE_HEADER = "Sling-Namespaces";
 
     /** default log */
-    private static final Logger log = LoggerFactory.getLogger(Loader.class);
-    
+    private final Logger log = LoggerFactory.getLogger(Loader.class);
+
     private final BundleContext bundleContext;
 
-    private final AbstractSlingRepository slingRepository;
+    private final SlingRepository slingRepository;
 
     // bundles whose registration failed and should be retried
     private final List<Bundle> delayedBundles;
@@ -66,7 +66,7 @@ public class Loader implements Namespace
     /** Namespace prefix table. */
     private final Map<Long, NamespaceEntry[]> namespaceTable = new 
HashMap<Long, NamespaceEntry[]>();
 
-    public Loader(AbstractSlingRepository repository, BundleContext 
bundleContext) {
+    public Loader(final SlingRepository repository, final BundleContext 
bundleContext) {
         this.bundleContext = bundleContext;
         this.slingRepository = repository;
         this.delayedBundles = new ArrayList<Bundle>();
@@ -341,7 +341,7 @@ public class Loader implements Namespace
             session.logout();
         }
     }
-    
+
     private static class NamespaceEntry {
 
         public final String prefix;


Reply via email to