jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1456029 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ./ lock/ query/ query/qom/ version/ xml/
Date Wed, 13 Mar 2013 16:26:35 GMT
Author: mduerig
Date: Wed Mar 13 16:26:34 2013
New Revision: 1456029

URL: http://svn.apache.org/r1456029
Log:
OAK-672: Avoid JCR APIs calling other JCR APIs
- Remove SessionContextProvider and pass SessionContext instances to JCR implementation classes

Removed:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContextProvider.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelFactoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java Wed Mar 13 16:26:34 2013
@@ -48,6 +48,7 @@ abstract class ItemImpl<T extends ItemDe
     protected static final boolean DISABLE_TRANSIENT_DEFINITION_CHECKS =
             Boolean.getBoolean("OAK-652");
 
+    protected final SessionContext sessionContext;
     protected final SessionDelegate sessionDelegate;
     protected final T dlg;
 
@@ -56,7 +57,8 @@ abstract class ItemImpl<T extends ItemDe
      */
     private static final Logger log = LoggerFactory.getLogger(ItemImpl.class);
 
-    protected ItemImpl(T itemDelegate) {
+    protected ItemImpl(T itemDelegate, SessionContext sessionContext) {
+        this.sessionContext = sessionContext;
         this.sessionDelegate = itemDelegate.getSessionDelegate();
         this.dlg = itemDelegate;
     }
@@ -106,7 +108,7 @@ abstract class ItemImpl<T extends ItemDe
     @Override
     @Nonnull
     public Session getSession() throws RepositoryException {
-        return SessionContextProvider.getSession(sessionDelegate);
+        return sessionContext.getSession();
     }
 
     /**
@@ -236,22 +238,22 @@ abstract class ItemImpl<T extends ItemDe
      */
     @Nonnull
     ValueFactoryImpl getValueFactory() {
-        return SessionContextProvider.getValueFactory(sessionDelegate);
+        return sessionContext.getValueFactory();
     }
 
     @Nonnull
     NodeTypeManager getNodeTypeManager() {
-        return SessionContextProvider.getNodeTypeManager(sessionDelegate);
+        return sessionContext.getNodeTypeManager();
     }
 
     @Nonnull
     DefinitionProvider getDefinitionProvider() {
-        return SessionContextProvider.getDefinitionProvider(sessionDelegate);
+        return sessionContext.getDefinitionProvider();
     }
 
     @Nonnull
     String toJcrPath(String oakPath) {
-        NamePathMapper namePathMapper = SessionContextProvider.getNamePathMapper(sessionDelegate);
+        NamePathMapper namePathMapper = sessionContext.getNamePathMapper();
         return namePathMapper.getJcrPath(oakPath);
     }
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java Wed Mar 13 16:26:34 2013
@@ -105,8 +105,8 @@ public class NodeImpl<T extends NodeDele
      */
     private static final Logger log = LoggerFactory.getLogger(NodeImpl.class);
 
-    public NodeImpl(T dlg) {
-        super(dlg);
+    public NodeImpl(T dlg, SessionContext sessionContext) {
+        super(dlg, sessionContext);
     }
 
     //---------------------------------------------------------------< Item >---
@@ -140,7 +140,7 @@ public class NodeImpl<T extends NodeDele
                     if (parent == null) {
                         throw new AccessDeniedException();
                     }
-                    return new NodeImpl<NodeDelegate>(parent);
+                    return new NodeImpl<NodeDelegate>(parent, sessionContext);
                 }
             }
         });
@@ -226,7 +226,7 @@ public class NodeImpl<T extends NodeDele
     }
 
     private String getOakPath(String jcrPath) throws RepositoryException {
-        return SessionContextProvider.getOakPath(sessionDelegate, jcrPath);
+        return sessionContext.getOakPath(jcrPath);
     }
 
     @Override
