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.

File:
1 edited

Legend:

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

    r9879 r9919  
    44import java.util.List;
    55
    6 import fr.mael.jiwigo.dao.TagDao;
    76import fr.mael.jiwigo.om.Image;
    87import fr.mael.jiwigo.om.Tag;
    98import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
    10 import fr.mael.jiwigo.transverse.session.SessionManager;
    119
    12 /*
    13  *  jiwigo-ws-api Piwigo webservice access Api
    14  *  Copyright (c) 2010-2011 Mael mael@le-guevel.com
    15  *                All Rights Reserved
    16  *
    17  *  This library is free software. It comes without any warranty, to
    18  *  the extent permitted by applicable law. You can redistribute it
    19  *  and/or modify it under the terms of the Do What The Fuck You Want
    20  *  To Public License, Version 2, as published by Sam Hocevar. See
    21  *  http://sam.zoy.org/wtfpl/COPYING for more details.
    22  */
    23 /**
    24  *
    25 
    26  * @author mael
    27  *
    28  */
    29 public class TagService {
    30     /**
    31      * Logger
    32      */
    33     public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
    34             .getLog(TagService.class);
    35 
    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     }
     10public interface TagService {
    5911
    6012    /**
     
    6416     * @throws ProxyAuthenticationException
    6517     */
    66     public List<Tag> list() throws IOException, ProxyAuthenticationException {
    67         return TagDao.getInstance(sessionManager).list();
    68     }
     18    public List<Tag> list() throws IOException, ProxyAuthenticationException;
    6919
    7020    /**
     
    7525     * @throws ProxyAuthenticationException
    7626     */
    77     public boolean create(String nom) throws IOException, ProxyAuthenticationException {
    78         Tag tag = new Tag();
    79         tag.setName(nom);
    80         return TagDao.getInstance(sessionManager).create(tag);
    81     }
     27    public boolean create(String nom) throws IOException, ProxyAuthenticationException;
    8228
    8329    /**
     
    8834     * @throws ProxyAuthenticationException
    8935     */
    90     public List<Tag> tagsForImage(Image image) throws IOException, ProxyAuthenticationException {
    91         return TagDao.getInstance(sessionManager).tagsForImage(image);
    92     }
    93 
     36    public List<Tag> tagsForImage(Image image) throws IOException, ProxyAuthenticationException;
    9437}
Note: See TracChangeset for help on using the changeset viewer.