Andreas 'ac0v' Specht > Hyper > Hyper::Config::Reader::Flow

Download:
Hyper-v0.05.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Module Version: v0.01   Source  

NAME ^

Hyper::Config::Reader::Flow - ini style Flow Control config reader

VERSION ^

This document describes Hyper::Config::Reader::Flow 0.01

SYNOPSIS ^

    use Hyper::Config::Reader::Flow;
    my $object = Hyper::Config::Reader::Flow->new({
        base_path => '/srv/web/www.example.com/',
        file      => 'etc/MyPortal/Control/Flow/FTest.ini',
    });

DESCRIPTION ^

This module is used for reading ini config files into Hyper config objects.

ATTRIBUTES ^

steps :get :default<{}>
validators :get :default<{}>
controls :get :default<{}>
attributes :get :default<[]>

SUBROUTINES/METHODS ^

_read_config :PROTECTED

Internally used to read the config file into an object hierarchy.

DIAGNOSTICS ^

CONFIGURATION AND ENVIRONMENT ^

The ini style configuration files are stored within the following structure:

 $BASE_PATH/etc/$NAMESPACE/Control/Flow/$SERVICE/$USECASE.ini

CONFIG FILE SYNTAX ^

The config file syntax is UNIX-Style .ini-Files. They are a bit different from Windows-style .ini files - the most notable difference is heredoc-support:

 attribute=<<EOT
 first_value
 second_value
 third_value
 EOT

The config file is split into several sections.

Config file sections

[Global]

Global configuration data goes here.

The attributes allowed in [Global] are described below.

attributes

Attributes for this Control. Multiple attributes can be specified using the heredoc syntax.

Example:

 [Global]
 attributes=<<EOT
 mMyAttribute
 mAnotherOne
 EOT

[Control] - embedded controls

You can embed Flow, Container and Primitive controls. Each embedded control needs a unique name and a class.

Controls are all subsections of the section [Control]:

 [Control]
 [Control $NAME]

Controls have the following attributes:

class :MANDATORY

Class of the embedded control. Perl class name with all '::' replaced by '.' and without the leading Hyper namespace

Example:

 [Control cSampleControl]
 ; use Hyper::Control::Container::CSample as Perl class
 class=Control.Container.CSample
template :OPTIONAL

Available for Container, Base and Primitive Controls. Template used for rendering a control. You may either specify a path relative to base_path or an absolute path.

dispatch :OPTIONAL

You can specify a class where a method named DISPATCH exists. This method is called very early in our Hyper workflow, before anything was printed to the client. You can change the Hyper application for example if you won't send any HTML Headers. This is needed for example if you'd like to implement a download.

Full example:

 [Control]
 [Control cExampleControl]
 class=ControlType.myService.myUsecase
 template=/path/to/template

[Step] - workflow steps

A workflow consist of a number of steps. Steps may have actions (code) to be executed and controls to be displayed.

Steps are connected via transitions which may have conditions to be met.

All steps are subsections of the section [Step]:

 [Step]
 [Step myStep]

Steps may have the following attributes:

action :OPTIONAL

Actions are executed before your own code is executed. In actions, you may assign data to embedded controls by reading out other controls' data or calling their methods.

Multiple actions can be specified using the heredoc syntax. Each action must be terminated by ';'.

Elements of the action syntax are described below.

  • this

    The special control "this" refers to an instance of the current object itself:

     this.mAccount=cAccount.value();

    This corresponds to $self used as a convention in perl classes.

  • Constants

    Numbers without any quotes or text with embraced by ' or ".

     this.mNumericConstant=23;
     this.mStringConstant="Hello World"
  • Variables / Attributes

    Variables can be nested with a '.' as seperator. Each variable must begin with a char A-Z, a-z as first sign. All other chars of the variable name can be A-Z, a-z, _ and 0-9.

     this.mNumericConstant=this.someVariable;
     this.mStringConstant=cControl.anotherVariable2;
  • Methods

    Each method name must begin with a char A-Z, a-z as first sign. All other chars of the variable name can be A-Z, a-z, _ and 0-9.

    Methods can also be called on nested variables if the variable has this method.

Examples:

 ; assignment
 action=<<EOT
 this.mTextAttribute="This is a Constant";
 this.mAnotherText='Another Constant';
 this.mNumber=1234;
 cEmbeddedContainer.mValue=cAnotherContainer.mTest;
 EOT

 ; method call
 action=<<EOT
 this.callMe();
 cEmbeddedContainer.mValue=cAnotherContainer.test();
 EOT

[Step $SOURCE $DESTINATION] - transitions from one step to another

Each Step may have multiple transitions to other steps.

Transitions are written as sub-sections of the source step with the name of the destination step:

 [Step SourceStep DestinationStep]

Transitions may only be performed when a condition is met. If no condition is specified, the transition will be performed automatically.

Transitions may have the following attributes:

condition :OPTIONAL

You may use constants, variables, and method calls in conditions (see actions for more information). You can't make assignments but you may use the following logical operators.

 Operator       Description
 ------------------------------------
 !              Logical not
 not            Not operator
 ==             Numeric equal
 !=             Numeric uneuqal
 eq             String equal
 ne             String unequal
 &&             Logical and
 ||             Logical or
 and            And operator
 or             or operator

Operator precendence is equal to perl - see perlop for details.

Examples:

 [Step One altTwo]
 condition=this.is_valid();

 [Step One altTwo]
 condition=this.is_valid() && cControl.something.is_valid();

CODE GENERATION

use generate-flow.pl to generate a perl class for yout flow control with a shadow class and a basic template.

 hyper.pl -b $BASE_PATH -s $SERVICE -u $USECASE -t flow

The following files will be generated:

if not existant:

 $BASE_PATH/lib/Hyper/Control/Flow/$SERVICE/F$USECASE.pm
 $BASE_PATH/var/Hyper/Control/Flow/$SERVICE/$USECASE.htc

always (previous files will be overwritten):

 $BASE_PATH/lib/Hyper/Control/Flow/$SERVICE/_F$USECASE.pm

YOUR CODE

Each Step will call a method named action_$STEP_NAME if existant.

This methods may gather data from interfaces, perform interface calls etc.

You should place your code and template into

 $BASE_PATH/lib/Hyper/Control/Flow/$SERVICE/F$USECASE.pm
 $BASE_PATH/var/Hyper/Control/Flow/$SERVICE/$USECASE.htc

DEPENDENCIES ^

INCOMPATIBILITIES ^

BUGS AND LIMITATIONS ^

RCS INFORMATIONS ^

Last changed by

$Author: ac0v $

Id

$Id: Flow.pm 317 2008-02-16 01:52:33Z ac0v $

Revision

$Revision: 317 $

Date

$Date: 2008-02-16 02:52:33 +0100 (Sa, 16 Feb 2008) $

HeadURL

$HeadURL: http://svn.hyper-framework.org/Hyper/Hyper/tags/0.05/lib/Hyper/Config/Reader/Flow.pm $

AUTHOR ^

Andreas Specht <ACID@cpan.org>

LICENSE AND COPYRIGHT ^

Copyright (c) 2007, Andreas Specht <ACID@cpan.org>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: