View Javadoc

1   // Copyright (C) 2005  Michael Wever ( mick@wever.org )
2   // 
3   // This program is free software; you can redistribute it and/or
4   // modify it under the terms of the GNU General Public License
5   // as published by the Free Software Foundation; either version 2
6   // of the License, or (at your option) any later version.
7   // 
8   // This program is distributed in the hope that it will be useful,
9   // but WITHOUT ANY WARRANTY; without even the implied warranty of
10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  // GNU General Public License for more details.
12  // 
13  // You should have received a copy of the GNU General Public License
14  // along with this program; if not, write to the Free Software
15  // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16  /*
17   * ServiceFactory.java
18   *
19   * Created on 16. juli 2005, 20:19
20   *
21   * To change this template, choose Tools | Options and locate the template under
22   * the Source Creation and Management node. Right-click the template and choose
23   * Open. You can then make changes to the template in the Source Editor.
24   */
25  
26  package org.wever.jradiodj.services;
27  
28  import org.wever.jradiodj.services.collection.CollectionManager;
29  import org.wever.jradiodj.services.collection.CollectionManagerImpl;
30  import org.wever.jradiodj.services.playlist.IceCastPlaylistGeneratorImpl;
31  import org.wever.jradiodj.services.playlist.PlaylistGenerator;
32  
33  
34  /*** Simple Factory that returns hardcoded implementations.
35   * The factory exists to make plugging in new implementations simple.
36   * Services must be multi-threaded friendly as only a single instance of any service
37   * will be created in the current jvm.
38   *
39   * @author mick
40   * @version $Id$
41   */
42  public final class ServiceFactory {
43  
44      private static CollectionManager collectionManager;
45  
46      private static PlaylistGenerator playlistGenerator;
47      
48      /*** Creates a new instance of ServiceFactory. */
49      private ServiceFactory() {
50      }
51      
52      /***
53       * 
54       * @return 
55       */
56      public static CollectionManager getCollectionManager() {
57          if( collectionManager == null ) {
58              collectionManager = new CollectionManagerImpl();
59          }
60          return collectionManager;
61      }
62      
63      /***
64       * 
65       * @return 
66       */
67      public static PlaylistGenerator getPlaylistGenerator() {
68          if( playlistGenerator == null ) {
69              playlistGenerator = new IceCastPlaylistGeneratorImpl();
70          }
71          return playlistGenerator;
72      }    
73  }