Launcher#configure()メソッドはこんな感じ

public void configure( InputStream is )
    throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
{
    Configurator configurator = new Configurator( this );
    configurator.configure( is );
}

Cofiguratorクラスのインスタンスを作成して、さらにconfirue()メソッドを呼び出す。この時引数として渡すのは、上位から渡されたInputStreamだが、これはclassworlds.confを指しているのだった。

下記がそのメソッドとなる。

public void configure( InputStream is )
    throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
{
    if ( world == null )
    {
        world = new ClassWorld();
    }

    curRealm = null;

    foreignClassLoader = null;

    if ( this.launcher != null )
    {
        foreignClassLoader = this.launcher.getSystemClassLoader();
    }

    ConfigurationParser parser = new ConfigurationParser( this, System.getProperties() );

    parser.parse( is );

    // Associate child realms to their parents.
    associateRealms();

    if ( this.launcher != null )
    {
        this.launcher.setWorld( world );
    }

}

ここから先、「World」だの「Realm」だのという単語が入った、クラスや変数が登場する。これらが何を表しているのかは、今後徐々に把握していくとしよう。

メソッドの先頭では早速、ClassWorldのインスタンスを生成している。その後細かいことやって、本題となる設定ファイルの解析処理をしてくれるのが、ConfigurationParserというクラスのようだ。このクラスに、Launcherインスタンスへの参照(this)とSystemPropertiesを引数にしてコンストラクを読んでいる。そしてそのインスタンスのparse()メソッドにまたまた、上位から分かってきた、classworlds.confを指しているInputStreamを渡している。おそらくこのparse()メソッドの中で、classworlds.confの解析をしていくのだろう。

results matching ""

    No results matching ""