避免使用不推荐的应用程序管理 moveModule 方法

此规则会标记是否使用了下列应用程序管理方法:

WebSphere Application Server V5.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);
}

有关更多类信息,请参阅信息中心中的下列内容: