KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > apollo > ServiceManager


1 /*
2 ** Apollo - Test Skeleton Toolkit for Web Start/JNLP
3 ** Copyright (c) 2001, 2002, 2003 by Gerald Bauer
4 **
5 ** This program is free software.
6 **
7 ** You may redistribute it and/or modify it under the terms of the GNU
8 ** General Public License as published by the Free Software Foundation.
9 ** Version 2 of the license should be included with this distribution in
10 ** the file LICENSE, as well as License.html. If the license is not
11 ** included with this distribution, you may find a copy at the FSF web
12 ** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
13 ** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
14 **
15 ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
16 ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
17 ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
18 ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
19 ** REDISTRIBUTION OF THIS SOFTWARE.
20 **
21 */

22
23 package apollo;
24
25 import apollo.dev.*;
26 import apollo.jnlp.*;
27 import apollo.spi.*;
28
29 // todo: should I throw ServiceNotAvailable exceptions?
30

31 public class ServiceManager
32 {
33
34    private static ServiceManager _instance;
35    private ServiceResolver _resolver;
36
37    private ServiceManager()
38    {
39       // check if we are running under webstart
40
try
41       {
42          Class JavaDoc clazz = Class.forName( "javax.jnlp.ServiceManager" );
43
44          _resolver = new JnlpServiceResolver( new DevServiceResolver() );
45       }
46       catch( ClassNotFoundException JavaDoc ex )
47       {
48          _resolver = new DevServiceResolver();
49       }
50    }
51
52    private static ServiceManager getServiceManager()
53    {
54       if( _instance == null )
55          _instance = new ServiceManager();
56
57       return _instance;
58    }
59
60    private ServiceResolver getResolver()
61    {
62       return _resolver;
63    }
64
65    public static BasicService lookupBasicService()
66    {
67       return getServiceManager().getResolver().lookupBasicService();
68    }
69
70    public static ClipboardService lookupClipboardService()
71    {
72       return getServiceManager().getResolver().lookupClipboardService();
73    }
74
75    public static FileOpenService lookupFileOpenService()
76    {
77       return getServiceManager().getResolver().lookupFileOpenService();
78    }
79
80    public static FileSaveService lookupFileSaveService()
81    {
82       return getServiceManager().getResolver().lookupFileSaveService();
83    }
84
85    public static PersistenceService lookupPersistenceService()
86    {
87       return getServiceManager().getResolver().lookupPersistenceService();
88    }
89
90    public static PrintService lookupPrintService()
91    {
92       return getServiceManager().getResolver().lookupPrintService();
93    }
94 }
95
96
Popular Tags