@@ -238,7 +238,7 @@ public class NodeImpl<T extends NodeDele
         return perform(new SessionOperation<Node>() {
             @Override
             public Node perform() throws RepositoryException {
-                String oakPath = SessionContextProvider.getOakPathKeepIndexOrThrowNotFound(sessionDelegate, relPath);
+                String oakPath = sessionContext.getOakPathKeepIndexOrThrowNotFound(relPath);
                 String oakName = PathUtils.getName(oakPath);
                 String parentPath = getOakPath(PathUtils.getParentPath(oakPath));
 
@@ -270,7 +270,7 @@ public class NodeImpl<T extends NodeDele
                 if (ntName == null) {
                     DefinitionProvider dp = getDefinitionProvider();
                     String childName = getOakName(PathUtils.getName(relPath));
-                    NodeDefinition def = dp.getDefinition(new NodeImpl<NodeDelegate>(parent), childName);
+                    NodeDefinition def = dp.getDefinition(new NodeImpl<NodeDelegate>(parent, sessionContext), childName);
                     ntName = def.getDefaultPrimaryTypeName();
                     if (ntName == null) {
                         throw new ConstraintViolationException(
@@ -294,7 +294,7 @@ public class NodeImpl<T extends NodeDele
                     dlg.setOrderableChildren(true);
                 }
 
-                NodeImpl<?> childNode = new NodeImpl<NodeDelegate>(added);
+                NodeImpl<?> childNode = new NodeImpl<NodeDelegate>(added, sessionContext);
                 childNode.internalSetPrimaryType(ntName);
                 childNode.autoCreateItems();
                 return childNode;
@@ -304,7 +304,7 @@ public class NodeImpl<T extends NodeDele
 
     @Nonnull
     private String getOakName(String name) throws RepositoryException {
-        return SessionContextProvider.getOakName(sessionDelegate, name);
+        return sessionContext.getOakName(name);
     }
 
     @Override
@@ -333,7 +333,7 @@ public class NodeImpl<T extends NodeDele
     }
 
     private String getOakPathOrThrowNotFound(String relPath) throws PathNotFoundException {
-        return SessionContextProvider.getOakPathOrThrowNotFound(sessionDelegate, relPath);
+        return sessionContext.getOakPathOrThrowNotFound(relPath);
     }
 
     /**
@@ -519,7 +519,7 @@ public class NodeImpl<T extends NodeDele
                 if (nd == null) {
                     throw new PathNotFoundException(relPath);
                 } else {
-                    return new NodeImpl<NodeDelegate>(nd);
+                    return new NodeImpl<NodeDelegate>(nd, sessionContext);
                 }
             }
         });
@@ -617,7 +617,7 @@ public class NodeImpl<T extends NodeDele
                 if (pd == null) {
                     throw new PathNotFoundException(relPath + " not found on " + getPath());
                 } else {
-                    return new PropertyImpl(pd);
+                    return new PropertyImpl(pd, sessionContext);
                 }
             }
         });
@@ -816,7 +816,7 @@ public class NodeImpl<T extends NodeDele
                             @Override
                             public Property apply(String oakPath) {
                                 PropertyDelegate pd = sessionDelegate.getProperty(oakPath);
-                                return pd == null ? null : new PropertyImpl(pd);
+                                return pd == null ? null : new PropertyImpl(pd, sessionContext);
                             }
                         }
                 );
@@ -945,7 +945,7 @@ public class NodeImpl<T extends NodeDele
 
     @Nonnull
     private EffectiveNodeTypeProvider getEffectiveNodeTypeProvider() {
-        return SessionContextProvider.getEffectiveNodeTypeProvider(sessionDelegate);
+        return sessionContext.getEffectiveNodeTypeProvider();
     }
 
     @Override
@@ -1086,7 +1086,7 @@ public class NodeImpl<T extends NodeDele
 
     @Nonnull
     private VersionManager getVersionManager() throws RepositoryException {
-        return SessionContextProvider.getVersionManager(sessionDelegate);
+        return sessionContext.getVersionManager();
     }
 
     /**
@@ -1393,24 +1393,24 @@ public class NodeImpl<T extends NodeDele
 
     //------------------------------------------------------------< private >---
 
-    private static Iterator<Node> nodeIterator(Iterator<NodeDelegate> childNodes) {
+    private Iterator<Node> nodeIterator(Iterator<NodeDelegate> childNodes) {
         return Iterators.transform(
                 childNodes,
                 new Function<NodeDelegate, Node>() {
                     @Override
                     public Node apply(NodeDelegate nodeDelegate) {
-                        return new NodeImpl<NodeDelegate>(nodeDelegate);
+                        return new NodeImpl<NodeDelegate>(nodeDelegate, sessionContext);
                     }
                 });
     }
 
-    private static Iterator<Property> propertyIterator(Iterator<PropertyDelegate> properties) {
+    private Iterator<Property> propertyIterator(Iterator<PropertyDelegate> properties) {
         return Iterators.transform(
                 properties,
                 new Function<PropertyDelegate, Property>() {
                     @Override
                     public Property apply(PropertyDelegate propertyDelegate) {
-                        return new PropertyImpl(propertyDelegate);
+                        return new PropertyImpl(propertyDelegate, sessionContext);
                     }
                 });
     }
@@ -1521,7 +1521,7 @@ public class NodeImpl<T extends NodeDele
     }
 
     private void checkValidWorkspace(String workspaceName) throws RepositoryException {
-        Workspace workspace = SessionContextProvider.getWorkspace(sessionDelegate);
+        Workspace workspace = sessionContext.getWorkspace();
         for (String wn : workspace.getAccessibleWorkspaceNames()) {
             if (wn.equals(workspaceName)) {
                 return;
@@ -1571,7 +1571,7 @@ public class NodeImpl<T extends NodeDele
                     } else {
                         // Return a property instance which throws on access. See OAK-395
                         return new PropertyImpl(new PropertyDelegate(
-                                sessionDelegate, dlg.getLocation().getChild(oakName)));
+                                sessionDelegate, dlg.getLocation().getChild(oakName)), sessionContext);
                     }
                 } else {
                     Value targetValue;
@@ -1593,7 +1593,7 @@ public class NodeImpl<T extends NodeDele
                         targetValue = ValueHelper.convert(value, targetType, getValueFactory());
                     }
 
-                    return new PropertyImpl(dlg.setProperty(PropertyStates.createProperty(oakName, targetValue)));
+                    return new PropertyImpl(dlg.setProperty(PropertyStates.createProperty(oakName, targetValue)), sessionContext);
                 }
             }
         });
@@ -1618,7 +1618,7 @@ public class NodeImpl<T extends NodeDele
                         return property;
                     } else {
                         return new PropertyImpl(new PropertyDelegate(
-                                sessionDelegate, dlg.getLocation().getChild(oakName)));
+                                sessionDelegate, dlg.getLocation().getChild(oakName)), sessionContext);
                     }
                 } else {
                     Value[] targetValues;
@@ -1643,7 +1643,7 @@ public class NodeImpl<T extends NodeDele
                     Iterable<Value> nonNullValues = Iterables.filter(
                             Arrays.asList(targetValues),
                             Predicates.notNull());
-                    return new PropertyImpl(dlg.setProperty(PropertyStates.createProperty(oakName, nonNullValues)));
+                    return new PropertyImpl(dlg.setProperty(PropertyStates.createProperty(oakName, nonNullValues)), sessionContext);
                 }
             }
         });

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java Wed Mar 13 16:26:34 2013
@@ -62,8 +62,8 @@ public class PropertyImpl extends ItemIm
 
     private static final Value[] NO_VALUES = new Value[0];
 
-    PropertyImpl(PropertyDelegate dlg) {
-        super(dlg);
+    PropertyImpl(PropertyDelegate dlg, SessionContext sessionContext) {
+        super(dlg, sessionContext);
     }
 
     //---------------------------------------------------------------< Item >---
@@ -89,7 +89,7 @@ public class PropertyImpl extends ItemIm
                 if (parent == null) {
                     throw new AccessDeniedException();
                 } else {
-                    return new NodeImpl<NodeDelegate>(dlg.getParent());
+                    return new NodeImpl<NodeDelegate>(dlg.getParent(), sessionContext);
                 }
             }
         });

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java Wed Mar 13 16:26:34 2013
@@ -125,18 +125,21 @@ public class RepositoryImpl implements R
         final boolean autoRefresh = false; // TODO implement auto refresh configuration
         try {
             ContentSession contentSession = contentRepository.login(credentials, workspaceName);
+
+            final SessionContext[] context = new SessionContext[1];
             SessionDelegate sessionDelegate = new SessionDelegate(contentSession) {
                 @Override
                 protected void refresh() {
                     // Refresh is always needed if this is an auto refresh session or there
                     // are pending observation events
-                    if (autoRefresh || SessionContextProvider.hasPendingEvents(this)) {
+                    if (autoRefresh || context[0].hasPendingEvents()) {
                         refresh(true);
                     }
                 }
-
             };
-            return SessionContextProvider.newSession(sessionDelegate, this);
+
+            context[0] = SessionContext.create(sessionDelegate, this);
+            return context[0].getSession();
         } catch (LoginException e) {
             throw new javax.jcr.LoginException(e.getMessage(), e);
         }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java Wed Mar 13 16:26:34 2013
@@ -34,7 +34,7 @@ import static com.google.common.base.Pre
 
 public abstract class SessionContext {
     private final RepositoryImpl repository;
-    private final WorkspaceImpl workspace;
+    private final SessionDelegate delegate;
     private final NamePathMapperImpl namePathMapper;
     private final ValueFactoryImpl valueFactory;
 
@@ -46,10 +46,10 @@ public abstract class SessionContext {
     private AccessControlConfiguration accessControlConfiguration;
     private ObservationManagerImpl observationManager;
 
-    private SessionContext(RepositoryImpl repository, WorkspaceImpl workspace,
+    private SessionContext(RepositoryImpl repository, SessionDelegate delegate,
             NamePathMapperImpl namePathMapper, ValueFactoryImpl valueFactory) {
+        this.delegate = delegate;
         this.repository = repository;
-        this.workspace = workspace;
         this.namePathMapper = namePathMapper;
         this.valueFactory = valueFactory;
     }
@@ -65,16 +65,22 @@ public abstract class SessionContext {
             }
         };
 
-        WorkspaceImpl workspace = new WorkspaceImpl(delegate);
         NamePathMapperImpl namePathMapper = new NamePathMapperImpl(nameMapper, delegate.getIdManager());
         ValueFactoryImpl valueFactory = new ValueFactoryImpl(root.getBlobFactory(), namePathMapper);
 
-        return new SessionContext(checkNotNull(repository), workspace, namePathMapper, valueFactory){
-            SessionImpl session = new SessionImpl(delegate, this, namespaces);
+        return new SessionContext(checkNotNull(repository), delegate, namePathMapper, valueFactory){
+            private final SessionImpl session = new SessionImpl(delegate, this, namespaces);
+            private final WorkspaceImpl workspace = new WorkspaceImpl(delegate, this);
+
             @Override
             public SessionImpl getSession() {
                 return session;
             }
+
+            @Override
+            public WorkspaceImpl getWorkspace() {
+                return workspace;
+            }
         };
     }
 
@@ -82,30 +88,32 @@ public abstract class SessionContext {
         return repository;
     }
 
+    public SessionDelegate getSessionDelegate() {
+        return delegate;
+    }
+
     public abstract SessionImpl getSession();
 
-    public WorkspaceImpl getWorkspace() {
-        return workspace;
-    }
+    public abstract WorkspaceImpl getWorkspace();
 
     public LockManager getLockManager() {
-        return workspace.getLockManager();
+        return getWorkspace().getLockManager();
     }
 
     public NodeTypeManager getNodeTypeManager() {
-        return workspace.getNodeTypeManager();
+        return getWorkspace().getNodeTypeManager();
     }
 
     public VersionManager getVersionManager() throws RepositoryException {
-        return workspace.getVersionManager();
+        return getWorkspace().getVersionManager();
     }
 
     public EffectiveNodeTypeProvider getEffectiveNodeTypeProvider() {
-        return workspace.getReadWriteNodeTypeManager();
+        return getWorkspace().getReadWriteNodeTypeManager();
     }
 
     public DefinitionProvider getDefinitionProvider() {
-        return workspace.getReadWriteNodeTypeManager();
+        return getWorkspace().getReadWriteNodeTypeManager();
     }
 
     public NamePathMapperImpl getNamePathMapper() {
@@ -184,7 +192,7 @@ public abstract class SessionContext {
      * @return Oak path, or {@code null}, with indexes left intact
      * @throws javax.jcr.PathNotFoundException
      */
-    @Nonnull
+    @CheckForNull
     public String getOakPathKeepIndex(String jcrPath) throws PathNotFoundException {
         return namePathMapper.getOakPathKeepIndex(jcrPath);
     }
@@ -217,7 +225,7 @@ public abstract class SessionContext {
     }
 
     @Nonnull
-    public PermissionProvider getPermissionProvider(SessionDelegate delegate) {
+    public PermissionProvider getPermissionProvider() {
         SecurityProvider securityProvider = repository.getSecurityProvider();
 
         // TODO
@@ -226,7 +234,7 @@ public abstract class SessionContext {
     }
 
     @Nonnull
-    public PrincipalManager getPrincipalManager(SessionDelegate delegate) {
+    public PrincipalManager getPrincipalManager() {
         if (principalManager == null) {
             SecurityProvider securityProvider = repository.getSecurityProvider();
             principalManager = securityProvider.getPrincipalConfiguration()
@@ -236,7 +244,7 @@ public abstract class SessionContext {
     }
 
     @Nonnull
-    public UserManager getUserManager(SessionDelegate delegate) {
+    public UserManager getUserManager() {
         if (userManager == null) {
             SecurityProvider securityProvider = repository.getSecurityProvider();
             userManager = securityProvider.getUserConfiguration().getUserManager(delegate.getRoot(), namePathMapper);
@@ -245,7 +253,7 @@ public abstract class SessionContext {
     }
 
     @Nonnull
-    public PrivilegeManager getPrivilegeManager(SessionDelegate delegate) {
+    public PrivilegeManager getPrivilegeManager() {
         if (privilegeManager == null) {
             SecurityProvider securityProvider = repository.getSecurityProvider();
             privilegeManager = securityProvider.getPrivilegeConfiguration().getPrivilegeManager(delegate.getRoot(), namePathMapper);
@@ -272,7 +280,7 @@ public abstract class SessionContext {
     }
 
     @Nonnull
-    public ObservationManager getObservationManager(SessionDelegate delegate) {
+    public ObservationManager getObservationManager() {
         if (observationManager == null) {
             observationManager = new ObservationManagerImpl(
                     delegate.getRoot(), namePathMapper, repository.getObservationExecutor());

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java Wed Mar 13 16:26:34 2013
@@ -53,7 +53,6 @@ import org.apache.jackrabbit.oak.jcr.del
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionOperation;
 import org.apache.jackrabbit.oak.jcr.xml.ImportHandler;
-import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
 import org.apache.jackrabbit.oak.spi.security.authorization.PermissionProvider;
@@ -77,6 +76,8 @@ public class SessionImpl extends Abstrac
 
     private final SessionDelegate dlg;
 
+    private SessionContext sessionContext;
+
     /**
      * Local namespace remappings. Prefixes as keys and namespace URIs as values.
      * <p/>
@@ -87,6 +88,7 @@ public class SessionImpl extends Abstrac
 
     SessionImpl(SessionDelegate dlg, SessionContext sessionContext, Map<String, String> namespaces) {
         this.dlg = dlg;
+        this.sessionContext = sessionContext;
         this.namespaces = namespaces;
     }
 
@@ -102,7 +104,7 @@ public class SessionImpl extends Abstrac
     @Override
     @Nonnull
     public Repository getRepository() {
-        return SessionContextProvider.getRepository(dlg);
+        return sessionContext.getRepository();
     }
 
     @Override
@@ -123,7 +125,7 @@ public class SessionImpl extends Abstrac
     @Override
     @Nonnull
     public Workspace getWorkspace() {
-        return SessionContextProvider.getWorkspace(dlg);
+        return sessionContext.getWorkspace();
     }
 
     @Override
@@ -139,7 +141,7 @@ public class SessionImpl extends Abstrac
     @Nonnull
     public ValueFactory getValueFactory() throws RepositoryException {
         ensureIsAlive();
-        return SessionContextProvider.getValueFactory(dlg);
+        return sessionContext.getValueFactory();
     }
 
     @Override
@@ -157,7 +159,7 @@ public class SessionImpl extends Abstrac
                 if (nd == null) {
                     throw new AccessDeniedException("Root node is not accessible.");
                 } else {
-                    return new NodeImpl<NodeDelegate>(nd);
+                    return new NodeImpl<NodeDelegate>(nd, sessionContext);
                 }
             }
         });
@@ -184,7 +186,7 @@ public class SessionImpl extends Abstrac
                 if (d == null) {
                     throw new ItemNotFoundException("Node with id " + id + " does not exist.");
                 }
-                return new NodeImpl<NodeDelegate>(d);
+                return new NodeImpl<NodeDelegate>(d, sessionContext);
             }
         });
     }
@@ -204,7 +206,7 @@ public class SessionImpl extends Abstrac
     }
 
     private String getOakPath(String absPath) throws RepositoryException {
-        return SessionContextProvider.getOakPath(dlg, absPath);
+        return sessionContext.getOakPath(absPath);
     }
 
     @Override
@@ -222,7 +224,7 @@ public class SessionImpl extends Abstrac
                 if (d == null) {
                     throw new PathNotFoundException("Node with path " + absPath + " does not exist.");
                 }
-                return new NodeImpl<NodeDelegate>(d);
+                return new NodeImpl<NodeDelegate>(d, sessionContext);
             }
         });
     }
@@ -256,7 +258,7 @@ public class SessionImpl extends Abstrac
                     if (loc.getProperty() == null) {
                         throw new PathNotFoundException(absPath);
                     } else {
-                        return new PropertyImpl(new PropertyDelegate(dlg, loc));
+                        return new PropertyImpl(new PropertyDelegate(dlg, loc), sessionContext);
                     }
                 }
             });
@@ -264,7 +266,7 @@ public class SessionImpl extends Abstrac
     }
 
     private String getOakPathOrThrowNotFound(String absPath) throws PathNotFoundException {
-        return SessionContextProvider.getOakPathOrThrowNotFound(dlg, absPath);
+        return sessionContext.getOakPathOrThrowNotFound(absPath);
     }
 
     @Override
@@ -294,7 +296,7 @@ public class SessionImpl extends Abstrac
 
             @Override
             public Void perform() throws RepositoryException {
-                String oakPath = SessionContextProvider.getOakPathKeepIndexOrThrowNotFound(dlg, destAbsPath);
+                String oakPath = sessionContext.getOakPathKeepIndexOrThrowNotFound(destAbsPath);
                 String oakName = PathUtils.getName(oakPath);
                 // handle index
                 if (oakName.contains("[")) {
@@ -337,7 +339,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public void logout() {
-        SessionContextProvider.remove(dlg);
+        sessionContext.dispose();
         dlg.logout();
         synchronized (namespaces) {
             namespaces.clear();
@@ -348,15 +350,15 @@ public class SessionImpl extends Abstrac
     @Nonnull
     public ContentHandler getImportContentHandler(
             String parentAbsPath, int uuidBehavior) throws RepositoryException {
-        UserConfiguration userConfiguration = SessionContextProvider.getUserConfiguration(dlg);
-        AccessControlConfiguration accessControlConfiguration = SessionContextProvider.getAccessControlConfiguration(dlg);
+        UserConfiguration userConfiguration = sessionContext.getUserConfiguration();
+        AccessControlConfiguration accessControlConfiguration = sessionContext.getAccessControlConfiguration();
         return new ImportHandler(getNode(parentAbsPath), dlg.getRoot(), this,
-                dlg, userConfiguration, accessControlConfiguration, uuidBehavior);
+                dlg, userConfiguration, accessControlConfiguration, uuidBehavior, sessionContext);
     }
 
     @Nonnull
     private LockManager getLockManager() {
-        return SessionContextProvider.getLockManager(dlg);
+        return sessionContext.getLockManager();
     }
 
     /**
@@ -401,13 +403,12 @@ public class SessionImpl extends Abstrac
     public boolean hasPermission(String absPath, String actions) throws RepositoryException {
         ensureIsAlive();
 
-        NamePathMapper namePathMapper = SessionContextProvider.getNamePathMapper(dlg);
-        String oakPath = namePathMapper.getOakPathKeepIndex(absPath);
+        String oakPath = sessionContext.getOakPathKeepIndex(absPath);
         if (oakPath == null) {
             throw new RepositoryException("Invalid JCR path: " + absPath);
         }
 
-        PermissionProvider permissionProvider = SessionContextProvider.getPermissionProvider(dlg);
+        PermissionProvider permissionProvider = sessionContext.getPermissionProvider();
         return permissionProvider.hasPermission(absPath, actions);
     }
 
@@ -429,7 +430,7 @@ public class SessionImpl extends Abstrac
     @Override
     @Nonnull
     public AccessControlManager getAccessControlManager() throws RepositoryException {
-        return SessionContextProvider.getAccessControlManager(dlg);
+        return sessionContext.getAccessControlManager(dlg);
     }
 
     /**
@@ -547,13 +548,13 @@ public class SessionImpl extends Abstrac
     @Override
     @Nonnull
     public PrincipalManager getPrincipalManager() throws RepositoryException {
-        return SessionContextProvider.getPrincipalManager(dlg);
+        return sessionContext.getPrincipalManager();
     }
 
     @Override
     @Nonnull
     public UserManager getUserManager() throws RepositoryException {
-        return SessionContextProvider.getUserManager(dlg);
+        return sessionContext.getUserManager();
     }
 
     //------------------------------------------------------------< private >---

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java Wed Mar 13 16:26:34 2013
@@ -56,16 +56,18 @@ import static org.apache.jackrabbit.oak.
 public class WorkspaceImpl implements JackrabbitWorkspace {
 
     private final SessionDelegate sessionDelegate;
+    private final SessionContext sessionContext;
     private final QueryManagerImpl queryManager;
     private final LockManager lockManager;
     private final VersionManagerImpl versionManager;
     private final ReadWriteNodeTypeManager nodeTypeManager;
 
-    public WorkspaceImpl(final SessionDelegate sessionDelegate) {
+    public WorkspaceImpl(final SessionDelegate sessionDelegate, final SessionContext sessionContext) {
         this.sessionDelegate = sessionDelegate;
-        this.queryManager = new QueryManagerImpl(sessionDelegate);
-        this.lockManager = new LockManagerImpl(sessionDelegate);
-        this.versionManager = new VersionManagerImpl(sessionDelegate);
+        this.sessionContext = sessionContext;
+        this.queryManager = new QueryManagerImpl(sessionDelegate, sessionContext);
+        this.lockManager = new LockManagerImpl(sessionDelegate, sessionContext);
+        this.versionManager = new VersionManagerImpl(sessionDelegate, sessionContext);
         this.nodeTypeManager = new ReadWriteNodeTypeManager() {
             @Override
             protected void refresh() throws RepositoryException {
@@ -86,13 +88,13 @@ public class WorkspaceImpl implements Ja
             @Override
             @Nonnull
             protected ValueFactory getValueFactory() {
-                return SessionContextProvider.getValueFactory(sessionDelegate);
+                return sessionContext.getValueFactory();
             }
 
             @Nonnull
             @Override
             protected NamePathMapper getNamePathMapper() {
-                return SessionContextProvider.getNamePathMapper(sessionDelegate);
+                return sessionContext.getNamePathMapper();
             }
         };
     }
@@ -101,7 +103,7 @@ public class WorkspaceImpl implements Ja
     @Override
     @Nonnull
     public SessionImpl getSession() {
-        return SessionContextProvider.getSession(sessionDelegate);
+        return sessionContext.getSession();
     }
 
     @Override
@@ -115,7 +117,7 @@ public class WorkspaceImpl implements Ja
     }
 
     private String getOakPathKeepIndexOrThrowNotFound(String absPath) throws PathNotFoundException {
-        return SessionContextProvider.getOakPathKeepIndexOrThrowNotFound(sessionDelegate, absPath);
+        return sessionContext.getOakPathKeepIndexOrThrowNotFound(absPath);
     }
 
     @Override
@@ -141,7 +143,7 @@ public class WorkspaceImpl implements Ja
     }
 
     private String getOakPathOrThrowNotFound(String srcAbsPath) throws PathNotFoundException {
-        return SessionContextProvider.getOakPathOrThrowNotFound(sessionDelegate, srcAbsPath);
+        return sessionContext.getOakPathOrThrowNotFound(srcAbsPath);
     }
 
     @Override
@@ -218,7 +220,7 @@ public class WorkspaceImpl implements Ja
     public ObservationManager getObservationManager() throws RepositoryException {
         ensureIsAlive();
 
-        return SessionContextProvider.getObservationManager(sessionDelegate);
+        return sessionContext.getObservationManager();
     }
 
     @Override
@@ -290,7 +292,7 @@ public class WorkspaceImpl implements Ja
      */
     @Override
     public PrivilegeManager getPrivilegeManager() throws RepositoryException {
-        return SessionContextProvider.getPrivilegeManager(sessionDelegate);
+        return sessionContext.getPrivilegeManager();
     }
 
     //------------------------------------------------------------< internal >---

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java Wed Mar 13 16:26:34 2013
@@ -28,7 +28,7 @@ import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import javax.jcr.lock.LockManager;
 
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 
 /**
@@ -39,11 +39,12 @@ import org.apache.jackrabbit.oak.jcr.del
 public class LockManagerImpl implements LockManager {
 
     private final SessionDelegate sessionDelegate;
-
+    private final SessionContext sessionContext;
     private final Set<String> tokens = new HashSet<String>();
 
-    public LockManagerImpl(SessionDelegate sessionDelegate) {
+    public LockManagerImpl(SessionDelegate sessionDelegate, SessionContext sessionContext) {
         this.sessionDelegate = sessionDelegate;
+        this.sessionContext = sessionContext;
     }
 
     @Override
@@ -99,6 +100,6 @@ public class LockManagerImpl implements 
 
     @Nonnull
     private Session getSession() {
-        return SessionContextProvider.getSession(sessionDelegate);
+        return sessionContext.getSession();
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java Wed Mar 13 16:26:34 2013
@@ -20,6 +20,7 @@ package org.apache.jackrabbit.oak.jcr.qu
 
 import java.util.HashMap;
 import java.util.List;
+
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
@@ -33,9 +34,9 @@ import javax.jcr.version.VersionExceptio
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
-import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
+import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 
 /**
@@ -43,6 +44,7 @@ import org.apache.jackrabbit.oak.jcr.del
  */
 public class QueryImpl implements Query {
 
+    private final SessionContext sessionContext;
     private final QueryManagerImpl manager;
     private final HashMap<String, Value> bindVariableMap = new HashMap<String, Value>();
     private final String language;
@@ -52,7 +54,8 @@ public class QueryImpl implements Query 
     private boolean parsed;
     private String storedQueryPath;
 
-    QueryImpl(QueryManagerImpl manager, String statement, String language) {
+    QueryImpl(QueryManagerImpl manager, String statement, String language, SessionContext sessionContext) {
+        this.sessionContext = sessionContext;
         this.manager = manager;
         this.statement = statement;
         this.language = language;
@@ -133,19 +136,19 @@ public class QueryImpl implements Query 
     public Node storeAsNode(String absPath) throws RepositoryException {
         manager.ensureIsAlive();
         SessionDelegate sessionDelegate = manager.getSessionDelegate();
-        String oakPath = SessionContextProvider.getOakPath(sessionDelegate, absPath);
+        String oakPath = sessionContext.getOakPath(absPath);
         String parent = PathUtils.getParentPath(oakPath);
         NodeDelegate parentDelegate = sessionDelegate.getNode(parent);
         if (parentDelegate == null) {
             throw new PathNotFoundException("The specified path does not exist: " + parent);
         }
-        Node parentNode = new NodeImpl<NodeDelegate>(parentDelegate);
+        Node parentNode = new NodeImpl<NodeDelegate>(parentDelegate, sessionContext);
         if (!parentNode.isCheckedOut()) {
             throw new VersionException("Cannot store query. Node at " +
                     absPath + " is checked in.");
         }
         String nodeName = PathUtils.getName(oakPath);
-        ValueFactory vf = SessionContextProvider.getValueFactory(sessionDelegate);
+        ValueFactory vf = sessionContext.getValueFactory();
         Node n = parentNode.addNode(nodeName, JcrConstants.NT_QUERY);
         n.setProperty(JcrConstants.JCR_STATEMENT, vf.createValue(statement));
         n.setProperty(JcrConstants.JCR_LANGUAGE, vf.createValue(language));

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java Wed Mar 13 16:26:34 2013
@@ -37,9 +37,9 @@ import javax.jcr.query.qom.QueryObjectMo
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyValue;
-import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.QueryEngine;
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
+import org.apache.jackrabbit.oak.api.Result;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.jcr.query.qom.QueryObjectModelFactoryImpl;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
@@ -51,14 +51,16 @@ import org.apache.jackrabbit.oak.spi.que
  */
 public class QueryManagerImpl implements QueryManager {
 
+    private final SessionDelegate sessionDelegate;
+    private final SessionContext sessionContext;
     private final QueryObjectModelFactoryImpl qomFactory;
     private final QueryEngine queryEngine;
-    private final SessionDelegate sessionDelegate;
     private final HashSet<String> supportedQueryLanguages = new HashSet<String>();
 
-    public QueryManagerImpl(SessionDelegate sessionDelegate) {
+    public QueryManagerImpl(SessionDelegate sessionDelegate, SessionContext sessionContext) {
         this.sessionDelegate = sessionDelegate;
-        qomFactory = new QueryObjectModelFactoryImpl(this, sessionDelegate);
+        this.sessionContext = sessionContext;
+        qomFactory = new QueryObjectModelFactoryImpl(this, sessionDelegate, sessionContext);
         queryEngine = sessionDelegate.getQueryEngine();
         supportedQueryLanguages.addAll(queryEngine.getSupportedQueryLanguages());
     }
@@ -68,7 +70,7 @@ public class QueryManagerImpl implements
         if (!supportedQueryLanguages.contains(language)) {
             throw new InvalidQueryException("The specified language is not supported: " + language);
         }
-        return new QueryImpl(this, statement, language);
+        return new QueryImpl(this, statement, language, sessionContext);
     }
 
     @Override
@@ -117,10 +119,10 @@ public class QueryManagerImpl implements
             long limit, long offset, HashMap<String, Value> bindVariableMap) throws RepositoryException {
         try {
             Map<String, PropertyValue> bindMap = convertMap(bindVariableMap);
-            NamePathMapper namePathMapper = SessionContextProvider.getNamePathMapper(sessionDelegate);
+            NamePathMapper namePathMapper = sessionContext.getNamePathMapper();
             Result r = queryEngine.executeQuery(statement, language, limit, offset,
                     bindMap, namePathMapper);
-            return new QueryResultImpl(sessionDelegate, r);
+            return new QueryResultImpl(sessionDelegate, r, sessionContext);
         } catch (IllegalArgumentException e) {
             throw new InvalidQueryException(e);
         } catch (ParseException e) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java Wed Mar 13 16:26:34 2013
@@ -35,7 +35,7 @@ import org.apache.jackrabbit.oak.api.Res
 import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 
@@ -59,11 +59,13 @@ public class QueryResultImpl implements 
      */
     private static final int PREFETCH_TIMEOUT = 100;
 
+    private final SessionContext sessionContext;
     final SessionDelegate sessionDelegate;
     final Result result;
     final String pathFilter;
 
-    public QueryResultImpl(SessionDelegate sessionDelegate, Result result) {
+    public QueryResultImpl(SessionDelegate sessionDelegate, Result result, SessionContext sessionContext) {
+        this.sessionContext = sessionContext;
         this.sessionDelegate = sessionDelegate;
         this.result = result;
 
@@ -158,7 +160,7 @@ public class QueryResultImpl implements 
             return null;
         }
         NodeDelegate d = sessionDelegate.getNode(path);
-        return d == null ? null : new NodeImpl<NodeDelegate>(d);
+        return d == null ? null : new NodeImpl<NodeDelegate>(d, sessionContext);
     }
 
     String getLocalPath(String path) {
@@ -238,7 +240,7 @@ public class QueryResultImpl implements 
         if (value == null) {
             return null;
         } else {
-            return SessionContextProvider.getValueFactory(sessionDelegate).createValue(value);
+            return sessionContext.getValueFactory().createValue(value);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelFactoryImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelFactoryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/qom/QueryObjectModelFactoryImpl.java Wed Mar 13 16:26:34 2013
@@ -47,7 +47,7 @@ import javax.jcr.query.qom.Source;
 import javax.jcr.query.qom.StaticOperand;
 import javax.jcr.query.qom.UpperCase;
 
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.jcr.query.QueryManagerImpl;
 
@@ -58,10 +58,12 @@ public class QueryObjectModelFactoryImpl
 
     private final QueryManagerImpl queryManager;
     private final SessionDelegate sessionDelegate;
+    private final SessionContext sessionContext;
 
-    public QueryObjectModelFactoryImpl(QueryManagerImpl queryManager, SessionDelegate sessionDelegate) {
+    public QueryObjectModelFactoryImpl(QueryManagerImpl queryManager, SessionDelegate sessionDelegate, SessionContext sessionContext) {
         this.queryManager = queryManager;
         this.sessionDelegate = sessionDelegate;
+        this.sessionContext = sessionContext;
     }
 
     @Override
@@ -221,7 +223,7 @@ public class QueryObjectModelFactoryImpl
     public QueryObjectModel createQuery(Source source, Constraint constraint, 
             Ordering[] orderings, Column[] columns) {
         QueryObjectModelImpl qom = new QueryObjectModelImpl(queryManager,
-                SessionContextProvider.getValueFactory(sessionDelegate),
+                sessionContext.getValueFactory(),
                 source, constraint, orderings, columns);
         qom.bindVariables();
         return qom;
@@ -231,7 +233,7 @@ public class QueryObjectModelFactoryImpl
         if (jcrName == null) {
             return null;
         }
-        return SessionContextProvider.getOakName(queryManager.getSessionDelegate(), jcrName);
+        return sessionContext.getOakName(jcrName);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java Wed Mar 13 16:26:34 2013
@@ -31,26 +31,25 @@ import javax.jcr.version.VersionExceptio
 import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionIterator;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Iterators;
 import org.apache.jackrabbit.commons.iterator.FrozenNodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.VersionIteratorAdapter;
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.VersionDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.VersionHistoryDelegate;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.util.TODO;
 
-import com.google.common.base.Function;
-import com.google.common.collect.Iterators;
-
 /**
  * <code>VersionHistoryImpl</code>...
  */
 public class VersionHistoryImpl extends NodeImpl<VersionHistoryDelegate>
         implements VersionHistory {
 
-    public VersionHistoryImpl(VersionHistoryDelegate dlg) {
-        super(dlg);
+    public VersionHistoryImpl(VersionHistoryDelegate dlg, SessionContext sessionContext) {
+        super(dlg, sessionContext);
     }
 
     @Override
@@ -65,7 +64,7 @@ public class VersionHistoryImpl extends 
 
     @Override
     public Version getRootVersion() throws RepositoryException {
-        return new VersionImpl(dlg.getRootVersion());
+        return new VersionImpl(dlg.getRootVersion(), sessionContext);
     }
 
     @Override
@@ -79,7 +78,7 @@ public class VersionHistoryImpl extends 
                 dlg.getAllVersions(), new Function<VersionDelegate, Version>() {
             @Override
             public Version apply(VersionDelegate input) {
-                return new VersionImpl(input);
+                return new VersionImpl(input, sessionContext);
             }
         }));
     }
@@ -97,14 +96,14 @@ public class VersionHistoryImpl extends 
     @Override
     public Version getVersion(String versionName)
             throws VersionException, RepositoryException {
-        return new VersionImpl(dlg.getVersion(versionName));
+        return new VersionImpl(dlg.getVersion(versionName), sessionContext);
     }
 
     @Override
     public Version getVersionByLabel(String label)
             throws VersionException, RepositoryException {
-        String oakLabel = SessionContextProvider.getOakName(sessionDelegate, label);
-        return new VersionImpl(dlg.getVersionByLabel(oakLabel));
+        String oakLabel = sessionContext.getOakName(label);
+        return new VersionImpl(dlg.getVersionByLabel(oakLabel), sessionContext);
     }
 
     @Override
@@ -135,7 +134,7 @@ public class VersionHistoryImpl extends 
 
     @Override
     public String[] getVersionLabels() throws RepositoryException {
-        NamePathMapper mapper = SessionContextProvider.getNamePathMapper(sessionDelegate);
+        NamePathMapper mapper = sessionContext.getNamePathMapper();
         List<String> labels = new ArrayList<String>();
         for (String label : dlg.getVersionLabels()) {
             labels.add(mapper.getJcrName(label));
@@ -150,7 +149,7 @@ public class VersionHistoryImpl extends 
             throw new VersionException("Version is not contained in this " +
                     "VersionHistory");
         }
-        NamePathMapper mapper = SessionContextProvider.getNamePathMapper(sessionDelegate);
+        NamePathMapper mapper = sessionContext.getNamePathMapper();
         List<String> labels = new ArrayList<String>();
         for (String label : dlg.getVersionLabels(version.getIdentifier())) {
             labels.add(mapper.getJcrName(label));

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java Wed Mar 13 16:26:34 2013
@@ -31,7 +31,7 @@ import javax.jcr.version.VersionHistory;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.VersionDelegate;
@@ -44,18 +44,18 @@ import static com.google.common.base.Pre
 
 class VersionImpl extends NodeImpl<VersionDelegate> implements Version {
 
-    public VersionImpl(VersionDelegate dlg) {
-        super(dlg);
+    public VersionImpl(VersionDelegate dlg, SessionContext sessionContext) {
+        super(dlg, sessionContext);
     }
 
     @Override
     public VersionHistory getContainingHistory() throws RepositoryException {
         return new VersionHistoryImpl(
-                getVersionManagerDelegate().getVersionHistory(dlg.getParent()));
+                getVersionManagerDelegate().getVersionHistory(dlg.getParent()), sessionContext);
     }
 
     private ValueFactoryImpl getValueFactory() {
-        return SessionContextProvider.getValueFactory(sessionDelegate);
+        return sessionContext.getValueFactory();
     }
 
     @Override
@@ -85,7 +85,7 @@ class VersionImpl extends NodeImpl<Versi
         VersionManagerDelegate vMgr = getVersionManagerDelegate();
         for (Value v : getValues(p)) {
             String id = v.getString();
-            predecessors.add(new VersionImpl(vMgr.getVersionByIdentifier(id)));
+            predecessors.add(new VersionImpl(vMgr.getVersionByIdentifier(id), sessionContext));
         }
         return predecessors.toArray(new Version[predecessors.size()]);
     }
@@ -97,7 +97,7 @@ class VersionImpl extends NodeImpl<Versi
         VersionManagerDelegate vMgr = getVersionManagerDelegate();
         for (Value v : getValues(p)) {
             String id = v.getString();
-            successors.add(new VersionImpl(vMgr.getVersionByIdentifier(id)));
+            successors.add(new VersionImpl(vMgr.getVersionByIdentifier(id), sessionContext));
         }
         return successors.toArray(new Version[successors.size()]);
     }
@@ -105,7 +105,7 @@ class VersionImpl extends NodeImpl<Versi
     @Override
     public Node getFrozenNode() throws RepositoryException {
         return new NodeImpl<NodeDelegate>(
-                dlg.getChild(VersionConstants.JCR_FROZENNODE));
+                dlg.getChild(VersionConstants.JCR_FROZENNODE), sessionContext);
     }
 
     //------------------------------< internal >--------------------------------

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java Wed Mar 13 16:26:34 2013
@@ -32,7 +32,7 @@ import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionManager;
 
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionOperation;
@@ -41,9 +41,11 @@ import org.apache.jackrabbit.oak.util.TO
 
 public class VersionManagerImpl implements VersionManager {
 
+    private final SessionContext sessionContext;
     private final VersionManagerDelegate versionManagerDelegate;
 
-    public VersionManagerImpl(SessionDelegate sessionDelegate) {
+    public VersionManagerImpl(SessionDelegate sessionDelegate, SessionContext sessionContext) {
+        this.sessionContext = sessionContext;
         this.versionManagerDelegate = VersionManagerDelegate.create(sessionDelegate);
     }
 
@@ -129,9 +131,9 @@ public class VersionManagerImpl implemen
         });
     }
 
-    private static String getOakPathOrThrowNotFound(SessionDelegate sessionDelegate, String absPath)
+    private String getOakPathOrThrowNotFound(SessionDelegate sessionDelegate, String absPath)
             throws PathNotFoundException {
-        return SessionContextProvider.getOakPathOrThrowNotFound(sessionDelegate, absPath);
+        return sessionContext.getOakPathOrThrowNotFound(absPath);
     }
 
     @Override
@@ -147,7 +149,7 @@ public class VersionManagerImpl implemen
                     throw new PathNotFoundException(absPath);
                 }
                 return new VersionHistoryImpl(
-                        versionManagerDelegate.getVersionHistory(nodeDelegate));
+                        versionManagerDelegate.getVersionHistory(nodeDelegate), sessionContext);
             }
         });
     }
@@ -164,7 +166,7 @@ public class VersionManagerImpl implemen
                     throw new PathNotFoundException(absPath);
                 }
                 return new VersionImpl(
-                        versionManagerDelegate.getBaseVersion(nodeDelegate));
+                        versionManagerDelegate.getBaseVersion(nodeDelegate), sessionContext);
             }
         });
     }
@@ -196,8 +198,8 @@ public class VersionManagerImpl implemen
     }
 
     @Nonnull
-    private static LockManager getLockManager(SessionDelegate sessionDelegate) {
-        return SessionContextProvider.getLockManager(sessionDelegate);
+    private LockManager getLockManager(SessionDelegate sessionDelegate) {
+        return sessionContext.getLockManager();
     }
 
     @Override
@@ -240,7 +242,7 @@ public class VersionManagerImpl implemen
                 if (getLockManager(sessionDelegate).isLocked(absPath)) {
                     throw new LockException("Node at " + absPath + " is locked");
                 }
-                return new VersionImpl(versionManagerDelegate.checkin(nodeDelegate));
+                return new VersionImpl(versionManagerDelegate.checkin(nodeDelegate), sessionContext);
             }
         });
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java Wed Mar 13 16:26:34 2013
@@ -26,6 +26,7 @@ import javax.jcr.ValueFactory;
 
 import org.apache.jackrabbit.commons.NamespaceHelper;
 import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.plugins.name.NamespaceConstants;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
@@ -68,10 +69,11 @@ public class ImportHandler extends Defau
     public ImportHandler(Node importTargetNode, Root root, Session session,
                          SessionDelegate dlg, UserConfiguration userConfig,
                          AccessControlConfiguration accessControlConfig,
-                         int uuidBehavior)
+                         int uuidBehavior, SessionContext sessionContext)
             throws RepositoryException {
         this.helper = new NamespaceHelper(session);
-        this.importer = new SessionImporter(importTargetNode, root, session, dlg, helper, userConfig, accessControlConfig, uuidBehavior);
+        this.importer = new SessionImporter(importTargetNode, root, session, dlg, helper, userConfig,
+                accessControlConfig, uuidBehavior, sessionContext);
         this.valueFactory = session.getValueFactory();
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java?rev=1456029&r1=1456028&r2=1456029&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java Wed Mar 13 16:26:34 2013
@@ -40,7 +40,7 @@ import javax.jcr.nodetype.PropertyDefini
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.commons.NamespaceHelper;
 import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
+import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.nodetype.EffectiveNodeTypeProvider;
@@ -66,6 +66,7 @@ public class SessionImporter implements 
     private final Node importTargetNode;
     private final Root root;
     private final int uuidBehavior;
+    private final SessionContext sessionContext;
 
     private final NamespaceHelper namespaceHelper;
     private Stack<Node> parents;
@@ -94,12 +95,14 @@ public class SessionImporter implements 
                            NamespaceHelper helper,
                            UserConfiguration userConfig,
                            AccessControlConfiguration accessControlConfig,
-                           int uuidBehavior) throws RepositoryException {
+                           int uuidBehavior,
+                           SessionContext sessionContext) throws RepositoryException {
         this.importTargetNode = importTargetNode;
         this.session = session;
         this.root = root;
         this.namespaceHelper = helper;
         this.uuidBehavior = uuidBehavior;
+        this.sessionContext = sessionContext;
 
         refTracker = new ReferenceChangeTracker();
 
@@ -109,7 +112,7 @@ public class SessionImporter implements 
         pItemImporters.clear();
 
         //TODO clarify how to provide ProtectedItemImporters
-        NamePathMapper namePathMapper = SessionContextProvider.getNamePathMapper(dlg);
+        NamePathMapper namePathMapper = sessionContext.getNamePathMapper();
         for (ProtectedItemImporter importer : userConfig.getProtectedItemImporters()) {
             if (importer.init(session, root, namePathMapper, false, uuidBehavior, refTracker)) {
                 pItemImporters.add(importer);



Mime
View raw message