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/CommentServiceImpl.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.CommentDao;
    710import fr.mael.jiwigo.om.Comment;
     11import fr.mael.jiwigo.service.CommentService;
    812import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
    9 import fr.mael.jiwigo.transverse.session.SessionManager;
    1013
    1114/*
     
    2528 *
    2629 */
    27 public class CommentService {
     30public class CommentServiceImpl implements CommentService {
    2831    /**
    2932     * Logger
    3033     */
    31     public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
    32             .getLog(CommentService.class);
     34    private final Logger LOG = LoggerFactory.getLogger(CommentServiceImpl.class);
    3335
    34     /**
    35      * singleton
    36      */
    37     private static CommentService instance;
    38 
    39     private SessionManager sessionManager;
    40 
    41     /**
    42      * @return the singleton
    43      */
    44     public static CommentService getInstance(SessionManager sessionManager) {
    45         if (instance == null) {
    46             instance = new CommentService(sessionManager);
    47         }
    48         return instance;
    49     }
    50 
    51     /**
    52      * private constructor, to use a singleton
    53      */
    54     private CommentService(SessionManager sessionManager) {
    55         this.sessionManager = sessionManager;
    56     }
     36    private CommentDao dao;
    5737
    5838    /**
     
    6444     */
    6545    public List<Comment> list(Integer imageId) throws IOException, ProxyAuthenticationException {
    66         return CommentDao.getInstance(sessionManager).list(imageId);
     46        return dao.list(imageId);
    6747    }
    6848
     
    8262        comment.setImageId(imageId);
    8363        comment.setAuthor(auteur);
    84         return CommentDao.getInstance(sessionManager).create(comment);
     64        return dao.create(comment);
     65    }
     66
     67    public CommentDao getDao() {
     68        return dao;
     69    }
     70
     71    public void setDao(CommentDao dao) {
     72        this.dao = dao;
    8573    }
    8674
Note: See TracChangeset for help on using the changeset viewer.