Skip to content

Getting started

Idriss Neumann edited this page Mar 16, 2015 · 91 revisions

JDK Version

JDK 1.7 and more

Maven repository

<repository>
    <id>vo-lifecycle-mvn-repo</id>
    <url>https://raw.github.com/idrissneumann/vo-lifecycle/mvn-repo/</url>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
    </snapshots>
</repository>

Maven dependency

<dependency>
    <groupId>vo-lifecycle</groupId>
    <artifactId>vo-lifecycle-core</artifactId>
    <version>${vo-lifecycle.version}</version>
</dependency>

Spring integration

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
    
	<!-- Transco table which can be used in the adapter -->
	<bean id="vo1TranscoStates" class="org.volifecycle.transco.impl.TranscoImpl">
        <property name="map">
            <map key-type="java.lang.String" value-type="java.lang.String">
                <entry key="STATE1" value="{id in database}" />
				<entry key="STATE2" value="{id in database}" />
            </map>
        </property>
    </bean>
	
    <!-- Event manager and change saver (not mandatory) -->
    <bean id="customEvtManager" class="org.yourproject.event.CustomEventManager" />
    <bean id="cusomChangeSaver" class="org.yourproject.event.CustomChangeSaver" />
    
    <!-- Adapters declarations -->
    <bean id="vo1Adapter" class="org.yourproject.adapter.VO1Adapter" />

    <!-- Checkers declarations -->
    <bean id="checkerDateValidated" class="org.yourproject.checkers.IsDateValidated">
        <property name="id" value="IS_ACCEPTED" />
        <property name="description" value="Assert : the object have got a setted validation date" />
    </bean>

    <!-- Transitions declarations -->
    <bean id="transitionToState2" class="org.volifecycle.lifecycle.impl.LifeCycleTransitionImpl">
        <!-- Type and description -->
        <property name="type" value="manual" />
        <property name="description" value="Change to STATE2" />
        
        <!-- Target state -->
        <property name="target" value="STATE2" />
        
        <!-- Checkers -->
        <property name="checkers">
            <list>
                <ref bean="checkerDateValidated" />
            </list>
        </property>
    </bean>
    
	<!-- States declarations -->
    <bean id="STATE1" class="org.volifecycle.lifecycle.impl.LifeCycleStateImpl">
        <!-- Id and description -->
        <property name="id" value="STATE1" />
        <property name="description" value="State 1" />
        
        <!-- Transitions by state id -->
        <property name="transitionsById">
            <map key-type="java.lang.String" value-type="org.volifecycle.lifecycle.impl.LifeCycleTransitionImpl">
                <entry key="STATE2" value-ref="transitionToState2" />
            </map>
        </property>
    </bean>
    
    <!-- Lifecycle managers declaration -->
    
     <bean id="dcLifeCycleManager" class="org.volifecycle.lifecycle.impl.LifeCycleManagerImpl">
        <!-- Id and description -->
        <property name="id" value="VO1_LIFECYCLE" />
        <property name="description" value="VO1 Lifecycle" />
        
        <!-- Lifecycle's state -->
        <property name="statesById">
            <map key-type="java.lang.String" value-type="org.volifecycle.lifecycle.impl.LifeCycleStateImpl">
                <entry key="STATE1" value-ref="STATE1" />
            </map>
        </property>
        
        <property name="adapter" ref="vo1Adapter" />
        <property name="evtManager" ref="customEvtManager" />
        <property name="saver" ref="cusomChangeSaver" />
     </bean>
</beans>

Clone this wiki locally