Table of Contents
The eBox framework offers modules several functionalities that are made available through a mostly object-oriented API. Not everything is object-oriented, procedural interfaces have been used where it made sense to do so.
Some of the features of the API work through inheritance, these usually provide a means for the module to implement standard functionalities like menus, the status page, configuration saving and revoking, etc. Some of these functionalities need to be implemented by the module, others are given by the framework for free, and the module may override or extend them.
All eBox modules inherit from the
EBox::Module
class, this class defines abstract
methods that modules may override to implement certain functionality.
These methods are called by the framework when they are needed.
Besides those abstract methods, the class implements a few methods, providing some basic functionality. These methods often follow the template method design pattern, they perform some operation but delegate some part of it on some abstract method that may be implemented by child classes.
Finally, there are a few methods that implement some common
operations that get used in most of the modules, these are meant to be
called by children classes when they need them. They are located in the
EBox::Module
class just for convenience.
All module instances are created and cached by the
EBox::Global
class, module constructors must
not be called directly except by EBox::Global
.
For this reason, they are named _create
instead of new
.
The leading underscore in the method name is a naming
convention, methods with such a name are meant to be used
privately by the owner class and its ancestors, they should
not be called directly by an unrelated class. In the case of
the module constructor, the only class that should call it is
EBox::Global
.
The _create
method in
EBox::Module
takes two named arguments
from the child classes. name
is the name
of the module, it is required; domain
is
the gettext domain for the module, it's
optional and “ebox” is its default value.
Example 3.1. Simple module constructor
sub _create { my $class = shift; my $self = $class->SUPER::_create(name => 'dhcp', domain => 'ebox-dhcp', @_); bless ($self, $class); return $self; }