<?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 JCR repositories -->
    <mode:repositories>
        <!-- Specify the source that should be used for the repository -->
        <mode:repository jcr:name="repository" >
            <mode:source>store</mode:source>
            <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names-->
            <mode:options jcr:primaryType="options">
                <!-- Should node types appear as nodes under '/jcr:system/jcr:nodeTypes'? -->
                <mode:option jcr:name="projectNodeTypes" mode:value="true"/>
	            <!-- The name of the JAAS application policy, used when clients get a session with credentials.
	                   (This policy is defined in the 'jboss-modeshape-beans.xml' file). -->
                <mode:option jcr:name="jaasLoginConfigName" mode:value="modeshape"/>

				<!-- Explicitly specify the "system" workspace in the "SystemStore" source. -->
				<mode:option jcr:name="systemSourceName" mode:value="system@store"/>
				
				<!-- Explicitly specify the directory where the index files should be stored. -->
				<mode:option jcr:name="queryIndexDirectory" mode:value="${jboss.server.data.dir}/modeshape/repositories/store/indexes"/>				
				
                
				<!--  Should  indexes should be rebuilt synchronously when the repository restarts, default true  -->                			
                <mode:option jcr:name="queryIndexesRebuiltSynchronously" mode:value="true"/>
                <!--  specifies the strategy (always or ifMissing) used to determine which query indexes need to be rebuilt when the repository restarts -->
				<mode:option jcr:name="rebuildQueryIndexOnStartup" mode:value="ifMissing"/>
                
            </mode:options>
            <!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here.-->
            <jcr:nodeTypes>
                <mode:resource>/org/modeshape/sequencer/teiid/teiid.cnd</mode:resource>
                <mode:resource>/org/modeshape/connector/meta/jdbc/connector-metajdbc.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/classfile/sequencer-classfile.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/image/images.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/java/javaSource.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/mp3/mp3.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/msoffice/msoffice.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/text/sequencer-text.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/xml/xml.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/zip/zip.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/sramp/sramp.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/wsdl/wsdl.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/xsd/xsd.cnd</mode:resource>				
                <mode:resource>/org/modeshape/sequencer/ddl/StandardDdl.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/ddl/dialect/derby/DerbyDdl.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdl.cnd</mode:resource>
                <mode:resource>/org/modeshape/sequencer/ddl/dialect/postgres/PostgresDdl.cnd</mode:resource>
            </jcr:nodeTypes>
            <!-- Define what the initial content looks like for each workspace -->
            <mode:initialContent mode:workspaces="default" mode:applyToNewWorkspaces="true" mode:content="modeshape-initial-content.xml"/>
        </mode:repository>
    </mode:repositories>

    <!-- Define the sources used by the repository (or repositories) to store and access the content -->
    <mode:sources jcr:primaryType="nt:unstructured">
        <!-- 
        If you wanted to use the driver directly instead of using the JNDI reference, you would replace
			mode:dataSourceJndiName="java:DefaultDS" 
			
		with these:
        	mode:driverClassName="org.hsqldb.jdbcDriver"
        	mode:username="sa"
        	mode:password=""
        	mode:url="jdbc:hsqldb:mem:target"
			mode:maximumConnectionsInPool="5"


        -->
        <mode:source jcr:name="store" mode:classname="org.modeshape.connector.store.jpa.JpaSource"
			mode:dataSourceJndiName="java:DefaultDS"
			mode:model="Simple"
        	mode:dialect="org.hibernate.dialect.HSQLDialect"
        	mode:referentialIntegrityEnforced="true"
        	mode:largeValueSizeInBytes="10000"
        	mode:retryLimit="3"
        	mode:compressData="false"
        	mode:predefinedWorkspaceNames="default,system"
        	mode:showSql="false"
            mode:autoGenerateSchema="update"
            mode:creatingWorkspacesAllowed="true"
        	mode:defaultWorkspaceName="default" />    
    </mode:sources>
    
    <mode:sequencers>
			  <!-- 
			  These are configured for demonstration purposes, and currently only apply to files uploaded into the 'default' workspace
			  of the 'store' source.  Adjust the path expressions and use those appropriate for your use case.
			  -->
        <mode:sequencer jcr:name="Delimited Text File Sequencer" mode:classname="org.modeshape.sequencer.text.DelimitedTextSequencer">
            <mode:description>Sequences *.csv text files loaded under '/files', extracting comma-separated and delimited files into columnar information.</mode:description>        
            <mode:pathExpression>store:default:/files//(*.csv[*])/jcr:content[@jcr:data] => store:default:/sequenced/text/delimited/$1 </mode:pathExpression>
            <!-- The split pattern is a regular expression used to split each row into columns. -->
            <mode:splitPattern>,</mode:splitPattern>
        </mode:sequencer>
        <mode:sequencer jcr:name="Fixed Width Text File Sequencer" mode:classname="org.modeshape.sequencer.text.FixedWidthTextSequencer">
            <mode:description>Sequences *.txt fixed-width text files loaded under '/files', extracting splitting rows into columns based on predefined positions.</mode:description>        
            <mode:pathExpression>store:default:/files//(*.txt[*])/jcr:content[@jcr:data] => store:default:/sequenced/text/fixedWidth/$1 </mode:pathExpression>
            <!-- The 'columnStartPositions' define the 0-based column start positions. Everything before the 
			           first start position is treated as the first column. The default value is the empty string 
			           (implying that each row should be treated as a single column). There is an implicit column 
			           start position of 0 that never needs to be specified. -->
			      <mode:columnStartPositions></mode:columnStartPositions>
        </mode:sequencer>
        <mode:sequencer jcr:name="Teiid Model Sequencer" mode:classname="org.modeshape.sequencer.teiid.ModelSequencer">
            <mode:description>Sequences Teiid relational models (e.g., *.xmi) loaded under '/files', extracting the structure defined in the models.</mode:description>
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only)
                 but excluding the filename, and places the sequenced content under the same relative path below '/sequenced/teiid/models'. 
                 For example, if an XMI model is uploaded to '/files/my/favorites/CustomerDetails.xmi', then the sequenced output will be placed at
                 the '/sequenced/teiid/models/my/favorites/CustomerDetails' node, which will have a primary type of 'xmi:model' and will
                 contain under it the nodes representing the catalogs, schemas, tables, views, columns, etc. Of course, the 
                 path expression can be modified as needed; for example, to include the filename of the XMI model in the 
                 sequenced output path. -->
            <mode:pathExpression>store:default:/files(//)(*.xmi[*])/jcr:content[@jcr:data] => store:default:/sequenced/teiid/models$1 </mode:pathExpression>
        </mode:sequencer>
        <mode:sequencer jcr:name="Teiid VDB Sequencer" mode:classname="org.modeshape.sequencer.teiid.VdbSequencer">
            <mode:description>Sequences Teiid Virtual Databases (e.g., *.vdb) loaded under '/files', extracting the VDB metadata and the structure defined in the VDB's relational models.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only) 
                 but excluding the filename, and places the sequenced content under the same relative path below '/sequenced/teiid/models'. 
                 For example, if a VDB file is uploaded to '/files/my/favorites/Customers.vdb', then the sequenced output will be placed at
                 the '/sequenced/teiid/models/my/favorites/Customer' node, which will have a primary type of 'vdb:virtualDatabase' and will
                 contain under it the nodes representing the models (which will each contain the nodes representing that
                 model's catalogs, schemas, tables, views, columns, etc.).  Of course, the path expression
                 can be modified as needed; for example, to include the filename of the XMI model in the sequenced output path. -->
            <mode:pathExpression>store:default:/files(//)(*.vdb[*])/jcr:content[@jcr:data] => store:default:/sequenced/teiid/vdbs$1 </mode:pathExpression>
        </mode:sequencer>
        <mode:sequencer jcr:name="Class File Sequencer" mode:classname="org.modeshape.sequencer.classfile.ClassFileSequencer">
            <mode:description>Sequences Java class files loaded under '/files', extracting structural information.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only)
                 including the filename, and places the sequenced content under the same relative path below '/sequenced/class'. 
                 For example, if a classfile is uploaded to '/files/my/favorites/org/example/Customers.class', then the sequenced output will be placed at
                 the '/sequenced/class/org/example/Customers.class' node, which will have a primary type of 'nt:unstructured'
                 and will contain under it a 'class:class' for each Java class, under which are the nodes representing the
                 methods, fields, constructors, and annotations. Of course, the path expression can be modified as needed. -->
            <mode:pathExpression>store:default:/files(//(*.class[*]))/jcr:content[@jcr:data] => store:default:/sequenced/class/$1 </mode:pathExpression>
        </mode:sequencer>
        <mode:sequencer jcr:name="Java File Sequencer" mode:classname="org.modeshape.sequencer.java.JavaMetadataSequencer">
            <mode:description>Sequences Java source files loaded under '/files', extracting structural information.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only)
                 including the filename, and places the sequenced content under the same relative path below '/sequenced/java'. 
                 For example, if a classfile is uploaded to '/files/my/favorites/org/example/Customers.java', then the sequenced output will be placed at
                 the '/sequenced/class/org/example/Customers.java' node, which will have a primary type of 'nt:unstructured'
                 and will contain under it a 'class:class' for each Java class, under which are the nodes representing the
                 methods, fields, constructors, and annotations. Of course, the path expression can be modified as needed. -->
            <mode:pathExpression>store:default:/files(//(*.java[*]))/jcr:content[@jcr:data] => store:default:/sequenced/java/$1 </mode:pathExpression>
        </mode:sequencer>
        <mode:sequencer jcr:name="CND File Sequencer" mode:classname="org.modeshape.sequencer.cnd.CndSequencer">
            <mode:description>Sequences CND files loaded under '/files', extracting the contained node type definitions.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only)
                 including the filename, and places the sequenced content under the same relative path below '/sequenced/cnd'. 
                 For example, if a CND file is uploaded to '/files/my/favorites/Customers.cnd', then the sequenced output will be placed at
                 the '/sequenced/ddl/my/favorites/Customer.cnd' node, which will have a primary type of 'nt:unstructured' and will
                 contain under it the 'nt:nodeType', 'nt:propertyDefinition' and 'nt:childNodeDefinition' nodes representing 
                 the node types, property definitions, and child node definitions contained within the CND file.
                 Of course, the path expression can be modified as needed; for example, to exclude the filename extension, 
                 or to exclude the relative path. -->
            <mode:pathExpression>store:default:/files(//(*.cnd[*]))/jcr:content[@jcr:data] => store:default:/sequenced/cnd/$1 </mode:pathExpression>
        </mode:sequencer>
        <mode:sequencer jcr:name="DDL File Sequencer" mode:classname="org.modeshape.sequencer.ddl.DdlSequencer">
            <mode:description>Sequences DDL files loaded under '/files', extracting the structured abstract syntax tree of the DDL commands and expressions.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only)
                 including the filename, and places the sequenced content under the same relative path below '/sequenced/ddl'. 
                 For example, if a DDL file is uploaded to '/files/my/favorites/Customers.ddl', then the sequenced output will be placed at
                 the '/sequenced/ddl/my/favorites/Customer.ddl' node, which will have a primary type of 'nt:unstructured' and will
                 contain under it the nodes representing the DDL statements. Of course, the path expression
                 can be modified as needed; for example, to exclude the filename extension, or to exclude the relative path. -->
            <mode:pathExpression>store:default:/files(//(*.ddl[*]))/jcr:content[@jcr:data] => store:default:/sequenced/ddl/$1 </mode:pathExpression>
        </mode:sequencer>     
        <mode:sequencer jcr:name="MS Office File Sequencer" mode:classname="org.modeshape.sequencer.msoffice.MSOfficeMetadataSequencer">
            <mode:description>Sequences Microsoft Office documents and presentations under '/files', extracting summary information and structure.</mode:description>        
            <mode:pathExpression>store:default:/files//(*.(xls|ppt|doc)[*])/jcr:content[@jcr:data] => store:default:/sequenced/msoffice/$1 </mode:pathExpression>
        </mode:sequencer>
        <mode:sequencer jcr:name="XSD File Sequencer" mode:classname="org.modeshape.sequencer.xsd.XsdSequencer">
            <mode:description>Sequences XSD files loaded into the repository under '/files', extracting the contents into the equivalent JCR graph structure.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only), 
                 including the filename, and places the sequenced content under the same relative path below '/sequenced/xsd'. 
                 For example, if an XSD file is uploaded to '/files/my/favorites/Customers.xsd', then the sequenced output will be placed at
                 the '/sequenced/wsdl/my/favorites/Customer.xsd' node, which will have a primary type of 'xs:schemaDocument' and will
                 contain under it the nodes representing the XSD components. Of course, the path expression
                 can be modified as needed; for example, to exclude the filename extension, or to exclude the relative path. -->
            <mode:pathExpression>store:default:/files(//)*.xsd[*]/jcr:content[@jcr:data] => store:default:/sequenced/xsd/$1 </mode:pathExpression>
        </mode:sequencer>  
        <mode:sequencer jcr:name="WSDL File Sequencer" mode:classname="org.modeshape.sequencer.wsdl.WsdlSequencer">
            <mode:description>Sequences WSDL 1.1 files loaded into the repository under '/files', extracting the contents into the equivalent JCR graph structure.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only), 
                 including the filename, and places the sequenced content under the same relative path below '/sequenced/wsdl'. 
                 For example, if a WSDL file is uploaded to '/files/my/favorites/Customers.wsdl', then the sequenced output will be placed at
                 the '/sequenced/wsdl/my/favorites/Customer.wsdl' node, which will have a primary type of 'wsdl:wsdlDocument' and will
                 contain under it the nodes representing the WSDL components. Of course, the path expression
                 can be modified as needed; for example, to exclude the filename extension, or to exclude the relative path. -->
            <mode:pathExpression>store:default:/files(//)*.wsdl[*]/jcr:content[@jcr:data] => store:default:/sequenced/wsdl/$1 </mode:pathExpression>
        </mode:sequencer>  
        <mode:sequencer jcr:name="XML File Sequencer" mode:classname="org.modeshape.sequencer.xml.XmlSequencer">
            <mode:description>Sequences XML files loaded under '/files', extracting the contents into the equivalent JCR graph structure.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only), 
                 including the filename, and places the sequenced content under the same relative path below '/sequenced/xml'. 
                 For example, if an XML file is uploaded to '/files/my/favorites/Customers.xml', then the sequenced output will be placed at
                 the '/sequenced/xml/my/favorites/Customer.xml' node, which will have a primary type of 'modexml:document' and will
                 contain under it the nodes representing the XML elements, attributes, and content nodes. Of course, the path expression
                 can be modified as needed; for example, to exclude the filename extension, or to exclude the relative path. -->
            <mode:pathExpression>store:default:/files(//)*.xml[*]/jcr:content[@jcr:data] => store:default:/sequenced/xml/$1 </mode:pathExpression>
        </mode:sequencer>  
        <mode:sequencer jcr:name="ZIP File Sequencer" mode:classname="org.modeshape.sequencer.zip.ZipSequencer">
            <mode:description>Sequences ZIP files loaded under '/files', extracting the archive file contents into the equivalent JCR graph structure of 'nt:file' and 'nt:folder' nodes.</mode:description>        
            <!-- Note this path expression captures the path below '/files' (in the 'store' source and 'default' workspace only), 
                 including the filename, and places the sequenced content under the same relative path below '/sequenced/zip'. 
                 For example, if a ZIP file is uploaded to '/files/my/favorites/Customers.zip', then the sequenced output will be placed at
                 the '/sequenced/xml/my/favorites/Customer.zip' node, which will have a primary type of 'zip:file'
                 (a subtype of 'nt:folder') and will contain 'nt:file' and 'nt:folder' nodes for each file and folder (respectively)
                 in the archive file. Of course, the path expression can be modified as needed; for example, to exclude the 
                 filename extension, or to exclude the relative path. -->
            <mode:pathExpression>store:default:/files(//)(*.zip[*])/jcr:content[@jcr:data] => store:default:/sequenced/zip/$1 </mode:pathExpression>
        </mode:sequencer>                          
    </mode:sequencers>
	
	<!--  
		Cluster Configuration options that use JGroups
		
		1.  Use the JGroups default configuration
		2.  Define your own JGroups configuration, below is an example
		
		Uncomment one of the options to enable ModeShape clustering.
	-->
	
	<!--  Option 1.  Use JGroups Default Configuration
	   <mode:clustering clusterName="modeshape-cluster" >	
	      <configuration>
		  </configuration>
	</mode:clustering>		
	
	-->
	
	<!-- Option 2.  Example of how to define your own JGroups configuration
		  
    <mode:clustering clusterName="modeshape-cluster" >	
	      <configuration>
			<![CDATA[<config>
   <UDP mcast_addr="${jboss.jgroups.modeshape.mcast_addr:228.10.10.10}"
        mcast_port="${jboss.jgroups.modeshape.mcast_port:45690}"
		bind_port="${jboss.jgroups.modeshape.bind_port:55275}"
        discard_incompatible_packets="true"
        max_bundle_size="64000"
        max_bundle_timeout="30"
        ip_ttl="${jgroups.udp.ip_ttl:2}"
        enable_bundling="true"
        thread_pool.enabled="true"
        thread_pool.min_threads="1"
        thread_pool.max_threads="25"
        thread_pool.keep_alive_time="5000"
        thread_pool.queue_enabled="false"
        thread_pool.queue_max_size="100"
        thread_pool.rejection_policy="Run"
        oob_thread_pool.enabled="true"
        oob_thread_pool.min_threads="1"
        oob_thread_pool.max_threads="8"
        oob_thread_pool.keep_alive_time="5000"
        oob_thread_pool.queue_enabled="false"
        oob_thread_pool.queue_max_size="100"
        oob_thread_pool.rejection_policy="Run"/>
   <PING timeout="2000"
           num_initial_members="3"/>
   <MERGE2 max_interval="30000"
           min_interval="10000"/>
   <FD_SOCK/>
   <FD timeout="10000" max_tries="5" />
   <VERIFY_SUSPECT timeout="1500"  />
   <BARRIER />
   <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
                  retransmit_timeout="300,600,1200,2400,4800"
                  discard_delivered_msgs="true"/>
   <UNICAST timeout="300,600,1200,2400,3600"/>
   <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
                  max_bytes="400000"/>
   <VIEW_SYNC avg_send_interval="60000"   />
   <pbcast.GMS print_local_addr="true" join_timeout="3000"
               view_bundling="true"/>
   <FC max_credits="20000000"
                   min_threshold="0.10"/>
   <FRAG2 frag_size="60000"  />
   <pbcast.STATE_TRANSFER  />  
			</config>]]>

		  </configuration>
	</mode:clustering>
	
	-->
	
	
	
</configuration>