001 /* 002 003 Copyright (C) 2001 Lionel Seinturier 004 005 This program is free software; you can redistribute it and/or modify 006 it under the terms of the GNU Lesser General Public License as 007 published by the Free Software Foundation; either version 2 of the 008 License, or (at your option) any later version. 009 010 This program is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 GNU Lesser General Public License for more details. 014 015 You should have received a copy of the GNU Lesser Generaly Public License 016 along with this program; if not, write to the Free Software 017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 018 019 package org.objectweb.jac.core.dist.rmi; 020 021 import org.objectweb.jac.core.dist.RemoteContainer; 022 import org.objectweb.jac.core.dist.Distd; 023 024 import java.rmi.Naming; 025 026 027 /** 028 * RMINaming wraps the RMI naming registry. 029 * The class method resolve() 030 * is dynamically called by org.objectweb.jac.dist.RemoteContainer.resolve(String) 031 * and statically by RMIRemoteRef.resolve(String). 032 * 033 * @author <a href="http://www-src.lip6.fr/homepages/Lionel.Seinturier/index-eng.html">Lionel Seinturier</a> 034 */ 035 036 public class RMINaming { 037 038 /** 039 * This method resolves a container from a container name. 040 * 041 * @param contName the name of the container 042 * @return the container reference, null if not resolved */ 043 044 public static RemoteContainer resolve( String contName ) { 045 046 RMIRemoteContainerInterf stub = null; 047 048 contName = Distd.getFullHostName( contName ); 049 050 try { 051 stub = (RMIRemoteContainerInterf) Naming.lookup(contName); 052 return new RMIRemoteContainerStub( stub, contName ); 053 } catch( Exception e ) { 054 return null; 055 } 056 057 } 058 059 }