KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdic > desktop > internal > impl > ServiceManagerStub


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.impl;
22
23 import org.jdesktop.jdic.desktop.internal.ServiceManager;
24
25
26 /**
27  * The <code>ServiceManagerStub</code> class implements the particular
28  * lookup of services. The request in ServiceManager to lookup services is
29  * delegated to this object.
30  *
31  * @author Elliott Hughes <enh@acm.org>
32  * @see org.jdesktop.jdic.desktop.internal.ServiceManager
33  */

34 public class ServiceManagerStub {
35
36     /**
37      * Suppress default constructor for noninstantiability.
38      */

39     private ServiceManagerStub() {}
40   
41     /**
42      * Gets the requested service object according to the given service name.
43      *
44      * @param serviceName the given service name.
45      * @throws IllegalArgumentException if there is no approprate service
46      * according to the given service name, or
47      * UnsupportedOperationException if we've got unsupported system
48      * mailer.
49      * @throws UnsupportedOperationException if the current mailer is not
50      * supported for this operation.
51      * @return the requested service object.
52      */

53     public static Object JavaDoc getService(String JavaDoc serviceName)
54         throws IllegalArgumentException JavaDoc, UnsupportedOperationException JavaDoc {
55         if (serviceName.equals(ServiceManager.LAUNCH_SERVICE)) {
56             return new MacLaunchService();
57         } else if (serviceName.equals(ServiceManager.BROWSER_SERVICE)) {
58             return new MacBrowserService();
59         } else if (serviceName.equals(ServiceManager.MAILER_SERVICE)) {
60             return new MacMailerService();
61         } else {
62             // Should never arrive here.
63
throw new IllegalArgumentException JavaDoc(
64                 "The requested service is not supported.");
65         }
66     }
67 }
68
Popular Tags