Package io.permazen.spring


package io.permazen.spring
Spring Framework integration classes.

Overview

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 http://permazen.io/schema/spring/permazen XML namespace:

Supported Elements
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: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. The <permazen:permazen> element supports the following attributes:

Supported 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.

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

 <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:permazen="http://permazen.io/schema/spring/permazen"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:c="http://www.springframework.org/schema/c"
   xsi:schemaLocation="
      http://permazen.io/schema/spring/permazen
        http://permazen.github.io/permazen/permazen-spring/src/main/resources/io/permazen/spring/permazen-1.1.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

     <!-- 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\..*"/>
         </permazen:scan-classes>
     </permazen:permazen>

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

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

 </beans>
 
See Also: