發布: 2008-5-23 11:33 |
作者: 不詳 |
來源:
http://www-900.ibm.com/developerWorks |
查看: 146次 | 進入軟件測試論壇討論
領測軟件測試網
除了對等通信采用的 SPP(簡單點到點)包之外,P2P 應用程序不包含很多類。首先,我們先仔細查看最重要的類,最后再看一下 SPP 通信包。
資源
P2P 應用程序的主要組件是資源。事實上,P2P 應用程序只是允許和控制對已發布資源的遠程訪問。資源可以是任何可尋址的事物 -- 文件系統、電話簿、數據庫和目錄。每個資源都管理零個或多個適當類型的項(文件系統資源管理文件,電話簿資源管理電話號碼)。
為演示如何實現資源,我創建了一個簡單的文件系統資源類 FileResource,如清單 3 所示。這個文件系統資源管理零個或多個文件。
清單 3. Resource 接口
public
interface Resource
{
// The initialize() method requires a TTDFactory instance
// (which the factory uses to create the TTDItem instances
// it returns from the select() method in response to a
// query) and a String array (which contains the arguments
// from the configuration file).
public
void
initialize(TTDFactory ttdfactory, String [] arstring)
throws ResourceException;
// The select() method requires a String instance that
// defines the selection criteria. It returns an array
// of TTDItems, one for each entry that matches the
// selection criteria.
public
TTDItem []
select(String stringSelector)
throws ResourceException;
}
|
Resource 接口定義資源的結構和行為。該接口還定義允許在資源上執行的操作。目前的操作列表包括 select。以后的實現還將包括 insert 和 delete。
文章來源于領測軟件測試網 http://www.kjueaiud.com/