Alceu Rodrigues de Freitas Junior > Siebel-Srvrmgr > Siebel::Srvrmgr::Daemon::Action

Download:
Siebel-Srvrmgr-0.14.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Source  

NAME ^

Siebel::Srvrmgr::Daemon::Action - base class for Siebel::Srvrmgr::Daemon action

SYNOPSIS ^

This class must be subclassed and the do method overrided.

An subclass should return true ONLY when was able to identify the type of output received. Beware that the output expected must include also the command executed or the Siebel::Srvrmgr::ListParser object will not be able to identify the type of the output (Siebel::Srvrmgr::Daemon does that).

This can be accomplish using something like this in the do method:

    sub do {

                my $self = shift;
                my $buffer = shift;

                $self->get_parser()->parse($buffer);

                my $tree = $self->get_parser()->get_parsed_tree();

                foreach my $obj ( @{$tree} ) {

                        if ( $obj->isa('Siebel::Srvrmgr::ListParser::Output::MyOutputSubclassName') ) {

                                my $data =  $obj->get_data_parsed();

                # do something

                                return 1;

                        }

                }    # end of foreach block

                return 0;
                
        }

Where MyOutputSubclassName is a subclass of Siebel::Srvrmgr::ListParser::Output.

If this kind of output is not identified and the proper return given, Siebel::Srvrmgr::Daemon can enter in a infinite loop.

ATTRIBUTES ^

parser

A reference to a Siebel::Srvrmgr::ListParser object. This attribute is required during object creation and is read-only.

params

An array reference. params is an optional attribute during the object creation and it is used to pass additional parameters. How those parameters are going to be used is left to who is creating subclasses of Siebel::Srvrmgr::Daemon::Action.

This attribute is read-only.

expected_output

A string telling the expected output type the Siebel::Srvrmgr::Daemon::Action subclass expectes to find. This is a lazy attribute since each subclass may have a different type of expected output.

The string may be anything related to Siebel::Srvrmgr::ListParser::Output subclasses and it will be used for validation during execution of do_parsed method.

METHODS ^

get_parser

Returns the Siebel::Srvrmgr::ListParser object stored into the parser attribute.

get_params

Returns the array reference stored in the params attribute.

do

This method expects to receive a array reference (with the content to be parsed) as parameter and it will do something with it. Usually this should be identify the type of output received, giving it to the proper parse and processing it somehow.

Every do method must return true (1) if output was used, otherwise false (0).

This method does:

parsing of the content of the buffer with the parser returned by get_parser method
invokes the do_parsed method passing the tree returned from the parser
clear the parser with the clear_parsed_tree method.
returns the returned value of the do_parsed method.

do_parsed

This method must be overrided by subclasses or it will die with trace.

It expects an array reference with the parsed tree given by get_parsed_tree of a Siebel::Srvrmgr::ListParser instance.

This method is invoked internally by do method, but is also usable directly if the parsed tree is given as expected.

If the output is used, this method must returns true, otherwise false.

CAVEATS ^

This class may be changed to a role instead of a superclass in the future since it's methods could be used by different classes.

SEE ALSO ^

AUTHOR ^

Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>

This file is part of Siebel Monitoring Tools.

Siebel Monitoring Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Siebel Monitoring Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>.

syntax highlighting: