Index: main/plugin-user-directory/src/org/ametys/plugins/userdirectory/component/PopulationManager.java
===================================================================
--- main/plugin-user-directory/src/org/ametys/plugins/userdirectory/component/PopulationManager.java	(revision 40174)
+++ main/plugin-user-directory/src/org/ametys/plugins/userdirectory/component/PopulationManager.java	(working copy)
@@ -22,9 +22,14 @@
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.components.LifecycleHelper;
 
 import org.ametys.cms.contenttype.ContentType;
 import org.ametys.cms.contenttype.ContentTypeExtensionPoint;
@@ -34,7 +39,7 @@
 /**
  * The population manager
  */
-public class PopulationManager implements Configurable, Serviceable, Component
+public class PopulationManager extends AbstractLogEnabled implements Configurable, Serviceable, Component, Contextualizable
 {
     /** The Avalon role */
     public static final String ROLE = PopulationManager.class.getName();
@@ -45,11 +50,20 @@
     /** The content type extension point */
     protected ContentTypeExtensionPoint _cTypeEP;
 
+    /** The context */
+    protected Context _context;
+    
     private Map<String, Population> _populations; 
     
     private boolean _initialized;
         
     @Override
+    public void contextualize(Context context) throws ContextException
+    {
+        _context = context;
+    }
+    
+    @Override
     public void service(ServiceManager manager) throws ServiceException
     {
         _serviceManager = manager;
@@ -78,8 +92,7 @@
                 if (object instanceof Population)
                 {
                     Population population = (Population) object;
-                    population.initialize(_serviceManager);
-                    population.configure(populationConf);
+                    LifecycleHelper.setupComponent(population, getLogger(), _context, _serviceManager, populationConf);
                     _populations.put(populationId, population);
                 }
                 else
@@ -99,6 +112,10 @@
             {
                 throw new ConfigurationException(String.format("Illegal access to class class %s for population of id '%s'", populationClass, populationId), populationConf);
             }
+            catch (Exception e)
+            {
+                throw new ConfigurationException(String.format("Unable to set up the population %s of id '%s' as a component", populationClass, populationId), populationConf);
+            }
         }
         
     }
Index: main/plugin-user-directory/src/org/ametys/plugins/userdirectory/population/AbstractPopulation.java
===================================================================
--- main/plugin-user-directory/src/org/ametys/plugins/userdirectory/population/AbstractPopulation.java	(revision 40174)
+++ main/plugin-user-directory/src/org/ametys/plugins/userdirectory/population/AbstractPopulation.java	(working copy)
@@ -24,11 +24,17 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
 import org.apache.commons.lang.StringUtils;
 
 import org.ametys.cms.contenttype.ContentType;
@@ -68,7 +74,7 @@
 /**
  * An abstract {@link Population}.<br>
  */
