EMF模型解析的策略分析

2021-04-13 21:25:46 字數 1076 閱讀 5562

今天看到兩種使用emf解析.xml為emf模型的策略:

一種是通過如下**:

word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee">

ifileeditorinput modelfile  =  (ifileeditorinput)geteditorinput();

uri resourceuri  =  uri.createplatformresourceuri(modelfile.getfile().getfullpath().tostring());;

resource  =  editingdomain.getresourceset().getresource(resourceuri,  true );

上面這種方式會引用乙個adapte***ctoryeditingdomain類,但我們基於模型做編輯器時,有時並不需要用這個類,例如gef,它具有自身的editordomain。

另外一種方式是使用emf模型自動生成的process,該類一般在模型的util包下面,引用**如下:

ifileeditorinput modelfile = (ifileeditorinput)geteditorinput();        

xmlprocessor processor =  new designxmlprocessor();            

resource = processor.load(new inputsource(new inputstreamreader(modelfile.getfile().getcontents(), "gbk")), null);

其實,對於emf而言,上面兩種解釋方式,歸根到底都需要emf獲得 業務模型相關的解析器,對於第一種方式,emf是如何獲取到業務模型的解析器呢?主要是通過擴充套件的方式,擴充套件定義在模型的plugin.xml中,**片斷如下圖所示:

這樣,解析.xml檔案時,emf從resourcefactory註冊中,根據相應的type,獲取解析器(designresourcefactoryimpl),完成解析。進入討論組討論。

LruCache原始碼解析 快取策略分析

最近在學習glide原始碼用到了lrucache,lru least recently used 的意思就是近期最少使用演算法,它的核心思想就是會優先淘汰那些近期最少使用的快取物件。有序map,此處用到了基於訪問的排序 private final linkedhashmapmap 當前快取容量 pr...

pytorch的模型解析

如何獲取pytorch的動態圖?model torch.jit.load test.pth graph model.graph.copy torch.c.jit pass inline graph node list graph.nodes 載入模型後,獲取模型的graph,這個graph就是需要的...

分庫分表的策略解析

分庫分表的策略。1.中間變數 user id 分庫數量 每個庫的表數量 2.庫 取整數 中間變數 每個庫的表數量 3.表 中間變數 每個庫的表數量 假設將原來的單庫單錶order拆分成256個庫,每個庫包含1024個表,那麼按照前面所提到的路由策略,對於user id 262145 的訪問,路由的計...