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

NAME

PXP - Perl Xtensions & Plugins

SYNOPSIS

 use PXP;
 PXP::init();

DESCRIPTION

This module provides a generic plugin framework, similar to the Eclipse model. It has been developed for the IMC project (see http://www.idealx.org/prj/imc) and is now released as an autonomous CPAN module.

Definitions

A "plugin" is a common design pattern found in many modern software frameworks. However, plugins sometimes refer to just a loadable binary library or require inheriting from a base class with the disadvantage of additional coupling.

In the PXP model, plugins and extensions have a particular definition:

plugin

A plugin is a packaged set of software components that extend a system or provide extension points for other components.

A plugin may contain extensions, extension points, and the configuration nodes (XML) related to these components.

A plugin can also contain other files, like CPAN modules, PAR (Perl ARchive) modules, HTML templates, icons, etc.

A plugin is described by a 'plugin.xml' descriptor file. See the example below.

extension point

An extension-point defines (as its name says!) an extension point for extending a system with extension components.

For example, an extension point with id='MainMenu' could group together many extensions, each one adding one or multiple menu entries to the 'MainMenu' extension point.

Another example: an id='HttpPipeline' extension-point could be used to build a pipeline of individual handlers that act together on a HTTP::Request object to analyze and respond to a browser query. Each stage of the pipeline could be registered in the 'HttpPipeline' extension point to actually call a subroutine as the request is processed.

In fact, these examples are really implemented in the IMC platform. See http://imc.sourceforge.net/ for more details.

This definition of an extension point illustrates the fact that an extension-point can be just a static hash of datas (menus) or can also instantiate objects and execute code contained in extensions, as in the pipeline example.

Also note, that the PXP framwework does not mandate any specific behaviour for an extension-point : a dummy extension-point can just 'forget' about any extension that tries to register to it.

extension

An extension in the PXP model is what other frameworks usually call a 'plugin'.

An extension represents a component that extends the system.

It can be a piece of data (remember the menu example above), or it can contain a part of code, or a class definition.

It is also commonly used to describe, configure and trigger the creation of object instances, in coordination with an extension point.

Annotated 'plugin.xml' example

<?xml version="1.0"?>

Every plugin descriptor is an XML file containing one <plugin> definition.

<plugin id="IMC::WebApp::TestPlugin" name="Test plugin" version="0.1" provider-name='IDEALX'>

The 'id' is an arbitraty ID, and is not necessarily related to a Perl object, class, or instance. However, if a class by the same name exists under the directory containing the plugin descriptor, then this class is loaded (require-ed) and its startup() method is called.

An optional 'class' overrides the 'id' attribute for loading the class by name.

Other attributes, like 'name', 'version' or 'provider-name' are purely informational.

  <require plugin='IMC::Core'/>

The <require> tag defines dependencies between plugins. The PluginRegistry will take care of resolving these dependencies in advance, so that dependent plugins are loaded and startup()'ed before the requiring plugin.

  <runtime>
    <library name="Crypt-SmbHash-0.02-i386-linux-thread-multi-5.8.3.par"/>
  </runtime>

The <runtime> tag loads additional libraries in the system. Each library to load is defined by an sub <library> tag. The 'name' attribute points to the PAR archive containing the bundled library. The path is relative to the directory containing the 'plugin.xml' descriptor file.

  <extension-point
    id='IMC::MainPipeline'
    name='Main Pipeline Extension-Point'/>

An <extension-point> tag defines a new extension-point in the system registry. The 'name' attribute is only informational.

  <extension 
    id='IMC::SessionLoader'
    name='Session Loader Extension'
    point="IMC::MainPipeline"/>

An <extension> tag defines an extension. By default, the PluginRegistry will not do anything special with an extension. It will just pass it to the target extension-point.

It is the ExtensionPoint that will decide what to do with the extension definition. A default ExtensionPointBaseClass provides a simple implementation that creates class instances by 'id' or 'class' and stores the resulting extension in a hash table.

</plugin>

SEE ALSO

PXP::PluginRegistry, PXP::ExtensionPoint, PXP::Extension

See the article on eclipse.org describing the plugin architecture : http://www.eclipse.org/articles/Article-Plug-in-architecture/plugin_architecture.html

AUTHORS

David Barth <dbarth@idealx.com>

Aurélien Degrémont <adegremont@idealx.com>

Gérald Macinenti <gmacinenti@idealx.com>

COPYRIGHT AND LICENSE

Copyright (C) 2005 - dbarth@idealx.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 175:

Non-ASCII character seen before =encoding in 'Aurélien'. Assuming UTF-8