Chapter 3. Module backend

Table of Contents

3.1. The base module
3.1.1. Module constructor
3.2. Root commands
3.3. EBox::GConfModule
3.4. Ordering stuff
3.5. Controlling a daemon
3.5.1. Configuration file generation
3.5.2. Controlling execution
3.6. gconf schemas
3.6.1. Minimal gconf schema
3.6.2. Default values
3.6.3. Module dependencies
3.7. Backups
3.8. Administrative logging
3.9. Migration scripts

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.

3.1. The base module

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.

3.1.1. Module constructor

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;
}