WEB开发网
开发学院软件开发Java 使用 JAX-RPC 访问 IBM WebSphere Service Regist... 阅读

使用 JAX-RPC 访问 IBM WebSphere Service Registry and Repository

 2009-10-23 00:00:00 来源:WEB开发网   
核心提示: staticDataGraphTypecreateDataGraph(BaseObject[]objects,StringrootID){WSRRwsrr=newWSRR();wsrr.setArtefacts(objects);wsrr.setRoot(rootID);DataGraphTyp

static DataGraphType createDataGraph(BaseObject[] objects, 
                   String rootID) { 
  WSRR wsrr = new WSRR(); 
  wsrr.setArtefacts(objects); 
  wsrr.setRoot(rootID); 
  DataGraphType dg = new DataGraphType(); 
  dg.setWSRR(wsrr); 
  return dg; 
}

处理返回的 DataGraphType 实例

在处理从查询或检索操作返回的 DataGraphType 实例时,为数据图中的所有对象建立索引将非常有用。如上所述,由于只将数据图中的另一个对象不包含的对象添加到构件数组中,因此,仅了解构件数组中的对象是不够的。

以下代码处理 DataGraphType 实例,并通过跟踪构件数组内的每个对象中所有可能的包含关系来生成找到的所有对象的 HashMap。

static HashMap buildHashMap(DataGraphType dg) { 
  HashMap hm = new HashMap(); 
  BaseObject[] topLevelObjects = dg.getWSRR().getArtefacts(); 
  mapArrayOfBaseObjects(hm, topLevelObjects); 
  return hm; 
} 
 
private static void mapArrayOfBaseObjects(HashMap hm, 
                     BaseObject[] baseObjects) { 
  int arrayLength = baseObjects.length; 
  for (int i = 0; i < arrayLength; i++) { 
    BaseObject baseObject = baseObjects[i]; 
    mapBaseObject(hm, baseObject); 
  } 
} 
 
private static void mapBaseObject(HashMap hm, BaseObject baseObject) { 
  String bsrURI = baseObject.getBsrURI(); 
  if (hm.get(bsrURI) == null) { 
    hm.put(bsrURI, baseObject); 
  } 
  /* 
   * Now follow containment relationships, recursing to add either a 
   * single object or an array of objects as appropriate. 
   */ 
  if (baseObject instanceof ComplexTypeDefinition) { 
    ComplexTypeDefinition ctd = (ComplexTypeDefinition) baseObject; 
    mapArrayOfBaseObjects(hm, ctd.getLocalAttributes()); 
  } else if (baseObject instanceof Export) { 
    Export exp = (Export) baseObject; 
    mapBaseObject(hm, exp.getExportBinding()); 
    mapArrayOfBaseObjects(hm, exp.getInterfaces()); 
  } else if (baseObject instanceof _import) { 
    _import imp = (_import) baseObject; 
    mapBaseObject(hm, imp.getImportBinding()); 
    mapArrayOfBaseObjects(hm, imp.getInterfaces()); 
  } else if (baseObject instanceof Module) { 
    Module module = (Module) baseObject; 
    mapArrayOfBaseObjects(hm, module.getImports()); 
    mapArrayOfBaseObjects(hm, module.getExports()); 
  } else if (baseObject instanceof WSDLBinding) { 
    mapBaseObject(hm, ((WSDLBinding) baseObject).getSOAPBinding()); 
  } else if (baseObject instanceof WSDLMessage) { 
    mapArrayOfBaseObjects(hm, 
             ((WSDLMessage) baseObject).getMessageParts()); 
  } else if (baseObject instanceof WSDLPort) { 
    mapBaseObject(hm, ((WSDLPort) baseObject).getSOAPAddress()); 
  } else if (baseObject instanceof WSDLPortType) { 
    mapArrayOfBaseObjects(hm, 
             ((WSDLPortType) baseObject).getOperations()); 
  } else if (baseObject instanceof WSDLService) { 
   mapArrayOfBaseObjects(hm, ((WSDLService) baseObject).getPorts()); 
  } 
} 

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:使用 JAX RPC

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接