Index: /extensions/jiwigo/trunk/.classpath
===================================================================
--- /extensions/jiwigo/trunk/.classpath	(revision 9920)
+++ /extensions/jiwigo/trunk/.classpath	(revision 9921)
@@ -1,27 +1,31 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/>
-	<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
-	<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
-	<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
-	<classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar"/>
-	<classpathentry kind="var" path="M2_REPO/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar"/>
-	<classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"/>
-	<classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.2/commons-codec-1.2.jar"/>
-	<classpathentry kind="var" path="M2_REPO/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5.jar"/>
-	<classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/net/iharder/filedrop/1.0/filedrop-1.0.jar"/>
-	<classpathentry kind="var" path="M2_REPO/com/jhlabs/filters/2.0.235/filters-2.0.235.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/jdom/jdom/1.1/jdom-1.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar"/>
-	<classpathentry kind="var" path="M2_REPO/logkit/logkit/1.0.1/logkit-1.0.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/com/drew/metadata-extractor/2.3.1/metadata-extractor-2.3.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/apache/sanselan/sanselan/0.97-incubator/sanselan-0.97-incubator.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/swinglabs/swing-worker/1.1/swing-worker-1.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/swinglabs/swingx/1.6.1/swingx-1.6.1.jar"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-openjdk"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/jiwigo-ws-api"/>
-	<classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/net/iharder/filedrop/1.0/filedrop-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/jhlabs/filters/2.0.235/filters-2.0.235.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient/4.1/httpclient-4.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.jar"/>
+  <classpathentry kind="src" path="/jiwigo-ws-api"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar"/>
+  <classpathentry kind="var" path="M2_REPO/logkit/logkit/1.0.1/logkit-1.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/drew/metadata-extractor/2.3.1/metadata-extractor-2.3.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/sanselan/sanselan/0.97-incubator/sanselan-0.97-incubator.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-asm/3.0.5.RELEASE/spring-asm-3.0.5.RELEASE.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-beans/3.0.5.RELEASE/spring-beans-3.0.5.RELEASE.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-core/3.0.5.RELEASE/spring-core-3.0.5.RELEASE.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/swinglabs/swing-worker/1.1/swing-worker-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/swinglabs/swingx/1.6.1/swingx-1.6.1.jar"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-openjdk"/>
 </classpath>
Index: /extensions/jiwigo/trunk/pom.xml
===================================================================
--- /extensions/jiwigo/trunk/pom.xml	(revision 9920)
+++ /extensions/jiwigo/trunk/pom.xml	(revision 9921)
@@ -31,4 +31,19 @@
 	    <version>0.2b</version>
 	</dependency>
+	<dependency>
+	    <groupId>org.slf4j</groupId>
+	    <artifactId>slf4j-log4j12</artifactId>
+	    <version>1.6.1</version>
+	</dependency>
+<!--	<dependency>-->
+<!--	    <groupId>org.jdom</groupId>-->
+<!--	    <artifactId>jdom</artifactId>-->
+<!--	    <version>1.1</version>-->
+<!--	</dependency>-->
+	<dependency>
+	    <groupId>org.springframework</groupId>
+	    <artifactId>spring-beans</artifactId>
+	    <version>3.0.5.RELEASE</version>
+	</dependency>
 
   </dependencies>
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/Main.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/Main.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/Main.java	(revision 9921)
@@ -8,5 +8,4 @@
 import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
 
-import fr.mael.jiwigo.transverse.session.SessionManager;
 import fr.mael.jiwigo.transverse.util.Tools;
 import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
@@ -39,5 +38,5 @@
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-   
+
  * Main class
  * @author mael
@@ -50,9 +49,4 @@
      */
     public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(Main.class);
