JMX::Jmx4Perl::Alias::Object - Internal object representing a concrete alias


jmx4perl documentation Contained in the jmx4perl distribution.

Index


Code Index:

NAME

Top

JMX::Jmx4Perl::Alias::Object - Internal object representing a concrete alias

DESCRIPTION

Top

Simple object which describes an alias. It knows about the following read-only methods

$alias->alias()

alias name in uppercase form (e.g. MEMORY_HEAP_USED)

$alias->name()

alias name in lowercase format (e.g. memory:heap:used)

$alias->description()

short description of the alias

$alias->default()

default values for an alias, which can be overwritten by a specific JMX::Jmx4Perl::Product::BaseHandler. This is an arrayref with two values: The MBean's name and the attribute or operation name.

$alias->type()

Either attribute or operation, depending on what kind of MBean part the alias stands for.

Additional, the "", == and != operators are overloaded to naturally compare and stringify alias values.

LICENSE

Top

This file is part of jmx4perl.

Jmx4perl 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 2 of the License, or (at your option) any later version.

jmx4perl 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 jmx4perl. If not, see <http://www.gnu.org/licenses/>.

A commercial license is available as well. Please contact roland@cpan.org for further details.

PROFESSIONAL SERVICES

Top

Just in case you need professional support for this module (or Nagios or JMX in general), you might want to have a look at http://www.consol.com/opensource/nagios/. Contact roland.huss@consol.de for further information (or use the contact form at http://www.consol.com/contact/)

AUTHOR

Top

roland@cpan.org


jmx4perl documentation Contained in the jmx4perl distribution.
package  JMX::Jmx4Perl::Alias::Object;

use Scalar::Util qw(refaddr);

use overload
    q{""} => sub { (shift)->as_string(@_) },
    q{==} => sub { (shift)->equals(@_) },
    q{!=} => sub { !(shift)->equals(@_) };

sub equals { 
    return (ref $_[0] eq ref $_[1] && refaddr $_[0] == refaddr $_[1]) ? 1 : 0;
}

sub new { 
    my $class = shift;
    return bless { @_ },ref($class) || $class;
}

sub as_string { return $_[0]->{alias}; }
sub alias { return shift->{alias}; }
sub name { return shift->{name}; }
sub description { return shift->{description}; }
sub default { return shift->{default}; }
sub type { return shift->{type}; }

1;