1

私はこのクラスを持っています:

public class Source extends Node {
  protected DistributionSampler delay ;
  protected DistributionSampler batchsize ;


/**
 * @param name The name of the source node
 * @param d The {@link DistributionSampler} used to generate the
 *          inter-arrival times
*/
  public Source( String name, DistributionSampler d ) {
    super( name ) ;
    delay = d ;
    batchsize = new Deterministic( 1 ) ;
    Sim.schedule( new Arrival( Sim.now() + delay.next() ) ) ;
  }

/**
 * @param name The name of the source node
 * @param d The {@link DistributionSampler} used to generate the
 *          inter-arrival times
 * @param b The {@link DistributionSampler} used to generate the
            batch sizes
*/
  public Source( String name, DistributionSampler d, DistributionSampler b ) {
    super( name ) ;
    delay = d ;
    batchsize = b ;
    Sim.schedule( new Arrival( Sim.now() + delay.next() ) ) ;
  }

   ....
}

DistributionSamplerはAbstractClassです。

XMLからJavaオブジェクトへの変換時に、(Bean名を介して)使用する抽象クラスの具体的な実装を確認します。

ただし、マッピングファイルを作成して、キャスターに翻訳の方法を指示する方法が完全にはわかりません。

どんな助けでも大歓迎です。

4

1 に答える 1

1
<class name="network.Source">
        <description xmlns="">
            Default mapping for class network.Source
        </description>

        <map-to xml="Source"/>

        <field name="name" type="java.lang.String" required="true">
            <bind-xml  node="element" />
        </field>

        <field name="delay" type="tools.DistributionSampler" required="true" set-method="initialiseDelay" get-method="getDelay">
            <bind-xml  auto-naming="deriveByClass" node="element" location="delay"/>
        </field>

        <field name="batchSize" type="tools.DistributionSampler">
            <bind-xml  auto-naming="deriveByClass" node="element" location="batchSize"/>
        </field>
    </class>

auto-naming = "deriveByClass"の部分は、送信すると、delay内に埋め込まれた要素のノード名を、distributionSamplerを拡張することを期待する同等のクラスにバインドすることを意味します。

したがって、次のxmlを処理することに満足しています。

<Source name="asd">
    <delay>
        <Deterministic time="234" />
    </delay>

    <batchSize>
        <Erlang K="234" Theta="234" />
    </batchSize>
</Source>

DeterministicとErlangのマッピングファイルを使用して、DistributionSamplerを拡張するクラスインスタンスにマッピングします。

于 2010-03-05T21:43:42.087 に答える