The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

POE::Component::StackedProcessor - Stack Processors In POE

SYNOPSIS

  use POE::Component::StackedProcessor;
  POE::Component::StackedProcessor->new(
    Alias      => $alias,
    Processors => [ $proc1, $proc2, $proc3 ],
    OnSuccess  => \&callback,
    OnFailure  => \&callback,
    ProcessorArgs => [ $foo, $bar, $baz ],
  );
  POE::Kernel->run();

DESCRIPTION

POE::Component::StackedProcessor allows you to build a chain of processors whose dispatching depends on the successful completion of the previous processor.

For example, suppose you have an HTML document that requires you to verify whethere it meats certain criteria such as proper markup, valid links, etc.

All you need to do is to create objects that have a method "process", and then you can invoke this from the stacked processor.

  package CheckMarkup;
  sub new { ... }
  sub process { ... }

  package ValidateLinks;
  sub new { ... }
  sub process { ... }

  package main;
  my $cm = CheckMarkup->new;
  my $vl = ValidateLink->new;
  POE::Component::StackedProcessor->new(
    Processors => [ $cm, $vl ],
  );

Normally this would be done in one pass for the sake of efficiency, but sometimes you want to break these steps up into several components such that you can mix and match the differnt processors as required.

METHOD

new ARGS

Processors

An arrayref of processor objects. Each of these object must have a method denoted by "callback_name" (which is by default "process")

ProcessArgs

An arrayref of arguments that should be passed to the processors.

OnSuccess / OnFailure

Specify a callback to be executed on completion of processing. You must pass a reference to a code ref.

If you want events to be posted to a session or such, pass a postback code

  POE::Component::StackedProcessor->new(
    OnSuccess => $session->postback('my event')
  );

callback_name

This is a class-method to specify at run time what method name should be called on the processor objects. The default is "process".

SEE ALSO

POE

AUTHOR

Daisuke Maki <daisuke@cpan.org>