避免使用已淘汰的應用程式管理 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);
}

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