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/CategoryServiceImpl.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.CategoryDao;
    710import fr.mael.jiwigo.om.Category;
     11import fr.mael.jiwigo.service.CategoryService;
    812import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
    9 import fr.mael.jiwigo.transverse.session.SessionManager;
    1013
    1114/*
     
    2528 *
    2629 */
    27 public class CategoryService {
     30public class CategoryServiceImpl implements CategoryService {
    2831    /**
    2932     * Logger
    3033     */
    31     public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
    32             .getLog(CategoryService.class);
     34    private final Logger LOG = LoggerFactory.getLogger(CategoryServiceImpl.class);
    3335
    34     /**
    35      * singleton
    36      */
    37     private static CategoryService instance;
    38 
    39     private SessionManager sessionManager;
    40 
    41     /**
    42      * @return the singleton
    43      */
    44     public static CategoryService getInstance(SessionManager sessionManager) {
    45         if (instance == null) {
    46             instance = new CategoryService(sessionManager);
    47         }
    48         return instance;
    49     }
    50 
    51     /**
    52      * private constructor to use a singleton
    53      */
    54     private CategoryService(SessionManager sessionManager) {
    55         this.sessionManager = sessionManager;
    56 
    57     }
     36    private CategoryDao dao;
    5837
    5938    /**
     
    6544     */
    6645    public List<Category> list(boolean recursive) throws IOException, ProxyAuthenticationException {
    67         return CategoryDao.getInstance(sessionManager).list(recursive);
     46        return dao.list(recursive);
    6847    }
    6948
     
    7554     */
    7655    public List<Category> makeTree() throws IOException, ProxyAuthenticationException {
    77         List<Category> list = CategoryDao.getInstance(sessionManager).list(true);
     56        List<Category> list = dao.list(true);
    7857        for (Category category : list) {
    7958            for (Category category2 : list) {
     
    10382        category.setDirectParent(parent);
    10483        category.setName(nom);
    105         return CategoryDao.getInstance(sessionManager).create(category);
     84        return dao.create(category);
    10685    }
    10786
     
    11594        Category category = new Category();
    11695        category.setName(nom);
    117         return CategoryDao.getInstance(sessionManager).create(category);
     96        return dao.create(category);
    11897    }
     98
     99    public CategoryDao getDao() {
     100        return dao;
     101    }
     102
     103    public void setDao(CategoryDao dao) {
     104        this.dao = dao;
     105    }
     106
    119107}
Note: See TracChangeset for help on using the changeset viewer.