protected MutableCachedNode createNode(
     SessionCache session,
     MutableCachedNode parent,
     String id,
     Name name,
     Name primaryType,
     Property... properties) {
   NodeKey key = session.getRootKey().withId(id);
   return parent.createChild(
       session, key, name, propFactory.create(JcrLexicon.PRIMARY_TYPE, primaryType), properties);
 }
 @Override
 public boolean initializeIndexStorage(SessionCache session, MutableCachedNode systemNode) {
   this.propFactory = session.getContext().getPropertyFactory();
   assert systemNode != null;
   ChildReferences childReferences = systemNode.getChildReferences(session);
   // initializes the /jcr:system/mode:indexes node if not already present.
   NodeKey indexesNodeKey = systemNode.getKey().withId(INDEXES_NODE_ID);
   if (!childReferences.hasChild(indexesNodeKey)) {
     MutableCachedNode indexes =
         createNode(
             session,
             systemNode,
             INDEXES_NODE_ID,
             ModeShapeLexicon.INDEXES,
             ModeShapeLexicon.INDEXES);
     indexes.excludeFromSearch();
     return true;
   }
   return false;
 }
  @Override
  public void initializeSystemArea(SessionCache session, MutableCachedNode parent) {
    this.propFactory = session.getContext().getPropertyFactory();
    MutableCachedNode system = null;
    MutableCachedNode namespaces = null;

    // Create the "/jcr:system" node ...
    system =
        createNode(session, parent, SYSTEM_NODE_ID, JcrLexicon.SYSTEM, ModeShapeLexicon.SYSTEM);

    // Create the "/jcr:system/jcr:nodeTypes" node ...
    createNode(
        session, system, "jcr:nodeTypes", JcrLexicon.NODE_TYPES, ModeShapeLexicon.NODE_TYPES);

    // Create the "/jcr:system/jcr:versionStorage" node which we don't want to index
    MutableCachedNode versionStorage =
        createNode(
            session,
            system,
            "jcr:versionStorage",
            JcrLexicon.VERSION_STORAGE,
            ModeShapeLexicon.VERSION_STORAGE);
    versionStorage.excludeFromSearch();

    // Create the "/jcr:system/mode:namespaces" node ...
    namespaces =
        createNode(
            session,
            system,
            "mode:namespaces",
            ModeShapeLexicon.NAMESPACES,
            ModeShapeLexicon.NAMESPACES);

    // Create the standard namespaces ...
    // createNamespace(session, namespaces, "", ""); // Don't initialize the "" namespaces
    createNamespace(session, namespaces, JcrLexicon.Namespace.PREFIX, JcrLexicon.Namespace.URI);
    createNamespace(session, namespaces, JcrNtLexicon.Namespace.PREFIX, JcrNtLexicon.Namespace.URI);
    createNamespace(
        session, namespaces, JcrMixLexicon.Namespace.PREFIX, JcrMixLexicon.Namespace.URI);
    createNamespace(session, namespaces, JcrSvLexicon.Namespace.PREFIX, JcrSvLexicon.Namespace.URI);
    createNamespace(
        session, namespaces, ModeShapeLexicon.Namespace.PREFIX, ModeShapeLexicon.Namespace.URI);
    createNamespace(
        session,
        namespaces,
        JcrNamespaceRegistry.XML_NAMESPACE_PREFIX,
        JcrNamespaceRegistry.XML_NAMESPACE_URI);
    createNamespace(
        session,
        namespaces,
        JcrNamespaceRegistry.XMLNS_NAMESPACE_PREFIX,
        JcrNamespaceRegistry.XMLNS_NAMESPACE_URI);
    createNamespace(
        session,
        namespaces,
        JcrNamespaceRegistry.XML_SCHEMA_NAMESPACE_PREFIX,
        JcrNamespaceRegistry.XML_SCHEMA_NAMESPACE_URI);
    createNamespace(
        session,
        namespaces,
        JcrNamespaceRegistry.XML_SCHEMA_INSTANCE_NAMESPACE_PREFIX,
        JcrNamespaceRegistry.XML_SCHEMA_INSTANCE_NAMESPACE_URI);

    // Create the "/jcr:system/mode:locks" node which we don't want to index
    MutableCachedNode locks =
        createNode(session, system, "mode:locks", ModeShapeLexicon.LOCKS, ModeShapeLexicon.LOCKS);
    locks.excludeFromSearch();

    // Create the "/jcr:system/mode:indexes" node which we don't want to index
    initializeIndexStorage(session, system);
  }