-    /**
-     * The login and session manager that allows to connect to
-     * the webservice and to query it
-     */
-    public static SessionManager sessionManager;
 
     /**
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/ImagesManagement.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/ImagesManagement.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/ImagesManagement.java	(revision 9921)
@@ -9,9 +9,8 @@
 import javax.imageio.ImageIO;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.om.Image;
-import fr.mael.jiwigo.service.ImageService;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
 import fr.mael.jiwigo.transverse.util.Tools;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 
 /**
@@ -154,5 +153,5 @@
 	if (!image.getIdCategory().equals(currentCategory)) {
 	    try {
-		listImage = ImageService.getInstance(Main.sessionManager).listByCategory(image.getIdCategory(), true);
+		listImage = SpringUtils.getImageService().listByCategory(image.getIdCategory(), true);
 		currentCategory = image.getIdCategory();
 	    } catch (IOException e) {
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/util/preferences/PreferencesManagement.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/util/preferences/PreferencesManagement.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/util/preferences/PreferencesManagement.java	(revision 9921)
@@ -5,8 +5,6 @@
 import java.io.IOException;
 
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.input.SAXBuilder;
-import org.jdom.output.XMLOutputter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 import fr.mael.jiwigo.transverse.util.Tools;
@@ -37,5 +35,5 @@
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-   
+
  * Classe de gestion des preferences
  * @author mael
@@ -93,8 +91,7 @@
      */
     public static String getValue(String key) {
-	SAXBuilder sxb = new SAXBuilder();
 	try {
-	    Document document = sxb.build(new File(getConfigFilePath()));
-	    return document.getRootElement().getChildText(key);
+	    Document document = Tools.readFileAsDocument(getConfigFilePath());
+	    return Tools.getStringValueDom(document.getDocumentElement(), key);
 	} catch (Exception e) {
 	    LOG.error(Tools.getStackTrace(e));
@@ -109,19 +106,15 @@
      */
     public static void setValue(String key, String text) {
-	SAXBuilder sxb = new SAXBuilder();
 	try {
-	    Document document = sxb.build(new File(getConfigFilePath()));
+	    Document document = Tools.readFileAsDocument(getConfigFilePath());
 	    try {
-		document.getRootElement().getChild(key).setText(text);
-	    } catch (NullPointerException e) {
-		Element element = new Element(key);
-		element.addContent(text);
-		document.getRootElement().addContent(element);
+		Tools.setStringValueDom(document.getDocumentElement(), key, text);
+	    } catch (Exception e) {
+		e.printStackTrace();
+		Element element = document.createElement(key);
+		Tools.setStringValueDom(element, key, text);
+		document.getDocumentElement().appendChild(element);
 	    }
-	    XMLOutputter out = new XMLOutputter();
-	    FileWriter writer = new FileWriter(getConfigFilePath());
-	    out.output(document, writer);
-	    writer.flush();
-	    writer.close();
+	    Tools.writeXmlFile(document, getConfigFilePath());
 	} catch (Exception e) {
 	    LOG.error(Tools.getStackTrace(e));
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/util/spring/SpringUtils.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/util/spring/SpringUtils.java	(revision 9921)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/util/spring/SpringUtils.java	(revision 9921)
@@ -0,0 +1,91 @@
+package fr.mael.jiwigo.transverse.util.spring;
+
+import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import fr.mael.jiwigo.service.CategoryService;
+import fr.mael.jiwigo.service.CommentService;
+import fr.mael.jiwigo.service.ImageService;
+import fr.mael.jiwigo.service.TagService;
+import fr.mael.jiwigo.transverse.session.SessionManager;
+
+public class SpringUtils {
+
+    /**
+     * Id of the image service bean
+     */
+    private static String IMAGE_SERVICE = "imageService";
+    /**
+     * Id of the tag service bean
+     */
+    private static String TAG_SERVICE = "tagService";
+    /**
+     * Id of the category service bean
+     */
+    private static String CATEGORY_SERVICE = "categoryService";
+    /**
+     * Id of the comment service bean
+     */
+    private static String COMMENT_SERVICE = "commentService";
+
+    private static String SESSION_MANAGER = "sessionManager";
+
+    /**
+     * bean factory
+     */
+    private static XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("application-context.xml"));
+
+    private SpringUtils() {
+    }
+
+    /**
+     * @return the image service
+     */
+    public static ImageService getImageService() {
+	return (ImageService) factory.getBean(IMAGE_SERVICE);
+    }
+
+    /**
+     * @return the tag service
+     */
+    public static TagService getTagService() {
+	return (TagService) factory.getBean(TAG_SERVICE);
+    }
+
+    /**
+     * @return the comment service
+     */
+    public static CommentService getCommentService() {
+	return (CommentService) factory.getBean(COMMENT_SERVICE);
+    }
+
+    /**
+     * @return the category service
+     */
+    public static CategoryService getCategoryService() {
+	return (CategoryService) factory.getBean(CATEGORY_SERVICE);
+    }
+
+    /**
+     * @return the session manager
+     */
+    public static SessionManager getSessionManager() {
+	return (SessionManager) factory.getBean(SESSION_MANAGER);
+    }
+
+    //    public static void main(String[] args) {
+    //	try {
+    //	    SessionManager sessionManager = getSessionManager();
+    //	    sessionManager.setLogin("mael");
+    //	    sessionManager.setUrl("http://mael.piwigo.com/ws.php");
+    //	    sessionManager.setPassword("motdepasse");
+    //	} catch (IOException e) {
+    //	    // TODO Auto-generated catch block
+    //	    e.printStackTrace();
+    //	} catch (ProxyAuthenticationException e) {
+    //	    // TODO Auto-generated catch block
+    //	    e.printStackTrace();
+    //	}
+    //    }
+
+}
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/ConnexionDialog.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/ConnexionDialog.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/ConnexionDialog.java	(revision 9921)
@@ -36,4 +36,5 @@
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 
 /**
@@ -116,4 +117,6 @@
      */
     private ProxyPanel proxyPanel;
+
+    private SessionManager sessionManager;
 
     /**
@@ -184,4 +187,7 @@
 	comboLocales.setModel(model);
 	model.setSelectedItem(defautLocale.getDisplayLanguage(Locale.ENGLISH));
+
+	this.sessionManager = SpringUtils.getSessionManager();
+
 	this.getContentPane().add(panelInformations, BorderLayout.NORTH);
 	this.getContentPane().add(proxyPanel, BorderLayout.CENTER);
@@ -208,5 +214,7 @@
 	    }
 	    //instanciation of the session manager
-	    Main.sessionManager = new SessionManager(loginField.getText(), passwordField.getText(), fieldUrl.getText());
+	    sessionManager.setLogin(loginField.getText());
+	    sessionManager.setPassword(passwordField.getText());
+	    sessionManager.setUrl(fieldUrl.getText() + "/ws.php");
 	    boolean echecProxy = false;
 	    if (proxyPanel.getCheckBox().isSelected()) {
@@ -214,9 +222,9 @@
 		try {
 		    portProxy = Integer.valueOf(proxyPanel.getFieldPort().getText());
-		    Main.sessionManager.setPortProxy(portProxy);
-		    Main.sessionManager.setUrlProxy(proxyPanel.getFieldUrl().getText());
-		    Main.sessionManager.setLoginProxy(proxyPanel.getFieldLogin().getText());
-		    Main.sessionManager.setPassProxy(proxyPanel.getFieldPassword().getText());
-		    Main.sessionManager.setUsesProxy(true);
+		    sessionManager.setPortProxy(portProxy);
+		    sessionManager.setUrlProxy(proxyPanel.getFieldUrl().getText());
+		    sessionManager.setLoginProxy(proxyPanel.getFieldLogin().getText());
+		    sessionManager.setPassProxy(proxyPanel.getFieldPassword().getText());
+		    sessionManager.setUsesProxy(true);
 		} catch (Exception e) {
 		    echecProxy = true;
@@ -260,5 +268,5 @@
 			JOptionPane.ERROR_MESSAGE);
 	    } else {
-		int response = Main.sessionManager.processLogin();
+		int response = sessionManager.processLogin();
 		if (response == 0) {
 		    Main.showFrame();
@@ -267,5 +275,5 @@
 		} else if (response == 1) {
 		    //if the login fails, an error is displayed
-		    if (!Main.sessionManager.isProxyError()) {
+		    if (!sessionManager.isProxyError()) {
 			JOptionPane.showMessageDialog(null, Messages.getMessage("connexionDialog_connexionError"),
 				Messages.getMessage("error"), JOptionPane.ERROR_MESSAGE);
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/comments/CommentsDialog.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/comments/CommentsDialog.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/comments/CommentsDialog.java	(revision 9921)
@@ -20,10 +20,9 @@
 import javax.swing.JTextArea;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.om.Comment;
-import fr.mael.jiwigo.service.CommentService;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.Tools;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 import fr.mael.jiwigo.ui.browser.BrowserPanel;
 
@@ -124,5 +123,5 @@
 	this.getContentPane().removeAll();
 	try {
-	    List<Comment> commentsForImage = CommentService.getInstance(Main.sessionManager).list(imageId);
+	    List<Comment> commentsForImage = SpringUtils.getCommentService().list(imageId);
 	    GridBagConstraints c = new GridBagConstraints();
 	    c.insets = new Insets(3, 3, 3, 3);
@@ -168,6 +167,6 @@
 	    boolean reussite = true;
 	    try {
-		reussite = CommentService.getInstance(Main.sessionManager).create(text, this.imageId,
-			Main.sessionManager.getLogin());
+		reussite = SpringUtils.getCommentService().create(text, this.imageId,
+			SpringUtils.getSessionManager().getLogin());
 	    } catch (IOException e) {
 		reussite = false;
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/CategoriesTree.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/CategoriesTree.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/CategoriesTree.java	(revision 9921)
@@ -23,10 +23,9 @@
 import javax.swing.tree.TreeSelectionModel;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.om.Category;
-import fr.mael.jiwigo.service.CategoryService;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.Tools;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 
 /**
@@ -141,5 +140,5 @@
 	DefaultMutableTreeNode category = null;
 	try {
-	    List<Category> list = CategoryService.getInstance(Main.sessionManager).makeTree();
+	    List<Category> list = SpringUtils.getCategoryService().makeTree();
 	    for (Category cat : list) {
 		if (cat.getParentCategories().size() == 0) {
@@ -232,6 +231,5 @@
 		    //try to create a category
 		    try {
-			if (CategoryService.getInstance(Main.sessionManager).create(nomcategorie,
-				selectedCategory.getIdentifier())) {
+			if (SpringUtils.getCategoryService().create(nomcategorie, selectedCategory.getIdentifier())) {
 			    setUpUi();
 			} else {
@@ -249,5 +247,5 @@
 		} else {
 		    try {
-			if (CategoryService.getInstance(Main.sessionManager).create(nomcategorie)) {
+			if (SpringUtils.getCategoryService().create(nomcategorie)) {
 			    setUpUi();
 			} else {
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailCategoryPanel.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailCategoryPanel.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailCategoryPanel.java	(revision 9921)
@@ -10,8 +10,6 @@
 import javax.swing.JPanel;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.om.Category;
 import fr.mael.jiwigo.om.Image;
-import fr.mael.jiwigo.service.ImageService;
 import fr.mael.jiwigo.transverse.ImagesManagement;
 import fr.mael.jiwigo.transverse.enumeration.PreferencesEnum;
@@ -21,4 +19,5 @@
 import fr.mael.jiwigo.transverse.util.filedrop.FileDrop;
 import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 import fr.mael.jiwigo.ui.layout.VerticalLayout;
 
@@ -142,6 +141,5 @@
 	try {
 	    MainFrame.getInstance().setMessage(Messages.getMessage("thumbviewer_loading"));
-	    imagesManagement.setListImage(ImageService.getInstance(Main.sessionManager).listByCategory(categoryId,
-		    rafraichir));
+	    imagesManagement.setListImage(SpringUtils.getImageService().listByCategory(categoryId, rafraichir));
 	    calculateThumbnailPerLine();
 	    addThumbnails();
@@ -165,6 +163,5 @@
 	JPanel panelh = new JPanel(new FlowLayout());
 	try {
-	    imagesManagement.setListImage(ImageService.getInstance(Main.sessionManager).listByCategory(categoryId,
-		    false));
+	    imagesManagement.setListImage(SpringUtils.getImageService().listByCategory(categoryId, false));
 	} catch (IOException e1) {
 	    LOG.error(Tools.getStackTrace(e1));
@@ -253,6 +250,6 @@
 			    .getLabel()));
 
-		    ImageService.getInstance(Main.sessionManager).create(files[i].getCanonicalPath(), categoryId,
-			    widthOriginal, heightOriginal, chunkSize, imagesManagement.getPrivacyLevel());
+		    SpringUtils.getImageService().create(files[i].getCanonicalPath(), categoryId, widthOriginal,
+			    heightOriginal, chunkSize, imagesManagement.getPrivacyLevel());
 		    MainFrame.getInstance()
 			    .setMessage(files[i].getName() + " " + Messages.getMessage("sendingSuccess"));
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailPanel.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailPanel.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailPanel.java	(revision 9921)
@@ -27,13 +27,11 @@
 import javax.swing.ListSelectionModel;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.om.Image;
 import fr.mael.jiwigo.om.Tag;
-import fr.mael.jiwigo.service.ImageService;
-import fr.mael.jiwigo.service.TagService;
 import fr.mael.jiwigo.transverse.ImagesManagement;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.Tools;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 import fr.mael.jiwigo.ui.browser.BrowserPanel;
 import fr.mael.jiwigo.ui.layout.VerticalLayout;
@@ -176,9 +174,9 @@
 	    try {
 		//getting the list of tags
-		List<Tag> tagsDispo = TagService.getInstance(Main.sessionManager).list();
+		List<Tag> tagsDispo = SpringUtils.getTagService().list();
 		//list to array (cause fucking JList does not support Lists)
 		Tag[] tableauTagDispo = (Tag[]) tagsDispo.toArray(new Tag[tagsDispo.size()]);
 		//getting the image's tags to preselect them
-		List<Tag> tagsDeLimage = TagService.getInstance(Main.sessionManager).tagsForImage(image);
+		List<Tag> tagsDeLimage = SpringUtils.getTagService().tagsForImage(image);
 		listTags = new JList(tableauTagDispo);
 		//multiple selection is allowed
@@ -227,5 +225,5 @@
 	    try {
 		try {
-		    if (!ImageService.getInstance(Main.sessionManager).addTags(image, tagIds.toString())) {
+		    if (!SpringUtils.getImageService().addTags(image, tagIds.toString())) {
 			JOptionPane.showMessageDialog(this, Messages.getMessage("addingTagsError"), Messages
 				.getMessage("error"), JOptionPane.ERROR_MESSAGE);
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailSearchPanel.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailSearchPanel.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailSearchPanel.java	(revision 9921)
@@ -6,11 +6,10 @@
 import javax.swing.JPanel;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.om.Category;
 import fr.mael.jiwigo.om.Image;
-import fr.mael.jiwigo.service.ImageService;
 import fr.mael.jiwigo.transverse.ImagesManagement;
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.Tools;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 import fr.mael.jiwigo.ui.layout.VerticalLayout;
 
@@ -90,6 +89,5 @@
 	try {
 	    MainFrame.getInstance().setMessage(Messages.getMessage("thumbviewer_loading"));
-	    ImagesManagement.getInstance().setListImage(
-		    ImageService.getInstance(Main.sessionManager).search(queryString));
+	    ImagesManagement.getInstance().setListImage(SpringUtils.getImageService().search(queryString));
 	    for (Image image : ImagesManagement.getInstance().getListImage()) {
 		try {
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/thread/ThreadPhotoSending.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/thread/ThreadPhotoSending.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/thread/ThreadPhotoSending.java	(revision 9921)
@@ -5,6 +5,4 @@
 import javax.swing.JOptionPane;
 
-import fr.mael.jiwigo.Main;
-import fr.mael.jiwigo.service.ImageService;
 import fr.mael.jiwigo.transverse.ImagesManagement;
 import fr.mael.jiwigo.transverse.enumeration.PreferencesEnum;
@@ -13,4 +11,5 @@
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 import fr.mael.jiwigo.ui.mainframe.MainFrame;
 import fr.mael.jiwigo.ui.mainframe.ThumbnailCategoryPanel;
@@ -67,7 +66,6 @@
 		MainFrame.getInstance().setAdditionalMessage(
 			Messages.getMessage("file") + " " + (i + 1) + "/" + files.length + " : ");
-		ImageService.getInstance(Main.sessionManager).create(files[i].getCanonicalPath(),
-			thumbPanel.getCategoryId(), widthOriginal, heightOriginal, chunkSize,
-			ImagesManagement.getInstance().getPrivacyLevel());
+		SpringUtils.getImageService().create(files[i].getCanonicalPath(), thumbPanel.getCategoryId(),
+			widthOriginal, heightOriginal, chunkSize, ImagesManagement.getInstance().getPrivacyLevel());
 		MainFrame.getInstance().setMessage(files[i].getName() + " " + Messages.getMessage("sendingSuccess"));
 	    } catch (FileAlreadyExistsException e) {
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/DialogChooseCategory.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/DialogChooseCategory.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/DialogChooseCategory.java	(revision 9921)
@@ -15,8 +15,5 @@
 import javax.swing.JOptionPane;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.om.Category;
-import fr.mael.jiwigo.service.CategoryService;
-import fr.mael.jiwigo.service.ImageService;
 import fr.mael.jiwigo.transverse.ImagesManagement;
 import fr.mael.jiwigo.transverse.enumeration.PreferencesEnum;
@@ -27,4 +24,5 @@
 import fr.mael.jiwigo.transverse.util.Tools;
 import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 import fr.mael.jiwigo.ui.mainframe.MainFrame;
 
@@ -99,5 +97,5 @@
 	comboCategories.setRenderer(new ComboCategoryRenderer());
 	try {
-	    categories = CategoryService.getInstance(Main.sessionManager).makeTree();
+	    categories = SpringUtils.getCategoryService().makeTree();
 	    createCategoriesTree();
 	} catch (IOException e) {
@@ -178,7 +176,6 @@
 		    Double chunkSize = Double.valueOf(PreferencesManagement.getValue(PreferencesEnum.CHUNK_SIZE
 			    .getLabel()));
-		    ImageService.getInstance(Main.sessionManager).create(file.getAbsolutePath(),
-			    category.getIdentifier(), widthOriginal, heightOriginal, chunkSize,
-			    ImagesManagement.getInstance().getPrivacyLevel());
+		    SpringUtils.getImageService().create(file.getAbsolutePath(), category.getIdentifier(),
+			    widthOriginal, heightOriginal, chunkSize, ImagesManagement.getInstance().getPrivacyLevel());
 		} catch (WrongChunkSizeException ex) {
 		    JOptionPane.showMessageDialog(null, Messages.getMessage("wrongChunkSizeError"), Messages
Index: /extensions/jiwigo/trunk/src/main/resources/application-context-dao.xml
===================================================================
--- /extensions/jiwigo/trunk/src/main/resources/application-context-dao.xml	(revision 9921)
+++ /extensions/jiwigo/trunk/src/main/resources/application-context-dao.xml	(revision 9921)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+	<bean id="imageDao" class="fr.mael.jiwigo.dao.impl.ImageDaoImpl">
+		<property name="sessionManager" ref="sessionManager"/>
+	</bean>
+
+	<bean id="commentDao" class="fr.mael.jiwigo.dao.impl.CommentDaoImpl">
+		<property name="sessionManager" ref="sessionManager"/>
+	</bean>
+
+	<bean id="categoryDao" class="fr.mael.jiwigo.dao.impl.CategoryDaoImpl">
+		<property name="sessionManager" ref="sessionManager"/>
+	</bean>
+
+	<bean id="tagDao" class="fr.mael.jiwigo.dao.impl.TagDaoImpl">
+		<property name="sessionManager" ref="sessionManager"/>
+	</bean>
+</beans>
Index: /extensions/jiwigo/trunk/src/main/resources/application-context-service.xml
===================================================================
--- /extensions/jiwigo/trunk/src/main/resources/application-context-service.xml	(revision 9921)
+++ /extensions/jiwigo/trunk/src/main/resources/application-context-service.xml	(revision 9921)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+	<bean id="imageService" class="fr.mael.jiwigo.service.impl.ImageServiceImpl">
+		<property name="dao" ref="imageDao"/>
+	</bean>
+
+	<bean id="commentService" class="fr.mael.jiwigo.service.impl.CommentServiceImpl">
+		<property name="dao" ref="commentDao"/>
+	</bean>
+
+	<bean id="categoryService" class="fr.mael.jiwigo.service.impl.CategoryServiceImpl">
+		<property name="dao" ref="categoryDao"/>
+	</bean>
+
+	<bean id="tagService" class="fr.mael.jiwigo.service.impl.TagServiceImpl">
+		<property name="dao" ref="tagDao"/>
+	</bean>
+</beans>
Index: /extensions/jiwigo/trunk/src/main/resources/application-context.xml
===================================================================
--- /extensions/jiwigo/trunk/src/main/resources/application-context.xml	(revision 9921)
+++ /extensions/jiwigo/trunk/src/main/resources/application-context.xml	(revision 9921)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+	<bean id="sessionManager" class="fr.mael.jiwigo.transverse.session.impl.SessionManagerImpl">
+		<property name="userAgent" value="Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0"/>
+	</bean>
+
+	<import resource="application-context-dao.xml" />
+
+	<import resource="application-context-service.xml" />
+</beans>
Index: /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/TestBase.java
===================================================================
--- /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/TestBase.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/TestBase.java	(revision 9921)
@@ -6,9 +6,13 @@
 
 import fr.mael.jiwigo.transverse.session.SessionManager;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 
 public class TestBase {
     public TestBase() {
-	Main.sessionManager = new SessionManager("mael", "motdepasse", "http://mael.piwigo.com");
-	if (Main.sessionManager.processLogin() != 0) {
+	SessionManager sessionManager = SpringUtils.getSessionManager();
+	sessionManager.setLogin("mael");
+	sessionManager.setPassword("motdepasse");
+	sessionManager.setUrl("http://mael.piwigo.com/ws.php");
+	if (sessionManager.processLogin() != 0) {
 	    try {
 		throw new Exception("Connection failed");
Index: /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/CategoryServiceTest.java
===================================================================
--- /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/CategoryServiceTest.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/CategoryServiceTest.java	(revision 9921)
@@ -8,8 +8,7 @@
 import org.junit.Test;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.TestBase;
-import fr.mael.jiwigo.dao.CategoryDao;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 
 public class CategoryServiceTest extends TestBase {
@@ -25,6 +24,6 @@
     public void ListerTest() throws ProxyAuthenticationException {
 	try {
-	    CategoryDao.getInstance(Main.sessionManager).list(true);
-	    CategoryDao.getInstance(Main.sessionManager).list(false);
+	    SpringUtils.getCategoryService().list(true);
+	    SpringUtils.getCategoryService().list(false);
 	} catch (IOException e) {
 	    e.printStackTrace();
@@ -39,5 +38,5 @@
     public void creerTest() throws ProxyAuthenticationException {
 	Date date = new Date();
-	Assert.assertSame(true, CategoryService.getInstance(Main.sessionManager).create("Category" + date.getTime()));
+	Assert.assertSame(true, SpringUtils.getCategoryService().create("Category" + date.getTime()));
     }
 
Index: /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/ImageServiceBinding.java
===================================================================
--- /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/ImageServiceBinding.java	(revision 9921)
+++ /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/ImageServiceBinding.java	(revision 9921)
@@ -0,0 +1,15 @@
+package fr.mael.jiwigo.service;
+
+
+public class ImageServiceBinding {
+    private ImageService imageService;
+
+    public ImageService getImageService() {
+	return imageService;
+    }
+
+    public void setImageService(ImageService imageService) {
+	this.imageService = imageService;
+    }
+
+}
Index: /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/ServicesTest.java
===================================================================
--- /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/ServicesTest.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/ServicesTest.java	(revision 9921)
@@ -5,9 +5,9 @@
 import org.junit.Test;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.TestBase;
 import fr.mael.jiwigo.om.Category;
 import fr.mael.jiwigo.om.Comment;
 import fr.mael.jiwigo.om.Image;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 
 public class ServicesTest extends TestBase {
@@ -20,5 +20,5 @@
     public void testCreer() throws Exception {
 	Category cat = null;
-	for (Category category : CategoryService.getInstance(Main.sessionManager).list(true)) {
+	for (Category category : SpringUtils.getCategoryService().list(true)) {
 	    if (category.getIdentifier().equals(3)) {
 		cat = category;
@@ -27,8 +27,8 @@
 	}
 
-	Image image = ImageService.getInstance(Main.sessionManager).listByCategory(cat.getIdentifier(), true).get(0);
-	List<Comment> comments = CommentService.getInstance(Main.sessionManager).list(image.getIdentifier());
+	Image image = SpringUtils.getImageService().listByCategory(cat.getIdentifier(), true).get(0);
+	List<Comment> comments = SpringUtils.getCommentService().list(image.getIdentifier());
 	//	int firstCount = comments.size();
-	CommentService.getInstance(Main.sessionManager).create("comment test", image.getIdentifier(), "none");
+	SpringUtils.getCommentService().create("comment test", image.getIdentifier(), "none");
 	//	int secondCount = CommentService.getInstance(Main.sessionManager).list(image.getIdentifier()).size();
 	//	Assert.assertSame(firstCount + 1, secondCount);
Index: /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/TagServiceTest.java
===================================================================
--- /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/TagServiceTest.java	(revision 9920)
+++ /extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/TagServiceTest.java	(revision 9921)
@@ -8,8 +8,7 @@
 import org.junit.Test;
 
-import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.TestBase;
-import fr.mael.jiwigo.dao.TagDao;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
+import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
 
 public class TagServiceTest extends TestBase {
@@ -26,5 +25,5 @@
     public void ListerTest() throws ProxyAuthenticationException {
 	try {
-	    TagDao.getInstance(Main.sessionManager).list();
+	    SpringUtils.getTagService().list();
 	} catch (IOException e) {
 	    e.printStackTrace();
@@ -40,5 +39,5 @@
 	Date date = new Date();
 	try {
-	    Assert.assertSame(true, TagService.getInstance(Main.sessionManager).create("Tag" + date.getTime()));
+	    Assert.assertSame(true, SpringUtils.getTagService().create("Tag" + date.getTime()));
 	} catch (IOException e) {
 	    // TODO Auto-generated catch block
