Ignore:
Timestamp:
Mar 29, 2011, 8:21:25 PM (13 years ago)
Author:
mlg
Message:

Complete rewriting of the api
The api now uses interfaces everywhere (for the dao, services and session manager). This allows the developer to use his own implementations if he wants.
Deletion of the singletons. There are now getters and setters. It allows to make dependency injection.
Use of sl4j in the api, instead of using log4j.

Location:
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java

    r9902 r9919  
    1 package fr.mael.jiwigo.dao;
     1package fr.mael.jiwigo.dao.impl;
    22
    33import java.io.File;
     
    88import java.util.List;
    99
     10import org.slf4j.Logger;
     11import org.slf4j.LoggerFactory;
    1012import org.w3c.dom.Document;
    1113import org.w3c.dom.Element;
     
    1416
    1517import sun.misc.BASE64Encoder;
     18import fr.mael.jiwigo.dao.ImageDao;
    1619import fr.mael.jiwigo.om.Image;
    1720import fr.mael.jiwigo.transverse.enumeration.MethodsEnum;
     
    3942 *
    4043 */
    41 public class ImageDao {
     44public class ImageDaoImpl implements ImageDao {
    4245
    4346    /**
    4447     * Logger
    4548     */
    46     public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
    47             .getLog(ImageDao.class);
    48 
    49     /**
    50      * Singleton
    51      */
    52     private static ImageDao instance;
     49    private final Logger LOG = LoggerFactory.getLogger(ImageDaoImpl.class);
    5350
    5451    /**
     
    6663    private ArrayList<File> filesToSend;
    6764
    68     /**
    69      * Private singleton, to use a singleton
    70      */
    71     private ImageDao(SessionManager sessionManager) {
     65    public ImageDaoImpl() {
    7266        cache = new HashMap<Integer, List<Image>>();
    73         this.sessionManager = sessionManager;
    74     }
    75 
    76     /**
    77      * @return le singleton
    78      */
    79     public static ImageDao getInstance(SessionManager sessionManager) {
    80         if (instance == null) {
    81             instance = new ImageDao(sessionManager);
    82         }
    83         return instance;
    8467    }
    8568
     
    260243    public List<Image> search(String searchString) throws IOException, ProxyAuthenticationException {
    261244        Document doc = sessionManager.executeReturnDocument(MethodsEnum.SEARCH.getLabel(), "query", searchString);
    262         LOG.debug(doc);
     245        LOG.debug(Tools.documentToString(doc));
    263246        Element element = (Element) doc.getDocumentElement().getElementsByTagName("images").item(0);
    264247        return getImagesFromElement(element);
     
    277260    }
    278261
     262    public SessionManager getSessionManager() {
     263        return sessionManager;
     264    }
     265
     266    public void setSessionManager(SessionManager sessionManager) {
     267        this.sessionManager = sessionManager;
     268    }
     269
    279270}
Note: See TracChangeset for help on using the changeset viewer.