/*
**	Class:			ShowRemoteProperty
**	Version:		1.1.0
**	Author:			Dario de Judicibus
**	E-mail:			dejudicibus@geocities.com
**	Created on:		June 10th, 1998
**	Changed on:		June 21st, 1998
**	Language:		Java (jdk 1.1)
**	-------------------------------------------------------------
**	(c) 1998 - All rights reserved
**	-------------------------------------------------------------
**	I make no representations or warranties about the suitability of
**	the software, either express or implied, including but not limited
**	to the implied warranties of merchantability, fitness for a
**	particular purpose, or non-infringement. I shall not be liable for
**	any damages suffered by licensee as a result of using, modifying or
**	distributing this software or its derivatives.
*/

import java.rmi.* ;
import java.rmi.server.* ;

/**
 *	@author Dario de Judicibus
 *	@version 1.0.0
 *	@see jdk 1.1
 *	Show the value of a remote property by using SystemProperties class
 *	<BR><B>1.1.0</B> - Added cvServerName
 */
class ShowRemoteProperty
{
	private static String cvObjectName = "RemoteProperty" ;

	public static void main( String[] args )
	{
   		// Create and install a security manager
		System.setSecurityManager( new RMISecurityManager( ) ) ;

		String propertyName = null ;
		String serverUrl 	= null ;

		if ( args.length == 1 )
		{
			propertyName = args[ 0 ] ;
			serverUrl	 = cvObjectName ;
		}
		else if ( args.length == 2 )
		{
			propertyName = args[ 1 ] ;
			serverUrl	 = "rmi://" + args[0] + "/" + cvObjectName ;
		}
		else
		{
			System.out.println( "Synopsys: ShowRemoteProperty [server_name] property_name" ) ;
		}

		if ( propertyName != null )
		{
			try
			{
				RemoteProperty ps = (RemoteProperty)Naming.lookup( serverUrl ) ;
				String propertyValue = ps.getValue( propertyName ) ;
				System.out.println( "Property '"
								  + propertyName
								  + "' has value '"
								  + propertyValue
								  + "'."
								  ) ;

			}
			catch ( Exception e )
			{
				System.out.println( serverUrl + " exception: " + e.getMessage( ) ) ;
				e.printStackTrace( );
			}
		}
	}
}