Plexus to Spring Adapter


This library is an adapter to use plexus components in a springframework application context. It translates plexus components descriptors and interfaces to spring to get dependency injection and interface based lifecycle management, with some limitations.


Pexus-spring provides to plexus components :

  • Lifecycle management (creation, initialization, Logger injection and destruction
  • Limited Contextualization using a PlexusContainerAdapter and ContextAdapter
  • Injection of dependencies (using plexus direct field-injection) based on plexus descriptor
  • Injection of configuration, limited to String and simple types

how ?

Plexus-spring defines some custom Spring components :

  • a PlexusBeanDefinitionDocumentReader to translate the plexus component descriptors to spring context XML document (using XSLT)
  • a spring namespace dedicated to plexus, that mimics the plexus component descriptor format
  • a FactoryBean to create and inject dependencies in plexus components
  • a BeanPostProcessor to support plexus lifecycle interfaces in spring context (LogEnabled, Contextualizable, Initializable, Disposable).
  • a PlexusContainerAdapter to support plexus-like lookups in spring context
To make life simplier, plexus-spring also provides a PlexusClassPathXmlApplicationContext that registers all necessary components and accepts either spring or plexus XML files as context locations.

who is using it ?

This adapter library has been created as part of the migration effort from plexus to spring in apache Archiva. It allows a smooth migration from plexus to spring as the initial components can be used as is in spring until they are migrated to be more spring compliant or replaced.

It can also be used to support some plexus components packaged as jars that provide helpfull features to a spring-based application.


Some components use interpolation in the configuration element with some predefined values (plexus.home).

To handle this you have to record a propertyConfigurer Spring bean :

  <bean id="propertyConfigurer" 
    <property name="locations">
    <!-- ignore if not found -->
    <property name="ignoreResourceNotFound">
    <!-- ignore if a interpolated key not exists -->
    <property name="ignoreUnresolvablePlaceholders">


The PlexusServletContextPropertyPlaceholderConfigurer will set a plexus.home value (if not already found in the properties defined in location to File( servletContext.getRealPath( "/WEB-INF" ) ).getAbsolutePath()