01: /*
02: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License version
07: * 2 only, as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful, but
10: * WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * General Public License version 2 for more details (a copy is
13: * included at /legal/license.txt).
14: *
15: * You should have received a copy of the GNU General Public License
16: * version 2 along with this work; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18: * 02110-1301 USA
19: *
20: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
21: * Clara, CA 95054 or visit www.sun.com if you need additional
22: * information or have any questions.
23: */
24:
25: package com.sun.jumpimpl.module.serviceregistry;
26:
27: import com.sun.jump.module.serviceregistry.JUMPServiceRegistryModule;
28:
29: import java.rmi.Remote;
30: import java.rmi.AlreadyBoundException;
31: import java.rmi.NotBoundException;
32: import java.rmi.RemoteException;
33: import java.rmi.AccessException;
34:
35: import javax.microedition.xlet.ixc.IxcRegistry;
36: import javax.microedition.xlet.ixc.StubException;
37:
38: import java.util.Map;
39:
40: public class ServiceRegistryImpl implements JUMPServiceRegistryModule {
41:
42: public void load(Map map) {
43: }
44:
45: public void unload() {
46: }
47:
48: private IxcRegistry registry;
49:
50: public ServiceRegistryImpl(IxcRegistry registry) {
51: this .registry = registry;
52: }
53:
54: /**
55: * Registers a service under a given name to the registry, and make it
56: * available for other JUMP processes.
57: * A wrapper for IxcRegistry.bind(String, Remote)
58: *
59: * @throws AlreadyBoundException if the name is already bound to another service.
60: * @throws RemoteException if the service object is not well-formed.
61: **/
62: public void registerService(String name, Remote service)
63: throws RemoteException, AlreadyBoundException {
64: registry.bind(name, service);
65: }
66:
67: /**
68: * Removes a service with a given name from the registry.
69: * A wrapper for IxcRegistry.unbind(String)
70: *
71: * @throws NotBoundException if the name is not found in this registry.
72: **/
73: public void unregisterService(String name)
74: throws NotBoundException, AccessException {
75: registry.unbind(name);
76: }
77:
78: /**
79: * Gets a service from the registry under a given name.
80: * A wrapper for IxcRegistry.lookup(name)
81: *
82: * @throws NotBoundException if the name is not found in this registry.
83: **/
84: public Remote getService(String name) throws NotBoundException,
85: RemoteException {
86: return registry.lookup(name);
87: }
88:
89: /**
90: * Provides a list of service names currently available in this registry.
91: * A wrapper for IxcRegistry.list()
92: **/
93: public String[] listRegisteredServices() {
94: return registry.list();
95: }
96:
97: }
|