/*
* Download and parse the cell configuration information. Create a
* new cell based upon the information.
*/
CellServerState setup = CellImporterUtils.getWFSCell(root, relativePath, child.name);
if (setup == null) {
logger.info("WFSLoader: unable to read cell setup info " + relativePath + "/" + child.name);
continue;
}
logger.info(setup.toString());
/*
* If the cell is at the root, then the relative path will be "/"
* and we do not want to prepend it to the cell path.
*/
String cellPath = relativePath + "/" + child.name;
if (relativePath.compareTo("") == 0) {
cellPath = child.name;
}
/*
* Create the cell and pass it the setup information
*/
String className = setup.getServerClassName();
CellMO cellMO = CellMOFactory.loadCellMO(className);
if (cellMO == null) {
/* Log a warning and move onto the next cell */
logger.warning("Unable to load cell MO: " + className);
continue;
}
/* Set the cell name */
// cellMO.setName(child.name);
/** XXX TODO: add an import details cell component XXX */
/* Call the cell's setup method */
try {
cellMO.setServerState(setup);
} catch (ClassCastException cce) {
logger.log(Level.WARNING, "Error setting up new cell " +
cellMO.getName() + " of type " +
cellMO.getClass(), cce);
continue;
}
/*
* Add the child to the cell hierarchy. If the cell has no parent,
* then we insert it directly into the world
*/
try {
if (parentRef == null) {
WonderlandContext.getCellManager().insertCellInWorld(cellMO);
}
else {
logger.info("WFSLoader: Adding child (ID=" + cellMO.getCellID().toString() +
") to parent (ID=" + parentRef.get().getCellID().toString() + ")");
parentRef.get().addChild(cellMO);
logger.info("WFSLoader: Parent Cell ID=" + cellMO.getParent().getCellID().toString());
Collection<ManagedReference<CellMO>> refs = cellMO.getParent().getAllChildrenRefs();
Iterator<ManagedReference<CellMO>> it = refs.iterator();
while (it.hasNext() == true) {
logger.info("WFSLoader: Child Cell=" + it.next().get().getCellID().toString());
}
logger.info("WFSLoader: Cell Live: " + cellMO.isLive());
}
} catch (MultipleParentException excp) {
logger.log(Level.WARNING, "Attempting to add a new cell with " +
"multiple parents: " + cellMO.getName());
continue;
}
/*
* Since we are loading cells for the first time, we put the cell
* in both the cell object and last modified reference map. We
* add the cell to its parent. If the parent is null, we add to the
* root.
*/
ManagedReference<CellMO> cellRef = AppContext.getDataManager().createReference(cellMO);
this.cellMOMap.put(cellPath, cellRef);
logger.info("WFSLoader: putting " + cellPath + " (ID=" + cellMO.getCellID().toString() + ") into map with " + child.lastModified);
logger.info(setup.toString());
/*
* See if the cell has any children and add to the linked list.
*/
CellList newChildren = CellImporterUtils.getWFSChildren(root, cellPath);