Component Module

Version 3.1 by Vincent Massol on 2009/08/20 22:19

Component Module

XWiki's Architecture is based on Component-oriented Development (see also this Plexus Component Tutorial to understand the benefits of using Components).

There are several Component Manager solutions out there for Java. To name a few:

XWiki has chosen to be independent of all existing Components Managers and instead to define some simple Component interfaces that can then be bound on any existing Component Manager. XWiki is currently implementing its own lightweight Component Manager with the idea to implement a Guice bridge as soon as Guice starts implementing JSR299/JSR330 annotations.

Features

The Component Module defines the following features:

  • Annotations to declare Component interfaces, Component implementations and Component dependencies (a.k.a as Component Requireements). Note that as soon as JSR299/JSR330 become official we'll drop our annotations and use these instead.
  • Ability to have Singleton Components and Per-lookup Components (a new instance is created when the component is retrieved)
  • Ability to define a Hint to separate different Components implementations implementing the same Component interface.
  • Automatic Field-based injection of Component Dependencies.
  • Ability for Components to perform some initialization when they are instantiated.
  • Ability for Components to log things.
  • Component Events to be notified when a new Component is registered/unregistered in the system
  • [Future] Ability to define Component Realms, i.e. the ability to isolate groups of components. 

Component Registration

TODO:

  • annotations
  • components.txt
  • components-overrides.txt
  • programatically using the CM

Component Initialization

This is done by implementing the org.xwiki.component.phase.Initializable interface. For example:

TODO

Component Logging

TODO

Tutorial

See the "Writing a XWiki Component" tutorial.

Get Connected