避免使用已淘汰的應用程式管理 moveModule 方法

此規則會標示使用的下列應用程式管理方法:

這些方法在 WebSphere Application Server 5.0 版中已淘汰,並且不提供任何功能。 它們可以取代為相同類別中的 setModuleInfo 方法呼叫。

例如,moveModule 呼叫可能如下:

appManagement.moveModule(appName, prefs, uniqueModuleURI, objectName, workspaceID);

當使用許多相同引數時,可以利用 setModuleInfo 方法,對它進行編碼。 範例如下所示:

int TARGET_COL = 2;
String newTarget = null;

// Get the new target from the ObjectName
if (objectName.getKeyProperty("server")!=null) {
newTarget = objectName.getKeyProperty("server");
} else if (objectName.getKeyProperty("cluster")!=null) {
newTarget = objectName.getKeyProperty("cluster");
}

if (newTarget!=null) {
Vector taskVector = appManagement.getModuleInfo(appName, prefs, uniqueModuleURI, workspaceID);
Iterator iter = taskVector.iterator();

// Loop through the task data
while ( iter.hasNext()) {
AppDeploymentTask task = (AppDeploymentTask) iter.next();
String taskName = task.getName().trim();

// Find the MapModulesToServers task
if (taskName.equals("MapModulesToServers")) {
String[][] taskData = task.getTaskData();
for (int i=1; i<taskData.length; i++) {
// update the target
taskData[i][TARGET_COL] = newTarget;
}
break;
}
}

appManagement.setModuleInfo(appName, prefs, uniqueModuleURI, workspaceID, taskVector);
}

如需類別的相關資訊,請參閱