true, true);
context = context.with(rootKeyAwareStrongRefFactory).with(rootKeyAwareWeakRefFactory).with(rootKeyAwareSimpleRefFactory);
// Create an execution context for this session that uses a local namespace registry ...
final NamespaceRegistry globalNamespaceRegistry = context.getNamespaceRegistry(); // thread-safe!
final LocalNamespaceRegistry localRegistry = new LocalNamespaceRegistry(globalNamespaceRegistry); // not-thread-safe!
this.context = context.with(localRegistry);
this.sessionRegistry = new JcrNamespaceRegistry(Behavior.SESSION, localRegistry, globalNamespaceRegistry, this);
this.workspace = new JcrWorkspace(this, workspaceName);
// Create the session cache ...
this.cache = repositoryCache.createSession(this.context, workspaceName, readOnly);
this.rootNode = new JcrRootNode(this, this.cache.getRootKey());
this.jcrNodes.put(this.rootNode.key(), this.rootNode);
this.sessionAttributes = sessionAttributes != null ? sessionAttributes : Collections.<String, Object>emptyMap();
// Pre-cache all of the namespaces to be a snapshot of what's in the global registry at this time.
// This behavior is specified in Section 3.5.2 of the JCR 2.0 specification.
localRegistry.getNamespaces();
// Increment the statistics ...
this.nanosCreated = System.nanoTime();
repository.statistics().increment(ValueMetric.SESSION_COUNT);