<?xml version="1.0" encoding="UTF-8"?>
<!-- 
  ~ ModeShape (http://www.modeshape.org)
  ~
  ~ See the COPYRIGHT.txt file distributed with this work for information
  ~ regarding copyright ownership.  Some portions may be licensed
  ~ to Red Hat, Inc. under one or more contributor license agreements.
  ~ See the AUTHORS.txt file in the distribution for a full listing of 
  ~ individual contributors.
  ~
  ~ ModeShape is free software. Unless otherwise indicated, all code in ModeShape
  ~ is licensed to you under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ ModeShape is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  ~ or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
  ~ for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public License
  ~ along with this distribution; if not, write to:
  ~ Free Software Foundation, Inc.
  ~ 51 Franklin Street, Fifth Floor
  ~ Boston, MA  02110-1301  USA
  -->
<configuration xmlns:mode="http://www.modeshape.org/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
    <!-- 
    Define the sources for the content.  These sources are directly accessible using the ModeShape-specific Graph API.
    In fact, this is how the ModeShape JCR implementation works.  You can think of these as being similar to
    JDBC DataSource objects, except that they expose graph content via the Graph API instead of records via SQL or JDBC. 
    -->
    <mode:sources jcr:primaryType="nt:unstructured">
        <!-- 
        The 'Cars' repository is an in-memory source with a single default workspace (though others could be created, too).
        -->
        <mode:source jcr:name="Cars" mode:classname="org.modeshape.graph.connector.inmemory.InMemoryRepositorySource" mode:retryLimit="3" mode:defaultWorkspaceName="workspace1"/>
        <!-- 
        The 'Aircraft' repository is also a JPA source (pointing to an in-memory HSQL database with a single default workspace.
        By defining a default workspace, the clients using the Graph API will by default use that workspace,
        but can easily say to use other workspaces (or create, clone, or destroy workspaces).
        
        If you wanted to use a JNDI datasource instead of manually specifying the database login information, you would replace this:
        	mode:driverClassName="org.hsqldb.jdbcDriver"
        	mode:username="sa"
        	mode:password=""
        	mode:url="jdbc:hsqldb:mem:target"
        
        With this:
        	mode:dataSourceJndiName="your JNDI name"
        -->
        <mode:source jcr:name="Aircraft" mode:classname="org.modeshape.connector.store.jpa.JpaSource"
        	mode:model="Simple"
        	mode:dialect="org.hibernate.dialect.HSQLDialect"
        	mode:driverClassName="org.hsqldb.jdbcDriver"
        	mode:username="sa"
        	mode:password=""
        	mode:url="jdbc:hsqldb:mem:target"
        	mode:maximumConnectionsInPool="1"
        	mode:referentialIntegrityEnforced="true"
        	mode:largeValueSizeInBytes="10000"
        	mode:retryLimit="3"
        	mode:compressData="false"
        	mode:predefinedWorkspaceNames="workspace2"
        	mode:showSql="false"
            mode:autoGenerateSchema="create"
            mode:creatingWorkspacesAllowed="true"
        	mode:defaultWorkspaceName="workspace2" />    

        <!-- 
        The 'UFO' repository is a file system source with a single default workspace.  The file system connector exposes
        files and folders as JCR nodes.  It can save JCR nodes too, but only if they have certain primary types.
        -->
        <mode:source jcr:name="UFOs" mode:classname="org.modeshape.connector.filesystem.FileSystemSource"
        	mode:workspaceRootPath="./ufoSource"
        	mode:defaultWorkspaceName="workspace1"
        	mode:creatingWorkspacesAllowed="false"
        	mode:updatesAllowed="true"/>    
        <!-- 
        The 'Vehicles' repository is a federated source that owns none of its own content, but instead
        projects (in this case) all of the content from the 'Cars' source as if it appears
        under '/Vehicles/Cars', while all the 'Aircraft' content appears under '/Vehicles/Aircraft'.
        -->
        <mode:source jcr:name="Vehicles">
            <mode:classname>org.modeshape.graph.connector.federation.FederatedRepositorySource</mode:classname>
            <mode:workspaces>
                <!-- 
                Unlike some other repository sources, federated sources have to define all of their workspaces,
                including how and where the content is projected.  So, we only need a single workspace,
                but we could actually define additional workspaces that expose various combinations or portions
                of 'Cars' and/or 'Aircraft' content.
                -->
                <mode:workspace jcr:name="virtual">
                    <mode:projections>
                        <!-- Project the 'Cars' content, starting with the '/Cars' node. -->
                        <mode:projection jcr:name="Cars projection" mode:source="Cars" mode:workspaceName="workspace1">
                            <mode:projectionRules>/Vehicles/Cars => /Cars</mode:projectionRules>
                        </mode:projection>
                        <!-- Project the 'Aircraft' content, starting with the '/Aircraft' node. -->
                        <mode:projection jcr:name="Aircarft projection" mode:source="Aircraft" mode:workspaceName="workspace2">
                            <mode:projectionRules>/Vehicles/Aircraft => /Aircraft</mode:projectionRules>
                        </mode:projection>
                        <!-- Project the 'UFO' content, starting with the root node. -->
                        <mode:projection jcr:name="UFO projection" mode:source="UFOs" mode:workspaceName="workspace1">
                            <mode:projectionRules>/Vehicles/UFOs => /</mode:projectionRules>
                        </mode:projection>
                        <!-- Project the 'System' content. Only needed when this source is accessed through JCR. -->
                        <!-- mode:projection jcr:name="System projection" mode:source="System" mode:workspaceName="default">
                            <mode:projectionRules>/jcr:system => /</mode:projectionRules>
                        </mode:projection-->
                    </mode:projections>
                </mode:workspace>
            </mode:workspaces>
        </mode:source>
        <!-- 
        A 'System' source needed for the '/jcr:system' branch of the Vehicles source when it is access through JCR.
        -->
        <!-- mode:source jcr:name="System" mode:classname="org.modeshape.graph.connector.inmemory.InMemoryRepositorySource" mode:retryLimit="3" mode:defaultWorkspaceName="default"/-->
    </mode:sources>
    <!-- 
    Define the sequencers. This is an optional section. For this example, we're not using any sequencers. 
    -->
    <mode:sequencers>
        <!--mode:sequencer jcr:name="Image Sequencer" mode:classname="org.modeshape.sequencer.image.ImageMetadataSequencer">
            <mode:description>Image metadata sequencer</mode:description>        
            <mode:pathExpression>/foo/source => /foo/target</mode:pathExpression>
            <mode:pathExpression>/bar/source => /bar/target</mode:pathExpression>
        </mode:sequencer-->
    </mode:sequencers>
    <!-- 
    Define the mime type detectors. This is an optional section.  By default, each engine will use the 
    MIME type detector that uses filename extensions.  So we wouldn't need to define the same detector again,
    but this is how you'd define another extension.
    -->
    <mode:mimeTypeDetectors>
        <mode:mimeTypeDetector jcr:name="Detector">
            <mode:description>Standard extension-based MIME type detector</mode:description>        
            <!-- 
            Specify the implementation class (required), as a child element or attribute on parent element.
            -->
            <mode:classname>org.modeshape.graph.mimetype.ExtensionBasedMimeTypeDetector</mode:classname>
            <!-- 
            Specify the classpath (optional) as an ordered list of 'names', where each name is significant to 
            the classpath factory.  For example, a name could be an OSGI identifier or a Maven coordinate,
            depending upon the classpath factory being used.  If there is only one 'name' in the classpath,
            it may be specified as an attribute on the 'mimeTypeDetector' element.  If there is more than one
            'name', then they must be specified as child 'classpath' elements. Blank or empty values are ignored. 
             -->
            <mode:classpath></mode:classpath>
            <mode:classpath></mode:classpath>
        </mode:mimeTypeDetector>
    </mode:mimeTypeDetectors>
    <!-- 
    Define the JCR repositories 
    -->
    <mode:repositories>
        <!-- 
        Define a JCR repository that accesses the 'Cars' source directly.
        This of course is optional, since we could access the same content through 'vehicles'.
        -->
        <mode:repository jcr:name="Cars">
            <!-- Specify the source that should be used for the repository -->
            <mode:source>Cars</mode:source>
            <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
            <mode:options jcr:primaryType="mode:options">
                <jaasLoginConfigName jcr:primaryType="mode:option" mode:value="modeshape-jcr"/>
            </mode:options>
            <!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
            <jcr:nodeTypes mode:resource="/cars.cnd" />
            <!-- Define any namespaces for this repository, other than those already defined by JCR or ModeShape -->
            <namespaces jcr:primaryType="mode:namespaces">
                <car jcr:primaryType="mode:namespace" mode:uri="http://jboss.org/dna/examples/cars/1.0"/>
            </namespaces>
        </mode:repository>
        <!-- 
        Define a JCR repository that accesses the 'Aircraft' source directly.
        This of course isn't really necessary for this example, since we could access the same content through 'vehicles'.
        -->
        <mode:repository jcr:name="Aircraft">
            <!-- Specify the source that should be used for the repository -->
            <mode:source>Aircraft</mode:source>
            <!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
            <jcr:nodeTypes mode:resource="/aircraft.cnd" />
            <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
            <mode:options jcr:primaryType="mode:options">
                <jaasLoginConfigName jcr:primaryType="mode:option" mode:value="modeshape-jcr"/>
            </mode:options>
        </mode:repository>
        <!-- 
        Define a JCR repository that accesses the 'UFO' source directly.
        This of course is optional, since we could access the same content through 'vehicles'.
        -->
        <mode:repository jcr:name="UFOs">
            <!-- Specify the source that should be used for the repository -->
            <mode:source>UFOs</mode:source>
            <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
            <mode:options jcr:primaryType="mode:options">
                <jaasLoginConfigName jcr:primaryType="mode:option" mode:value="modeshape-jcr"/>
            </mode:options>
            <!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
            <mode:nodeTypes jcr:primaryType="mode:nodeTypes"/>
            <!-- Define any namespaces for this repository, other than those already defined by JCR or ModeShape -->
            <namespaces jcr:primaryType="mode:namespaces" />
        </mode:repository>
        <!-- 
        Define a JCR repository that accesses the 'Vehicles' federated source directly,
        which is defined in the sources to be a projection of the 'Cars' and 'Vehicles' content.
        -->
        <!-- Define a JCR repository that accesses the 'Vehicles' federated source directly -->
        <mode:repository jcr:name="Vehicles">
            <!-- Specify the source that should be used for the repository -->
            <mode:source>Vehicles</mode:source>
            <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
            <mode:options jcr:primaryType="mode:options">
                <projectNodeTypes jcr:primaryType="mode:option" mode:value="false"/>
                <jaasLoginConfigName jcr:primaryType="mode:option" mode:value="modeshape-jcr"/>
            </mode:options>
            <!--  Add any custom JCR descriptors -->
            <mode:descriptors>
            	<!-- 
            		This adds a JCR Repository descriptor named "myCustomDescriptor" with a value of "foo".
            		So this code:
            		Repository repo = ...;
            		System.out.println(repo.getDescriptor("myCustomDescriptor");
            		
            		Will now print out "foo".
            	-->
            	<myCustomDescriptor mode:value="foo" />
            </mode:descriptors>
            <!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
            <jcr:nodeTypes mode:resource="/aircraft.cnd,/cars.cnd" />
            <!-- Define any namespaces for this repository, other than those already defined by JCR, ModeShape or by imported content. -->
            <mode:namespaces jcr:primaryType="mode:namespaces">
                <car jcr:primaryType="mode:namespace" mode:uri="http://www.modeshape.org/examples/cars/1.0"/>
                <air jcr:primaryType="mode:namespace" mode:uri="http://www.modeshape.org/examples/aircraft/1.0"/>
            </mode:namespaces>
        </mode:repository>
    </mode:repositories>
</configuration>
