IBM FileNet P8, バージョン 5.2.1            

CodeModule オブジェクトの更新

CodeModule オブジェクト内に格納されたアクション・ハンドラーを変更する場合は、まずアクション・ハンドラーの新バージョンを使用して、CodeModule オブジェクトを更新する必要があります。 次いで、更新したコード・モジュールを参照するサブクラス化された Action オブジェクトをすべて更新する必要があります。

以下の Java™ および C# の例では、以前に JAR ファイル EventHandlers.jar にアーカイブされたイベント・ハンドラーの更新プロセスを示しています。この JAR ファイルは CodeModule オブジェクトのコンテンツ・エレメントに格納されています。 ハンドラーが変更されて EventHandlers.jar に再アーカイブされると、新しいバージョンの EventHandlers.jarCodeModule オブジェクトを更新する準備ができたことになります。

まず、新規 JAR ファイルのコンテンツが ContentTransfer オブジェクトとして取得され、ContentElementList に格納されます。次に、CodeModule オブジェクトの現在のバージョンがチェックアウトされ、予約オブジェクトが取得され、予約オブジェクトの ContentElements プロパティーが ContentElementList オブジェクトに設定されます。 予約オブジェクトがチェックインされ、CodeModule オブジェクトの新バージョンになります。

更新された CodeModule オブジェクトは EventAction オブジェクトによって参照されます。そのため、このオブジェクトは、CodeModule オブジェクトの現在のバージョンを参照するように更新する必要があります。 この例の 2 番目の部分に示すように、EventAction オブジェクトの CodeModule プロパティーは、CodeModule オブジェクトの現在のバージョンに設定されます。

Java の例

...
// Create a File object for the JAR containing the updated event handler.
File newHandlerVersion = new File("C:¥¥EclipseWorkspace¥¥EventHandlers¥¥EventHandlers.jar");
// non-Windows: File newHandlerVersion = new File("/EclipseWorkspace/EventHandlers/EventHandlers.jar");
           
// 更新済み JAR コンテンツから ContentTransfer オブジェクトを作成する
ContentElementList contentList = Factory.ContentTransfer.createList();
ContentTransfer ctNew;
FileInputStream fileIS;
ctNew = Factory.ContentTransfer.createInstance();
fileIS = new FileInputStream(newHandlerVersion.getAbsolutePath());
ctNew.setCaptureSource(fileIS);
ctNew.set_ContentType("application/java-archive");
contentList.add(ctNew);

// 現在のバージョンの CodeModule オブジェクトをチェックアウトする
CodeModule cm = Factory.CodeModule.getInstance(os, "/CodeModules/EventHandlers.jar");
cm.checkout(com.filenet.api.constants.ReservationType.EXCLUSIVE, null, null, null);
cm.save(RefreshMode.REFRESH);

// チェックアウトされたコード・モジュールから予約オブジェクトを取得する
// このオブジェクトが、コード・モジュールの新しいバージョンになる
CodeModule cmUpdate = (CodeModule) cm.get_Reservation();


// 予約オブジェクトに新しいコンテンツを設定する
cmUpdate.set_ContentElements(contentList);

// 新しいバージョンのコード・モジュールをチェックインする
cmUpdate.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
cmUpdate.save(RefreshMode.REFRESH);
 
/////////////////////////////////////////////
// Get event action to update its CodeModule property.
PropertyFilter pf = new PropertyFilter();
pf.addIncludeType(1, null, null, FilteredPropertyType.SINGLETON_OBJECT, new Integer(1) );
pf.addIncludeProperty(0, null, Boolean.TRUE, PropertyNames.CODE_MODULE, new Integer(1) );
EventAction eventAction = Factory.EventAction.fetchInstance(os, new Id("{94AF1BB3-A4A7-4851-9067-D6F88005C470}"), pf); 

// CodeModule プロパティーの設定
eventAction.set_CodeModule(cmUpdate);

eventAction.save(RefreshMode.REFRESH); 
}

C# の例

...
// Create a Stream object for the JAR containing the updated event handler.
Stream fileStream = File.OpenRead(@"C:¥¥EclipseWorkspace¥¥EventHandlers¥¥EventHandlers.jar");

// 更新済み JAR コンテンツから IContentTransfer オブジェクトを作成する
IContentElementList contentList = Factory.ContentTransfer.CreateList();
IContentTransfer ctNew;
ctNew = Factory.ContentTransfer.CreateInstance();
ctNew.SetCaptureSource(fileStream);
ctNew.ContentType = "application/java-archive";
contentList.Add(ctNew);

// 現在のバージョンの CodeModule オブジェクトをチェックアウトする
ICodeModule cm = Factory.CodeModule.GetInstance(os, "/CodeModules/EventHandlers.jar");
cm.Checkout(ReservationType.EXCLUSIVE, null, null, null);
cm.Save(RefreshMode.REFRESH);

// チェックアウトされたコード・モジュールから予約オブジェクトを取得する
// このオブジェクトが、コード・モジュールの新しいバージョンになる
ICodeModule cmUpdate = (ICodeModule)cm.Reservation;

// 予約オブジェクトに新しいコンテンツを設定する
cmUpdate.ContentElements = contentList;

// 新しいバージョンのコード・モジュールをチェックインする
cmUpdate.Checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
cmUpdate.Save(RefreshMode.REFRESH);

/////////////////////////////////////////////
// Get event action to update its CodeModule property.
PropertyFilter pf = new PropertyFilter();
pf.AddIncludeType(1, null, null, FilteredPropertyType.SINGLETON_OBJECT, 1);
pf.AddIncludeProperty(0, null, true, PropertyNames.CODE_MODULE, 1);
IEventAction eventAction = Factory.EventAction.FetchInstance(os, new Id("{94AF1BB3-A4A7-4851-9067-D6F88005C470}"), pf);

// CodeModule プロパティーの設定
eventAction.CodeModule = cmUpdate;

eventAction.Save(RefreshMode.REFRESH);
}


最終更新日: 2015 年 10 月
server_procedures_codemodule_updating.htm

© Copyright IBM Corp. 2015.