protected static String getStatusToolTip() { StringBuffer result = new StringBuffer("<html>"); // NOI18N result.append("<table cellspacing=\"0\" border=\"0\">"); // NOI18N final CollabManager manager = CollabManager.getDefault(); if (manager != null) { Set sessions = new TreeSet( new Comparator() { public int compare(Object o1, Object o2) { String s1 = ((CollabSession) o1).getUserPrincipal().getDisplayName(); String s2 = ((CollabSession) o2).getUserPrincipal().getDisplayName(); return s1.compareTo(s2); } }); sessions.addAll(Arrays.asList(manager.getSessions())); if (sessions.size() == 0) { result.append("<tr><td>"); // NOI18N result.append(getStatusDescription(CollabPrincipal.STATUS_OFFLINE)); result.append("</td></tr>"); // NOI18N } else { for (Iterator i = sessions.iterator(); i.hasNext(); ) { CollabPrincipal principal = ((CollabSession) i.next()).getUserPrincipal(); result.append("<tr>"); // NOI18N result.append("<td>"); // NOI18N result.append("<b>"); // NOI18N result.append(principal.getDisplayName()); result.append(": "); // NOI18N result.append("</b>"); // NOI18N result.append("</td>"); // NOI18N result.append("<td>"); // NOI18N result.append(getStatusDescription(principal.getStatus())); result.append("</td>"); // NOI18N result.append("</tr>"); // NOI18N } } } result.append("</table>"); // NOI18N return result.toString(); }
/* PROTECTED METHODS */ protected void getBeanElements( Element parentElement, String objectName, String objectType, Object bean) throws IntrospectionException, IllegalAccessException { if (objectName == null) { // Get just the class name by lopping off the package name StringBuffer sb = new StringBuffer(bean.getClass().getName()); sb.delete(0, sb.lastIndexOf(".") + 1); objectName = sb.toString(); } // Check if the bean is a standard Java object type or a byte[] (encoded as a base 64 array) Element element = getStandardObjectElement(document, bean, objectName); // If the body element object is null then the bean is not a standard Java object type if (element != null) { if (includeNullValues || !element .getAttribute( NamespaceConstants.NSPREFIX_SCHEMA_XSI + ":" + org.apache.axis.Constants.ATTR_TYPE) .equals("anyType")) { if (!includeTypeInfo) { element.removeAttribute( NamespaceConstants.NSPREFIX_SCHEMA_XSI + ":" + org.apache.axis.Constants.ATTR_TYPE); element.removeAttribute(NamespaceConstants.NSPREFIX_SCHEMA_XSI + ":null"); } parentElement.appendChild(element); } } else { // Analyze the bean Class classOfBean = null; if (bean != null) classOfBean = bean.getClass(); // If the object is an array, then serialize each of the beans in the array. if ((classOfBean != null) && (classOfBean.isArray())) { String[] arrayInfo = getXsdSoapArrayInfo(classOfBean.getCanonicalName(), nsPrefix); int arrayLen = Array.getLength(bean); StringBuffer arrayType = new StringBuffer(arrayInfo[1]); arrayType.insert(arrayType.indexOf("[]") + 1, arrayLen); if (objectName.charAt(objectName.length() - 1) == ';') objectName = new StringBuffer(objectName).deleteCharAt(objectName.length() - 1).toString(); element = document.createElement(objectName); parentElement.appendChild(element); // Get the bean objects from the array and serialize each for (int i = 0; i < arrayLen; i++) { Object b = Array.get(bean, i); if (b != null) { String name = null; if (objectName.charAt(objectName.length() - 1) == 's') { name = formatName(objectName.substring(0, objectName.length() - 1)); } getBeanElements(element, name, b.getClass().getName(), b); } else { // Array element is null, so don't include it and decrement the # elements in the array int index = arrayType.indexOf("["); arrayType.replace(index + 1, index + 2, String.valueOf(--arrayLen)); } if (includeTypeInfo) { element.setAttributeNS( NamespaceConstants.NSURI_SCHEMA_XSI, NamespaceConstants.NSPREFIX_SCHEMA_XSI + ":" + Constants.ATTR_TYPE, NamespaceConstants.NSPREFIX_SOAP_ENCODING + ":Array"); element.setAttributeNS( NamespaceConstants.NSURI_SOAP_ENCODING, NamespaceConstants.NSPREFIX_SOAP_ENCODING + ":" + Constants.ATTR_ARRAY_TYPE, arrayInfo[0] + ":" + arrayType.toString()); } } } else { int beanType = 0; String beanName = null; if (classOfBean != null) { if (classOfBean == Vector.class) { beanType = 1; beanName = "Vector"; } else if (classOfBean == ArrayList.class) { beanType = 2; beanName = "ArrayList"; } else if (classOfBean == LinkedList.class) { beanType = 3; beanName = "LinkedList"; } else if (classOfBean == Hashtable.class) { beanType = 4; beanName = "Hashtable"; } else if (classOfBean == Properties.class) { beanType = 5; beanName = "Properties"; } else if ((classOfBean == HashMap.class) || (classOfBean == SortedMap.class)) { beanType = 6; beanName = "Map"; } } if (beanType > 0) { String prefix = null; if ((beanType == 1) || (beanType == 5)) prefix = NamespaceConstants.NSPREFIX_SOAP_ENCODING; if (beanType == 6) prefix = Constants.NS_PREFIX_XMLSOAP; else prefix = DEFAULT_NS_PREFIX; element = document.createElement(objectName); if (includeTypeInfo) { element.setAttributeNS( NamespaceConstants.NSURI_SCHEMA_XSI, NamespaceConstants.NSPREFIX_SCHEMA_XSI + ":" + Constants.ATTR_TYPE, prefix + ":" + beanName); if (bean == null) element.setAttributeNS( NamespaceConstants.NSURI_SCHEMA_XSI, NamespaceConstants.NSPREFIX_SCHEMA_XSI + ":null", "true"); } parentElement.appendChild(element); if ((beanType >= 1) && (beanType <= 3)) { AbstractCollection collection = (AbstractCollection) bean; // Get the bean objects from the vector and serialize each Iterator it = collection.iterator(); while (it.hasNext()) { Object b = it.next(); String name = null; if (b != null) { if (objectName.charAt(objectName.length() - 1) == 's') { name = formatName(objectName.substring(0, objectName.length() - 1)); } else name = "item"; } getBeanElements(element, name, b.getClass().getName(), b); } } else if ((beanType == 4) || (beanType == 5)) { Hashtable hashtable = (Hashtable) bean; // Get the bean objects from the hashtable or properties and serialize each Enumeration en = hashtable.keys(); while (en.hasMoreElements()) { Object key = en.nextElement(); String keyClassName = key.getClass().getName(); Object value = hashtable.get(key); String beanClassName = null; if (value != null) beanClassName = value.getClass().getName(); Element itemElement = document.createElement("item"); element.appendChild(itemElement); getBeanElements(itemElement, "key", keyClassName, key); getBeanElements(itemElement, "value", beanClassName, value); } } else if (beanType == 6) { Map map = null; if (classOfBean == HashMap.class) map = (HashMap) bean; else if (classOfBean == SortedMap.class) map = (SortedMap) bean; // Get the bean objects from the hashmap and serialize each Set set = map.keySet(); Iterator it = set.iterator(); while (it.hasNext()) { Object key = it.next(); String keyClassName = key.getClass().getName(); Object value = map.get(key); String beanClassName = null; if (value != null) beanClassName = value.getClass().getName(); Element itemElement = document.createElement("item"); element.appendChild(itemElement); getBeanElements(itemElement, "key", keyClassName, key); getBeanElements(itemElement, "value", beanClassName, value); } } } else { // Create a parent element for this bean's properties if (objectName.charAt(objectName.length() - 1) == ';') objectName = new StringBuffer(objectName).deleteCharAt(objectName.length() - 1).toString(); objectName = formatName(objectName); element = document.createElement(objectName); parentElement.appendChild(element); if (includeTypeInfo) { StringBuffer className = new StringBuffer(objectType); element.setAttributeNS( NamespaceConstants.NSURI_SCHEMA_XSI, NamespaceConstants.NSPREFIX_SCHEMA_XSI + ":" + Constants.ATTR_TYPE, nsPrefix + ":" + className.delete(0, className.lastIndexOf(".") + 1).toString()); } if (classOfBean != null) { // Get an array of property descriptors BeanInfo bi = Introspector.getBeanInfo(classOfBean); PropertyDescriptor[] pds = bi.getPropertyDescriptors(); // For each property of the bean, get a SOAPBodyElement that // represents the individual property. Append that SOAPBodyElement // to the class name element of the SOAP body. for (int i = 0; i < pds.length; i++) { PropertyDescriptor pd = pds[i]; getBeanElementProperties(element, bean, pd); } } else { if (includeTypeInfo) element.setAttributeNS( NamespaceConstants.NSURI_SCHEMA_XSI, NamespaceConstants.NSPREFIX_SCHEMA_XSI + ":null", "true"); } } } } }
public void buildTypeGraph() { Map<String, JarFile> openJarFiles = new HashMap<String, JarFile>(); Map<String, File> openClassFiles = new HashMap<String, File>(); // use global cache to load resource in/out of the same jar as the classes Set<String> resourceCacheSet = new HashSet<>(); try { for (String path : pathsToScan) { File f = null; try { f = new File(path); if (!f.exists() || f.isDirectory() || (!f.getName().endsWith("jar") && !f.getName().endsWith("class"))) { continue; } if (GENERATED_CLASSES_JAR.equals(f.getName())) { continue; } if (f.getName().endsWith("class")) { typeGraph.addNode(f); openClassFiles.put(path, f); } else { JarFile jar = new JarFile(path); openJarFiles.put(path, jar); java.util.Enumeration<JarEntry> entriesEnum = jar.entries(); while (entriesEnum.hasMoreElements()) { final java.util.jar.JarEntry jarEntry = entriesEnum.nextElement(); String entryName = jarEntry.getName(); if (jarEntry.isDirectory()) { continue; } if (entryName.endsWith("-javadoc.xml")) { try { processJavadocXml(jar.getInputStream(jarEntry)); // break; } catch (Exception ex) { LOG.warn("Cannot process javadoc {} : ", entryName, ex); } } else if (entryName.endsWith(".class")) { TypeGraph.TypeGraphVertex newNode = typeGraph.addNode(jarEntry, jar); // check if any visited resources belong to this type for (Iterator<String> iter = resourceCacheSet.iterator(); iter.hasNext(); ) { String entry = iter.next(); if (entry.startsWith(entryName.substring(0, entryName.length() - 6))) { newNode.setHasResource(true); iter.remove(); } } } else { String className = entryName; boolean foundClass = false; // check if this resource belongs to any visited type while (className.contains("/")) { className = className.substring(0, className.lastIndexOf('/')); TypeGraph.TypeGraphVertex tgv = typeGraph.getNode(className.replace('/', '.')); if (tgv != null) { tgv.setHasResource(true); foundClass = true; break; } } if (!foundClass) { resourceCacheSet.add(entryName); } } } } } catch (IOException ex) { LOG.warn("Cannot process file {}", f, ex); } } typeGraph.trim(); typeGraph.updatePortTypeInfoInTypeGraph(openJarFiles, openClassFiles); } finally { for (Entry<String, JarFile> entry : openJarFiles.entrySet()) { try { entry.getValue().close(); } catch (IOException e) { DTThrowable.wrapIfChecked(e); } } } }