KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdic > desktop > internal > ServiceManager


1 /*
2  * Copyright (C) 2004 Sun Microsystems, Inc. All rights reserved. Use is
3  * subject to license terms.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the Lesser GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  */

20  
21 package org.jdesktop.jdic.desktop.internal;
22
23 import org.jdesktop.jdic.desktop.internal.impl.ServiceManagerStub;
24 import org.jdesktop.jdic.init.JdicInitException;
25 import org.jdesktop.jdic.init.JdicManager;
26
27
28 /**
29  * The <code>ServiceManager</code> class provides static fields to refer to
30  * the available services, and static methods to get the approprate service
31  * objects with the given service name. This class is abstract and final and
32  * cannot be instantiated.
33  *
34  * @see ServiceManagerStub
35  * @see LaunchService
36  * @see BrowserService
37  * @see MailerService
38  */

39 public class ServiceManager {
40   
41     /**
42      * Constant name for looking up the launch service object.
43      */

44     public static final String JavaDoc LAUNCH_SERVICE = "LaunchService";
45   
46     /**
47      * Constant name for looking up the browser service object.
48      */

49     public static final String JavaDoc BROWSER_SERVICE = "BrowserService";
50   
51     /**
52      * Constant name for looking up the mailer service object.
53      */

54     public static final String JavaDoc MAILER_SERVICE = "MailerService";
55   
56     /**
57      * Suppress default constructor for noninstantiability.
58      */

59     private ServiceManager() {}
60     
61     // Add the initialization code from package org.jdesktop.jdic.init.
62
// To set the environment variables or initialize the set up for
63
// native libraries and executable files.
64
static {
65         try {
66             JdicManager jm = JdicManager.getManager();
67             jm.initShareNative();
68         } catch (JdicInitException e){
69             e.printStackTrace();
70         }
71     }
72   
73     /**
74      * Gets a service object with the given name. The given service name should be one
75      * of the pre-defined service names.
76      *
77      * @param serviceName the given service name.
78      * @return the appropriate service object.
79      * @throws NullPointerException if the given service name is null.
80      * @see LaunchService
81      * @see BrowserService
82      * @see MailerService
83      */

84     public static Object JavaDoc getService(String JavaDoc serviceName)
85         throws NullPointerException JavaDoc {
86         if (serviceName == null) {
87             throw new NullPointerException JavaDoc("Service name is null.");
88         }
89         
90         return ServiceManagerStub.getService(serviceName);
91     }
92 }
93
Popular Tags