KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > core > dist > rmi > RMINaming


1 /*
2
3   Copyright (C) 2001 Lionel Seinturier
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU Lesser 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,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   GNU Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser Generaly 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 USA */

18
19 package org.objectweb.jac.core.dist.rmi;
20
21 import org.objectweb.jac.core.dist.RemoteContainer;
22 import org.objectweb.jac.core.dist.Distd;
23
24 import java.rmi.Naming JavaDoc;
25
26
27 /**
28  * RMINaming wraps the RMI naming registry.
29  * The class method resolve()
30  * is dynamically called by org.objectweb.jac.dist.RemoteContainer.resolve(String)
31  * and statically by RMIRemoteRef.resolve(String).
32  *
33  * @author <a HREF="http://www-src.lip6.fr/homepages/Lionel.Seinturier/index-eng.html">Lionel Seinturier</a>
34  */

35  
36 public class RMINaming {
37
38    /**
39     * This method resolves a container from a container name.
40     *
41     * @param contName the name of the container
42     * @return the container reference, null if not resolved */

43    
44    public static RemoteContainer resolve( String JavaDoc contName ) {
45    
46     RMIRemoteContainerInterf stub = null;
47
48       contName = Distd.getFullHostName( contName );
49       
50       try {
51          stub = (RMIRemoteContainerInterf) Naming.lookup(contName);
52          return new RMIRemoteContainerStub( stub, contName );
53       } catch( Exception JavaDoc e ) {
54          return null;
55       }
56
57    }
58
59 }
60
Popular Tags