Version 6

    This will describe how the modeshape-config.xml file can be configured when ModeShape is run in a JBoss AS server.

     

    Change from default InMemoryRepositorySource to use a JDBC source

     

    The following are 2 options for configuring to a JDBC source.

    1. Use JNDI to refer to an existing JDBC DataSource managed by the server (with connection pools); or
    2. Specify the JDBC connection properties, and ModeShape will use its own connections

     

    Using JNDI

    To use JNDI to reference a JDBC DataSource, replace the <mode:source> fragment with the following:

     

      <mode:source jcr:name="store" 
            mode:classname="org.modeshape.connector.store.jpa.JpaSource"
            <!-- begin JNDI attribute -->
            mode:dataSourceJndiName="your JNDI name"
            <!-- end JNDI attribute -->
            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" /> 
    

     

    Most of these values can be changed to suit your particular needs (see the JPA Connector appendix in our Reference Guide for detailed descriptions of each attribute). Specifically, in production you will want much more control over the database schema, and can generate the appropriate schema for your DBMS, have your DBA manually set up (or modify) your production database, and remove the "mode:autoGenerateSchema" attribute altogether.

     

    If the referenced data source does not already exist, then configure it using a -ds.xml file in the server/<configuration>/deploy directory.

     

    Using JDBC Connections

    If you want to connect directly to the JDBC data source, use the same <mode:source> fragment as for JNDI except replace the "mode:dataSourceJndiName" attribute with several connection-related attributes:

     

     <mode:source jcr:name="store"
            mode:classname="org.modeshape.connector.store.jpa.JpaSource"
            <!-- begin JDBC connection attributes -->
            mode:driverClassName="org.hsqldb.jdbcDriver"
            mode:username="sa"
            mode:password=""
            mode:url="jdbc:hsqldb:mem:target"
            mode:maximumConnectionsInPool="5" 
            <!-- end JDBC connection attributes -->
            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" />
    

     

     

     

    For purposes of illustration, the HSQL DB is being used, but simply replace the attribute values with the appropriate driver class name, username, password, and database URL.