⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serverinstall.java

📁 移动Agent编程工具Naplet
💻 JAVA
字号:
/* * @<#>ServerInstall.java version 0.0.1, 1/1/2000 * * THIS PROGRAM IS FREE SOFTWARE; YOU CAN DISTRIBUTED IT AND/OR * MODIFY IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION. * * THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, * BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE * GNU GENERAL PUBLIC LICENSE FOR MORE DETAILS. * * Copyright (c) 2000 Wayne State University. All Rights Reserved. */package naplet.server;import java.io.*;import java.util.*;// import naplet.NapletConfigurationException;/** * The <code>ServerInstall</code> class set default configuration * * @version 0.0.1, 1/1/2000 * @author C. Xu */public class ServerInstall{  /**   * constructs a ServerInstall.   *   * @param configFile the configuration file of naplet server   */  public ServerInstall( String cfgFile )  {    Map configParameters = parseConfigFile( cfgFile );    try    {      NapletServerImpl server = new NapletServerImpl( configParameters );      ThreadGroup aGroup = new ThreadGroup( "NapletServer" );      Thread aThread = new Thread( aGroup, server, "NapletServerMain" );      aThread.start();    }    catch ( ServerConfigException sce )    {      System.out.println( "Server configuration exception " + sce.getMessage() );      System.exit( 1 );    }    catch ( ServiceInstallException sie )    {      System.out.println( "Service installation exception " + sie.getMessage() );      System.exit( 1 );    }    catch ( java.rmi.RemoteException re )    {      re.printStackTrace();      System.exit( 1 );    }  }  /**   * Usage: java ServerInstall [configFile]   */  public static void main( String args[] )  {    String configFile = null;    if ( args.length == 1 )    {      configFile = args[0];    }    else    {      System.out.println( "Usage: ServerInstall configuration" );      System.exit( 1 );    }    new ServerInstall( configFile );  }  private Map parseConfigFile( String fname )  {    File configFile = new File( fname );    if ( !configFile.exists() || !configFile.canRead() )    {      System.out.println( "Config file " + fname +                          "doesn't exist or unreadable" );    }    BufferedReader in = null;    try    {      in = new BufferedReader( new FileReader( configFile ) );    }    catch ( FileNotFoundException e )    {}    Map aMap = Collections.synchronizedMap( new HashMap() );    while ( true )    {      try      {        String line = in.readLine();        if ( line == null )        {          break;        }        if ( !line.startsWith( "#" ) || !line.startsWith( " " ) )        {          int delim = line.indexOf( "=" );          if ( delim != -1 )          {            aMap.put( ( new StringTokenizer(                line.substring( 0, delim ) ) ).nextToken(),                      ( line.substring( delim + 2, line.length() ) ) );          }        }      }      catch ( IOException ioe )      {        System.out.println( "config file " + fname                            + ": File read error" );      }    }    return aMap;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -