KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdic > tray > 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.tray.internal;
22
23
24 import org.jdesktop.jdic.tray.internal.impl.ServiceManagerStub;
25 import org.jdesktop.jdic.init.JdicInitException;
26 import org.jdesktop.jdic.init.JdicManager;
27
28
29 /**
30  * The <code>ServiceManager</code> class provides static fields to refer to
31  * the available services, and static methods to get the approprate service
32  * objects with the given service name. This class is abstract and final and
33  * cannot be instantiated.
34  *
35  * @see ServiceManagerStub
36  */

37 public class ServiceManager {
38   
39     /**
40      * Constant name for looking up the SystemTray service object.
41      */

42     public static final String JavaDoc SYSTEM_TRAY_SERVICE = "SystemTrayService";
43
44     /**
45      * Constant name for looking up the TrayIcon service object.
46      */

47     public static final String JavaDoc TRAY_ICON_SERVICE = "TrayIconService";
48
49     /**
50      * Constant name for looking up the TrayApplet service object.
51      */

52     public static final String JavaDoc TRAY_APPLET_SERVICE = "TrayAppletService";
53     
54     /**
55      * Suppress default constructor for noninstantiability.
56      */

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

79     public static Object JavaDoc getService(String JavaDoc serviceName)
80             throws NullPointerException JavaDoc {
81         if (serviceName == null) {
82             throw new NullPointerException JavaDoc("Service name is null.");
83         }
84         
85         return ServiceManagerStub.getService(serviceName);
86     }
87 }
88
Popular Tags