This documentation is for WSO2 App Factory 2.0.0. View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

Introduction

Lifecycle Management of all the applications is handled by the <lifecycle> element. This section describes how to create a lifecycle that needs to be applied for the applications. The lifecycle includes the stages that are associated with the application, the configurations for switching between stages when promoting or demoting the application, the conditions and validations for promotion and demotion etc. 

For this, add the new life cycle stage declaration inside the  <lifecycle> element in <AF_HOME>/repository/resources/lifecycles/configurations.xml file.  

Sample configuration

Following sample code explains how to add a life cycle stage called Testing between existing Development and Production life cycle stages. Assume the Testing stage has two checklists as 'Smoke Test Passed*' and 'Test Cases Passed*'. These checklists ensure that certain standards and policies are satisfied before moving the application to the next stage. This stage also has Demote and Promote as possible transition states.

<lifecycle>
	<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="Development">     
		<!-- Development life cycle -->
		<state id="Development">
		.
		.
		</state>
		
		<!-- Testing life cycle -->
		<state id="Testing">
			<datamodel>
				<data name="checkItems">
					<item name="Smoke Tests Passed*" forEvent="Promote"></item>
					<item name="Test Cases Passed*" forEvent="Promote"></item>
				</data>
				<data name="transitionExecution">
					<execution forEvent="Promote" class="org.wso2.carbon.appfactory.core.governance.lifecycle.AppFactoryLCExecutor"></execution>
					<execution forEvent="Demote" class="org.wso2.carbon.appfactory.core.governance.lifecycle.AppFactoryLCExecutor"></execution>			    
				</data>	
		
				<data name="transitionScripts">
					<js forEvent="Promote">
						<console function="doPromote">
							<script type="text/javascript">
						    	doPromote = function() {
								window.location = unescape("../resources/resource.jsp?region=region3%26item=resource_browser_menu%26path=/_system/governance/repository/applications");
						    	}
							</script>
						</console>                          
					</js>
					<js forEvent="Demote">
						<console function="doDemote">
							<script type="text/javascript">
						    	doPromote = function() {
								window.location = unescape("../resources/resource.jsp?region=region3%26item=resource_browser_menu%26path=/_system/governance/repository/applications");
						    	}
							</script>
						</console>
					</js>
				</data>			
			</datamodel>
			<transition event="Promote" target="Production"/>
			<transition event="Demote" target="Development"/>
		</state>
   
		<!-- Production life cycle -->
		<state id="Production">
		.
		.
		</state>

	</scxml>
</lifecycle>

The elements of the sample configuration are explained below. You can use this information to edit the file according to you requirements.

XML elements of the sample code

Property NameDescriptionTypeDefault ValueFixed ValuesMandatory/Optional
< scxml xmlns = "" version = "" initialstate = "" >     
<state id="">

state - New life cycle is stated using <state> tag.

  id - Defines the name of the state.

    
<datamodel>

Datamodel specifies logics for given life cycle. It contains 3 data elements that defines:

  • Check items.
  • Transition permissions.
  • Transition scripts.
    
          <
          data name
          =
          ""
          >  
     
 
          
        

Define data model.

  

checkItems: defines that this element contains the set of check items. It is required to be set to 'checkItems'

transitionExecution: Specify transition states for a given lifecycle.

transitionScripts: Currently App Factory is not using above code block. Therefore keep as it is during new lifecycle.

 
 < item name = "" forEvent = "" >

name - Defines the check item name
forEvent - Defines the set of transitions that this check item is required. Accepts a ',' separated list.

    
 < execution forEvent = "" class = "" ><execution> defines, which life cycle executor class has to execute when a specific transition state has clicked.     
 < js forEvent = "" >     
 < console function = "" >     
 

< script type = " text/javascript " >

This attribute specifies the scripting language of the element's contents and overrides the default scripting language.    
          <
          transition event
          =
          "" target
          =
          ""
          />
        
event
Event specify which life cycle stage has to move when a given transition state has clicked.    
 targetDefine target life cycle.    
  • No labels