-public abstract class AbstractPopulation implements Population
+public abstract class AbstractPopulation implements Population, Serviceable, Contextualizable, Configurable, Component
 {
     private static final int __VALIDATION_ACTION_ID = 41;
     
@@ -88,12 +94,40 @@
     protected boolean _sourcePrevails;
     /** The population bo source */
     protected boolean _isBOSource;
+    /** The context */
+    protected Context _context;
+    /** The language manager */
+    protected LanguagesManager _languagesManager;
+    /** The ametys object resolver */
+    protected AmetysObjectResolver _resolver;
+    /** The content type extension point */
+    protected ContentTypeExtensionPoint _contentTypeEP;
+    /** The workflow manager */
+    protected Workflow _workflowManager;
+    /** The observation manager */
+    protected ObservationManager _observationManager;
+    /** The current user provider */
+    protected CurrentUserProvider _currentUserProvider;
+    /** The user directory page handler */
+    protected UserDirectoryPageHandler _udPageHangler;
+    /** The service manager */
+    protected ServiceManager _serviceManager;
     
-    private ServiceManager _serviceManager;
+    
+    public void contextualize(Context context) throws ContextException
+    {
+        _context = context;
+    }
     
     @Override
-    public void initialize(ServiceManager serviceManager)
+    public void service(ServiceManager serviceManager) throws ServiceException
     {
+        _languagesManager = (LanguagesManager) serviceManager.lookup(LanguagesManager.ROLE);
+        _resolver = (AmetysObjectResolver) serviceManager.lookup(AmetysObjectResolver.ROLE);
+        _contentTypeEP = (ContentTypeExtensionPoint) serviceManager.lookup(ContentTypeExtensionPoint.ROLE);
+        _workflowManager = (Workflow) serviceManager.lookup(Workflow.ROLE);
+        _observationManager = (ObservationManager) serviceManager.lookup(ObservationManager.ROLE);
+        _currentUserProvider = (CurrentUserProvider) serviceManager.lookup(CurrentUserProvider.ROLE);
         _serviceManager = serviceManager;
     }
     
@@ -360,18 +394,9 @@
      */
     protected void importContent(String contentName, String contentTypeId, String workflowName, int initialActionId, Map<String, List<Object>> remoteValues, Logger logger, SyncReport syncReport)
     {
-        try
-        {
-            LanguagesManager languagesManager = (LanguagesManager) _serviceManager.lookup(LanguagesManager.ROLE);
-            for (String lang : languagesManager.getAvailableLanguages().keySet())
-            {
-                importContent(lang, contentName, contentTypeId, workflowName, initialActionId, remoteValues, logger, syncReport);
-            }
-        }
-        catch (ServiceException e)
+        for (String lang : _languagesManager.getAvailableLanguages().keySet())
         {
-            syncReport.incrementNbError();
-            logger.error("An error occurred during lookup web language manager", e);
+            importContent(lang, contentName, contentTypeId, workflowName, initialActionId, remoteValues, logger, syncReport);
         }
     }
     
@@ -392,13 +417,9 @@
         {
             long time_0 = System.currentTimeMillis();
             
-            AmetysObjectResolver resolver = (AmetysObjectResolver) _serviceManager.lookup(AmetysObjectResolver.ROLE);
-            
-            ContentTypeExtensionPoint contentTypeEP = (ContentTypeExtensionPoint) _serviceManager.lookup(ContentTypeExtensionPoint.ROLE);
-            
-            ContentType cType = contentTypeEP.getExtension(contentType);
+            ContentType cType = _contentTypeEP.getExtension(contentType);
     
-            SynchronizableContent content = getContent(lang, contentName, contentType, resolver);
+            SynchronizableContent content = getContent(lang, contentName, contentType);
             if (content == null)
             {
                 if (logger.isInfoEnabled())
@@ -408,7 +429,7 @@
                 
                 // Content does not exist, create it
                 String contentId = createContentAction(lang, contentName, contentType, workflowName, actionId, logger, syncReport);
-                content = resolver.resolveById(contentId);
+                content = _resolver.resolveById(contentId);
                 syncReport.incrementNbContentCreated();
                 
                 synchronizeContent(getPopulationMapping(), remoteValues, cType, content, logger, syncReport);
@@ -470,13 +491,12 @@
      * @param lang the language
      * @param contentName the content name
      * @param contentType the content type
-     * @param resolver the resolver
      * @return the content in the repository (null if no exist)
      */
-    protected SynchronizableContent getContent(String lang, String contentName, String contentType, AmetysObjectResolver resolver)
+    protected SynchronizableContent getContent(String lang, String contentName, String contentType)
     {
         String xPathQuery = UserContentHelper.getContentPathQuery(this, lang, contentName, contentType);
-        AmetysObjectIterable<SynchronizableContent> contents = resolver.query(xPathQuery);
+        AmetysObjectIterable<SynchronizableContent> contents = _resolver.query(xPathQuery);
         
         if (contents.hasNext())
         {
@@ -504,11 +524,9 @@
         {
             logger.debug("Create content " + contentName + " with lang " + lang);
         }
-        Workflow workflowManager;
+        
         try
         {
-            workflowManager = (Workflow) _serviceManager.lookup(Workflow.ROLE);
-            
             Map<String, Object> inputs = new HashMap<String, Object>();
             
             inputs.put(CreateContentFunction.CONTENT_LANGUAGE_KEY, lang);
@@ -519,7 +537,7 @@
             Map<String, Object> results = new HashMap<String, Object>();
             inputs.put(AbstractContentWorkflowComponent.RESULT_MAP_KEY, results);
             
-            workflowManager.initialize(workflowName, actionId, inputs);
+            _workflowManager.initialize(workflowName, actionId, inputs);
 
             @SuppressWarnings("unchecked")
             Map<String, Object> workflowResult = (Map<String, Object>) inputs.get(AbstractContentWorkflowComponent.RESULT_MAP_KEY);
@@ -531,12 +549,6 @@
             logger.error("An error occurred with the workflow", e);
             return null;
         }
-        catch (ServiceException e)
-        {
-            syncReport.incrementNbError();
-            logger.error("An error occurred during lookup workflow component", e);
-            return null;
-        }
     }
     
     /**
@@ -750,19 +762,15 @@
     {
         try
         {
-            Workflow workflow = (Workflow) _serviceManager.lookup(Workflow.ROLE);
-            ObservationManager observationManager = (ObservationManager) _serviceManager.lookup(ObservationManager.ROLE);
-            CurrentUserProvider currentUserProvider = (CurrentUserProvider) _serviceManager.lookup(CurrentUserProvider.ROLE);
-
             ((ModifiableContent) content).setLastModified(new Date());
             content.saveChanges();
             
             ((VersionableAmetysObject) content).checkpoint();
             
             // Notify observers that the content has been modified
-            observationManager.notify(new Event(currentUserProvider.getUser(), ObservationConstants.CONTENT_MODIFIED, content));
+            _observationManager.notify(new Event(_currentUserProvider.getUser(), ObservationConstants.CONTENT_MODIFIED, content));
 
-            if (content.isLocked() && !LockHelper.isLockOwner(content, currentUserProvider.getUser()))
+            if (content.isLocked() && !LockHelper.isLockOwner(content, _currentUserProvider.getUser()))
             {
                 logger.warn("Can't apply changes because content " + content.getTitle() + " is locked");
                 return;
@@ -772,11 +780,11 @@
             inputs.put(AbstractContentWorkflowComponent.RESULT_MAP_KEY, new HashMap<String, Object>());
             inputs.put(AbstractContentWorkflowComponent.CONTENT_KEY, content);
 
-            Step currentStep = (Step) workflow.getCurrentSteps(content.getWorkflowId()).iterator().next();
+            Step currentStep = (Step) _workflowManager.getCurrentSteps(content.getWorkflowId()).iterator().next();
             int currentStepId = currentStep.getStepId();
             
             String actionId = "8" + currentStepId + "0";
-            workflow.doAction(content.getWorkflowId(), Integer.valueOf(actionId), inputs);
+            _workflowManager.doAction(content.getWorkflowId(), Integer.valueOf(actionId), inputs);
         }
         catch (WorkflowException e)
         {
@@ -788,11 +796,6 @@
             syncReport.incrementNbError();
             logger.error(String.format("Unable to update workflow of content %s (%s)", content.getTitle(), content.getId()));
         }
-        catch (ServiceException e)
-        {
-            syncReport.incrementNbError();
-            logger.error("An error occurred during lookup components");
-        }
     }
     
     /**
@@ -815,8 +818,7 @@
                 
         try
         {
-            Workflow workflow = (Workflow) _serviceManager.lookup(Workflow.ROLE);
-            workflow.doAction(content.getWorkflowId(), __VALIDATION_ACTION_ID, inputs);
+            _workflowManager.doAction(content.getWorkflowId(), __VALIDATION_ACTION_ID, inputs);
            
             if (logger.isInfoEnabled())
             {
@@ -837,11 +839,6 @@
                 logger.info(String.format("The content %s (%s) can not be validated after import", content.getTitle(), content.getId()));
             }
         }
-        catch (ServiceException e)
-        {
-            report.incrementNbError();
-            logger.error("An error occurred during lookup components");
-        }
     } 
     
     /**
@@ -853,24 +850,22 @@
     {
         try
         {
-            CurrentUserProvider currentUserProvider = (CurrentUserProvider) _serviceManager.lookup(CurrentUserProvider.ROLE);
-            ObservationManager observationManager = (ObservationManager) _serviceManager.lookup(ObservationManager.ROLE);
-            UserDirectoryPageHandler udPageHangler = (UserDirectoryPageHandler) _serviceManager.lookup(UserDirectoryPageHandler.ROLE);
-
+            _udPageHangler = (UserDirectoryPageHandler) _serviceManager.lookup(UserDirectoryPageHandler.ROLE);
             // Clear virtual page cache
-            udPageHangler.clearAllCache();
+            _udPageHangler.clearAllCache();
             
-            Set<Page> udRootPages = udPageHangler.getUserDirectoryRootPages (this.getId());
+            Set<Page> udRootPages = _udPageHangler.getUserDirectoryRootPages (this.getId());
             for (Page rootPage : udRootPages)
             {
-                observationManager.notify(new Event(currentUserProvider.getUser(), org.ametys.web.ObservationConstants.PAGE_CHANGED, rootPage, new Object[]{rootPage.getId()}));
+                _observationManager.notify(new Event(_currentUserProvider.getUser(), org.ametys.web.ObservationConstants.PAGE_CHANGED, rootPage, new Object[]{rootPage.getId()}));
             }
         }
         catch (ServiceException e)
         {
             syncReport.incrementNbError();
-            logger.error("An error occurred during lookup components");
+            logger.error("An error occurred during lookup components", e);
         }
+        
     }
     
     /**
@@ -884,40 +879,30 @@
         {
             String xPathQuery = UserContentHelper.getContentPathQuery(this, null, null, null);
             
-            AmetysObjectResolver resolver;
-            try
+            AmetysObjectIterable<ModifiableDefaultContent> it = _resolver.query(xPathQuery);
+            
+            while (it.hasNext())
             {
-                resolver = (AmetysObjectResolver) _serviceManager.lookup(AmetysObjectResolver.ROLE);
-                AmetysObjectIterable<ModifiableDefaultContent> it = resolver.query(xPathQuery);
+                ModifiableDefaultContent content = it.next();
+                String idMetadataPath = getPopulationMapping().getId();
                 
-                while (it.hasNext())
+                String[] pathSegments = idMetadataPath.split("/");
+                
+                ModifiableCompositeMetadata metadataHolder = content.getMetadataHolder();
+                
+                for (int i = 0;  i < pathSegments.length - 1; i++)
                 {
-                    ModifiableDefaultContent content = it.next();
-                    String idMetadataPath = getPopulationMapping().getId();
-                    
-                    String[] pathSegments = idMetadataPath.split("/");
-                    
-                    ModifiableCompositeMetadata metadataHolder = content.getMetadataHolder();
-                    
-                    for (int i = 0;  i < pathSegments.length - 1; i++)
-                    {
-                        metadataHolder = metadataHolder.getCompositeMetadata(pathSegments[i], true);
-                    }
-                    
-                    String metadataName = pathSegments[pathSegments.length - 1];
-                    
-                    if (!syncReport.isHandled(metadataHolder.getString(metadataName)))
-                    {
-                        content.remove();
-                        content.saveChanges();
-                        syncReport.incrementNbContentDeleted();
-                    }
+                    metadataHolder = metadataHolder.getCompositeMetadata(pathSegments[i], true);
                 }
-            }
-            catch (ServiceException e)
-            {
-                syncReport.incrementNbError();
-                logger.error("An error occurred during lookup ametys object resolver component");
+                
+                String metadataName = pathSegments[pathSegments.length - 1];
+                
+                if (!syncReport.isHandled(metadataHolder.getString(metadataName)))
+                {
+                    content.remove();
+                    content.saveChanges();
+                    syncReport.incrementNbContentDeleted();
+                }
             }
         }
     }
Index: main/plugin-user-directory/src/org/ametys/plugins/userdirectory/population/Population.java
===================================================================
--- main/plugin-user-directory/src/org/ametys/plugins/userdirectory/population/Population.java	(revision 40174)
+++ main/plugin-user-directory/src/org/ametys/plugins/userdirectory/population/Population.java	(working copy)
@@ -21,7 +21,6 @@
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.service.ServiceManager;
 
 import org.ametys.plugins.repository.RepositoryConstants;
 import org.ametys.plugins.userdirectory.synchronize.SyncReport;
@@ -97,10 +96,4 @@
      * @throws ConfigurationException if an error occurred
      */
     void configure(Configuration configuration) throws ConfigurationException;
-    
-    /**
-     * Initialize service manager
-     * @param serviceManager the service manager
-     */
-    void initialize(ServiceManager serviceManager);
 }
