Skip navigation links

Package io.permazen.spring

Spring Framework integration classes.

See: Description

Package io.permazen.spring Description

Spring Framework integration classes.


This package provides the following features to facilitate use with Spring:

Permazen XML Tags

Permazen makes available the following XML tags to Spring declarative XML. All elements live in the XML namespace:

Element Description
<permazen:scan-classes> Works just like Spring's <context:component-scan> but finds @PermazenType-annotated Java model classes. Returns the classes found in a List.
<permazen:scan-field-types> Works just like Spring's <context:component-scan> but finds @JFieldType-annotated custom FieldType classes. Returns the classes found in a List.
<permazen:permazen> Simplifies defining and configuring a Permazen database.

The <permazen:permazen> element requires a nested <permazen:scan-classes> element to configure the Java model classes. A nested <permazen:scan-field-types> may also be included. The <permazen:permazen> element supports the following attributes:

Attribute Type Required? Description
kvstore Bean reference No The underlying key/value store database. This should be the name of a Spring bean that implements the KVDatabase interface. If unset, defaults to a new SimpleKVDatabase instance.
schema-version Integer No The schema version corresponding to the configured Java model classes. A value of zero means to use whatever is the highest schema version already recorded in the database. A value of -1 (the default) means to auto-generate a version number based on the compatibility hash of the SchemaModel generated from the Java model classes.
storage-id-generator Bean reference No To use a custom StorageIdGenerator, specify the name of a Spring bean that implements the StorageIdGenerator interface. By default, a DefaultStorageIdGenerator is used. If this attribute is set, then auto-generate-storage-ids must not be set to false.
auto-generate-storage-ids Boolean No Whether to auto-generate storage ID's. Default is true

An example Spring XML configuration using an in-memory key/value store and supporting Spring's @Transactional annotation:

 <beans xmlns=""

     <!-- Define the underlying key/value database -->
     <bean id="kvdb" class="io.permazen.kv.simple.SimpleKVDatabase" p:waitTimeout="5000" p:holdTimeout="10000"/>

     <!-- Define the Permazen database on top of that -->
     <permazen:permazen id="permazen" kvstore="kvdb">

         <!-- These are our Java model classes -->
         <permazen:scan-classes base-package="com.example.myapp">
             <permazen:exclude-filter type="regex" expression="com\.example\.myapp\.test\..*"/>

         <!-- We have some custom FieldType's here too -->
         <permazen:scan-field-types base-package="com.example.myapp.fieldtype"/>

     <!-- Create a Permazen transaction manager -->
     <bean id="transactionManager" class="io.permazen.spring.PermazenTransactionManager"
       p:Permazen-ref="permazen" p:allowNewSchema="true"/>

     <!-- Enable @Transactional annotations -->
     <tx:annotation-driven transaction-manager="transactionManager"/>

See Also:
Spring Framework
Skip navigation links

Copyright © 2018. All rights reserved.