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/service/impl
Files:
1 added
1 copied

Legend:

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

    r9879 r9919  
    1 package fr.mael.jiwigo.service;
     1package fr.mael.jiwigo.service.impl;
    22
    33import java.io.IOException;
    44import java.util.List;
    55
     6import org.slf4j.Logger;
     7import org.slf4j.LoggerFactory;
     8
    69import fr.mael.jiwigo.dao.TagDao;
    710import fr.mael.jiwigo.om.Image;
    811import fr.mael.jiwigo.om.Tag;
     12import fr.mael.jiwigo.service.TagService;
    913import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
    10 import fr.mael.jiwigo.transverse.session.SessionManager;
    1114
    1215/*
     
    2730 *
    2831 */
    29 public class TagService {
     32public class TagServiceImpl implements TagService {
    3033    /**
    3134     * Logger
    3235     */
    33     public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
    34             .getLog(TagService.class);
     36    private final Logger LOG = LoggerFactory.getLogger(TagServiceImpl.class);
    3537
    36     /**
    37      * The instance, to use a singleton
    38      */
    39     private static TagService instance;
    40 
    41     private SessionManager sessionManager;
    42 
    43     /**
    44      * @return the singleton
    45      */
    46     public static TagService getInstance(SessionManager sessionManager) {
    47         if (instance == null) {
    48             instance = new TagService(sessionManager);
    49         }
    50         return instance;
    51     }
    52 
    53     /**
    54      * private constructor
    55      */
    56     private TagService(SessionManager sessionManager) {
    57         this.sessionManager = sessionManager;
    58     }
     38    private TagDao dao;
    5939
    6040    /**
     
    6545     */
    6646    public List<Tag> list() throws IOException, ProxyAuthenticationException {
    67         return TagDao.getInstance(sessionManager).list();
     47        return dao.list();
    6848    }
    6949
     
    7858        Tag tag = new Tag();
    7959        tag.setName(nom);
    80         return TagDao.getInstance(sessionManager).create(tag);
     60        return dao.create(tag);
    8161    }
    8262
     
    8969     */
    9070    public List<Tag> tagsForImage(Image image) throws IOException, ProxyAuthenticationException {
    91         return TagDao.getInstance(sessionManager).tagsForImage(image);
     71        return dao.tagsForImage(image);
     72    }
     73
     74    public TagDao getDao() {
     75        return dao;
     76    }
     77
     78    public void setDao(TagDao dao) {
     79        this.dao = dao;
    9280    }
    9381
Note: See TracChangeset for help on using the changeset viewer.