home *** CD-ROM | disk | FTP | other *** search
- package sun.rmi.registry;
-
- import java.net.InetAddress;
- import java.net.UnknownHostException;
- import java.rmi.AccessException;
- import java.rmi.AlreadyBoundException;
- import java.rmi.NotBoundException;
- import java.rmi.RMISecurityManager;
- import java.rmi.Remote;
- import java.rmi.RemoteException;
- import java.rmi.registry.Registry;
- import java.rmi.server.ObjID;
- import java.rmi.server.RemoteServer;
- import java.rmi.server.ServerNotActiveException;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import sun.rmi.server.UnicastServerRef;
- import sun.rmi.transport.LiveRef;
- import sun.rmi.transport.ObjectTable;
- import sun.rmi.transport.Target;
-
- public class RegistryImpl extends RemoteServer implements Registry {
- private Hashtable bindings = new Hashtable(101);
- private static RegistryImpl registry;
- private static InetAddress localhost = null;
- // $FF: renamed from: id java.rmi.server.ObjID
- private static ObjID field_0 = new ObjID(0);
-
- public RegistryImpl() throws RemoteException {
- this.setup(new LiveRef());
- }
-
- public RegistryImpl(int var1) throws RemoteException {
- LiveRef var2 = new LiveRef(field_0, var1);
- this.setup(var2);
- }
-
- private void setup(LiveRef var1) throws RemoteException {
- UnicastServerRef var2 = new UnicastServerRef(var1);
- super.ref = var2;
- var2.exportObject(this, (Object)null);
- Target var3 = ObjectTable.getTarget(this);
- var3.setPermanent(true);
- }
-
- public Remote lookup(String var1) throws RemoteException, NotBoundException {
- Hashtable var3 = this.bindings;
- synchronized(var3){}
-
- Remote var2;
- try {
- Remote var5 = (Remote)this.bindings.get(var1);
- if (var5 == null) {
- throw new NotBoundException(var1);
- }
-
- var2 = var5;
- } catch (Throwable var7) {
- throw var7;
- }
-
- return var2;
- }
-
- public void bind(String var1, Remote var2) throws RemoteException, AlreadyBoundException, AccessException {
- this.checkAccess("bind");
- Hashtable var3 = this.bindings;
- synchronized(var3){}
-
- try {
- Remote var5 = (Remote)this.bindings.get(var1);
- if (var5 != null) {
- throw new AlreadyBoundException(var1);
- }
-
- this.bindings.put(var1, var2);
- } catch (Throwable var7) {
- throw var7;
- }
-
- }
-
- public void unbind(String var1) throws RemoteException, NotBoundException, AccessException {
- this.checkAccess("unbind");
- Hashtable var2 = this.bindings;
- synchronized(var2){}
-
- try {
- Remote var4 = (Remote)this.bindings.get(var1);
- if (var4 == null) {
- throw new NotBoundException(var1);
- }
-
- this.bindings.remove(var1);
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
-
- public void rebind(String var1, Remote var2) throws RemoteException, AccessException {
- this.checkAccess("rebind");
- this.bindings.put(var1, var2);
- }
-
- public String[] list() throws RemoteException {
- Hashtable var2 = this.bindings;
- synchronized(var2){}
-
- try {
- int var4 = this.bindings.size();
- String[] var1 = new String[var4];
- Enumeration var5 = this.bindings.keys();
-
- while(true) {
- --var4;
- if (var4 < 0) {
- return var1;
- }
-
- var1[var4] = (String)var5.nextElement();
- }
- } catch (Throwable var7) {
- throw var7;
- }
- }
-
- void checkAccess(String var1) throws AccessException {
- try {
- if (localhost == null) {
- localhost = InetAddress.getLocalHost();
- }
-
- String var2 = RemoteServer.getClientHost();
- InetAddress var3 = InetAddress.getByName(var2);
- if (!var3.equals(localhost) && !var2.equals(localhost.getHostName())) {
- throw new AccessException("Registry." + var1 + " " + var3 + " != " + localhost);
- }
- } catch (ServerNotActiveException var4) {
- } catch (UnknownHostException var5) {
- throw new AccessException("Registry." + var1);
- }
- }
-
- public static ObjID getID() {
- return field_0;
- }
-
- public static void main(String[] var0) {
- System.setSecurityManager(new RMISecurityManager());
-
- try {
- int var1 = 1099;
- if (var0.length >= 1) {
- var1 = Integer.parseInt(var0[0]);
- }
-
- registry = new RegistryImpl(var1);
-
- while(true) {
- try {
- Thread.sleep(2147483646L);
- } catch (InterruptedException var2) {
- }
- }
- } catch (NumberFormatException var3) {
- System.out.println("Port is not a number.");
- } catch (Exception var4) {
- System.out.println("RegistryImpl.main: an exception occurred: " + ((Throwable)var4).getMessage());
- ((Throwable)var4).printStackTrace();
- }
-
- System.exit(1);
- }
- }
-