public Set<String> getOperatorClasses(String parent, String searchTerm) throws ClassNotFoundException { if (CollectionUtils.isEmpty(operatorClassNames)) { loadOperatorClass(); } if (parent == null) { parent = Operator.class.getName(); } else { if (!typeGraph.isAncestor(Operator.class.getName(), parent)) { throw new IllegalArgumentException("Argument must be a subclass of Operator class"); } } Set<String> filteredClass = Sets.filter( operatorClassNames, new Predicate<String>() { @Override public boolean apply(String className) { OperatorClassInfo oci = classInfo.get(className); return oci == null || !oci.tags.containsKey("@omitFromUI"); } }); if (searchTerm == null && parent.equals(Operator.class.getName())) { return filteredClass; } if (searchTerm != null) { searchTerm = searchTerm.toLowerCase(); } Set<String> result = new HashSet<String>(); for (String clazz : filteredClass) { if (parent.equals(Operator.class.getName()) || typeGraph.isAncestor(parent, clazz)) { if (searchTerm == null) { result.add(clazz); } else { if (clazz.toLowerCase().contains(searchTerm)) { result.add(clazz); } else { OperatorClassInfo oci = classInfo.get(clazz); if (oci != null) { if (oci.comment != null && oci.comment.toLowerCase().contains(searchTerm)) { result.add(clazz); } else { for (Map.Entry<String, String> entry : oci.tags.entrySet()) { if (entry.getValue().toLowerCase().contains(searchTerm)) { result.add(clazz); break; } } } } } } } } return result; }
/** * Notifies this <tt>Conference</tt> that the ordered list of <tt>Endpoint</tt>s of {@link * #speechActivity} i.e. the dominant speaker history has changed. * * <p>This instance notifies the video <tt>Channel</tt>s about the change so that they may update * their last-n lists and report to this instance which <tt>Endpoint</tt>s are to be asked for * video keyframes. */ private void speechActivityEndpointsChanged() { List<Endpoint> endpoints = null; for (Content content : getContents()) { if (MediaType.VIDEO.equals(content.getMediaType())) { Set<Endpoint> endpointsToAskForKeyframes = null; endpoints = speechActivity.getEndpoints(); for (Channel channel : content.getChannels()) { if (!(channel instanceof RtpChannel)) continue; RtpChannel rtpChannel = (RtpChannel) channel; List<Endpoint> channelEndpointsToAskForKeyframes = rtpChannel.speechActivityEndpointsChanged(endpoints); if ((channelEndpointsToAskForKeyframes != null) && !channelEndpointsToAskForKeyframes.isEmpty()) { if (endpointsToAskForKeyframes == null) { endpointsToAskForKeyframes = new HashSet<>(); } endpointsToAskForKeyframes.addAll(channelEndpointsToAskForKeyframes); } } if ((endpointsToAskForKeyframes != null) && !endpointsToAskForKeyframes.isEmpty()) { content.askForKeyframes(endpointsToAskForKeyframes); } } } }
public boolean isDirectTransferInProgress(final FrostUploadItem ulItem) { final String id = ulItem.getGqIdentifier(); if (directPUTsInProgress.contains(id)) { return true; } if (directPUTsWithoutAnswer.contains(id)) { return true; } return false; }
/** * Introspects the given class and returns event property descriptors for each writable property * found in the class itself, it's superclasses and all interfaces this class and the superclasses * implements. * * @param clazz is the Class to introspect * @return list of properties */ public static Set<WriteablePropertyDescriptor> getWritableProperties(Class clazz) { // Determine all interfaces implemented and the interface's parent interfaces if any Set<Class> propertyOrigClasses = new HashSet<Class>(); getImplementedInterfaceParents(clazz, propertyOrigClasses); // Add class itself propertyOrigClasses.add(clazz); // Get the set of property names for all classes return getWritablePropertiesForClasses(propertyOrigClasses); }
/** * Adds to the given list of property descriptors the mapped properties, ie. properties that have * a getter method taking a single String value as a parameter. * * @param clazz to introspect * @param result is the list to add to */ protected static void addMappedProperties(Class clazz, List<InternalEventPropDescriptor> result) { Set<String> uniquePropertyNames = new HashSet<String>(); Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { String methodName = methods[i].getName(); if (!methodName.startsWith("get")) { continue; } String inferredName = methodName.substring(3, methodName.length()); if (inferredName.length() == 0) { continue; } Class<?> parameterTypes[] = methods[i].getParameterTypes(); if (parameterTypes.length != 1) { continue; } if (parameterTypes[0] != String.class) { continue; } String newInferredName = null; // Leave uppercase inferred names such as URL if (inferredName.length() >= 2) { if ((Character.isUpperCase(inferredName.charAt(0))) && (Character.isUpperCase(inferredName.charAt(1)))) { newInferredName = inferredName; } } // camelCase the inferred name if (newInferredName == null) { newInferredName = Character.toString(Character.toLowerCase(inferredName.charAt(0))); if (inferredName.length() > 1) { newInferredName += inferredName.substring(1, inferredName.length()); } } inferredName = newInferredName; // if the property inferred name already exists, don't supply it if (uniquePropertyNames.contains(inferredName)) { continue; } result.add( new InternalEventPropDescriptor(inferredName, methods[i], EventPropertyType.MAPPED)); uniquePropertyNames.add(inferredName); } }
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(); }
private static void getImplementedInterfaceParents(Class clazz, Set<Class> classesResult) { Class[] interfaces = clazz.getInterfaces(); if (interfaces == null) { return; } for (int i = 0; i < interfaces.length; i++) { classesResult.add(interfaces[i]); getImplementedInterfaceParents(interfaces[i], classesResult); } }
private static void addIntrospectPropertiesWritable( Class clazz, Set<WriteablePropertyDescriptor> result) { PropertyDescriptor properties[] = introspect(clazz); for (int i = 0; i < properties.length; i++) { PropertyDescriptor property = properties[i]; String propertyName = property.getName(); Method writeMethod = property.getWriteMethod(); if (writeMethod == null) { continue; } result.add( new WriteablePropertyDescriptor( propertyName, writeMethod.getParameterTypes()[0], writeMethod)); } }
public Reference createReference(Object bean) throws NamingException { try { BeanInfo bi = Introspector.getBeanInfo(bean.getClass()); PropertyDescriptor[] pds = bi.getPropertyDescriptors(); List refAddrs = new ArrayList(); String factoryClassLocation = defaultFactoryClassLocation; boolean using_ref_props = referenceProperties.size() > 0; // we only include this so that on dereference we are not surprised to find some properties // missing if (using_ref_props) refAddrs.add( new BinaryRefAddr(REF_PROPS_KEY, SerializableUtils.toByteArray(referenceProperties))); for (int i = 0, len = pds.length; i < len; ++i) { PropertyDescriptor pd = pds[i]; String propertyName = pd.getName(); // System.err.println("Making Reference: " + propertyName); if (using_ref_props && !referenceProperties.contains(propertyName)) { // System.err.println("Not a ref_prop -- continuing."); continue; } Class propertyType = pd.getPropertyType(); Method getter = pd.getReadMethod(); Method setter = pd.getWriteMethod(); if (getter != null && setter != null) // only use properties that are both readable and writable { Object val = getter.invoke(bean, EMPTY_ARGS); // System.err.println( "val: " + val ); if (propertyName.equals("factoryClassLocation")) { if (String.class != propertyType) throw new NamingException( this.getClass().getName() + " requires a factoryClassLocation property to be a string, " + propertyType.getName() + " is not valid."); factoryClassLocation = (String) val; } if (val == null) { RefAddr addMe = new BinaryRefAddr(propertyName, NULL_TOKEN_BYTES); refAddrs.add(addMe); } else if (Coerce.canCoerce(propertyType)) { RefAddr addMe = new StringRefAddr(propertyName, String.valueOf(val)); refAddrs.add(addMe); } else // other Object properties { RefAddr addMe = null; PropertyEditor pe = BeansUtils.findPropertyEditor(pd); if (pe != null) { pe.setValue(val); String textValue = pe.getAsText(); if (textValue != null) addMe = new StringRefAddr(propertyName, textValue); } if (addMe == null) // property editor approach failed addMe = new BinaryRefAddr( propertyName, SerializableUtils.toByteArray( val, indirector, IndirectPolicy.INDIRECT_ON_EXCEPTION)); refAddrs.add(addMe); } } else { // System.err.println(this.getClass().getName() + // ": Skipping " + propertyName + " because it is " + (setter == null ? // "read-only." : "write-only.")); if (logger.isLoggable(MLevel.WARNING)) logger.warning( this.getClass().getName() + ": Skipping " + propertyName + " because it is " + (setter == null ? "read-only." : "write-only.")); } } Reference out = new Reference(bean.getClass().getName(), factoryClassName, factoryClassLocation); for (Iterator ii = refAddrs.iterator(); ii.hasNext(); ) out.add((RefAddr) ii.next()); return out; } catch (Exception e) { // e.printStackTrace(); if (Debug.DEBUG && logger.isLoggable(MLevel.FINE)) logger.log(MLevel.FINE, "Exception trying to create Reference.", e); throw new NamingException("Could not create reference from bean: " + e.toString()); } }
public void removeReferenceProperty(String propName) { referenceProperties.remove(propName); }
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); } } } }
public boolean isDirectTransferInProgress(final FrostDownloadItem dlItem) { final String id = dlItem.getGqIdentifier(); return directGETsInProgress.contains(id); }
/** Apply the states of FcpRequestPut to the FrostUploadItem. */ private void applyState(final FrostUploadItem ulItem, final FcpPersistentPut putReq) { // when cancelled and we expect this, don't set failed; don't even set the old priority! if (ulItem.isInternalRemoveExpected() && putReq.isFailed()) { final int returnCode = putReq.getCode(); if (returnCode == 25) { return; } } if (directPUTsWithoutAnswer.contains(ulItem.getGqIdentifier())) { // we got an answer directPUTsWithoutAnswer.remove(ulItem.getGqIdentifier()); } // apply externally changed priority if (ulItem.getPriority() != putReq.getPriority()) { if (Core.frostSettings.getBoolValue(SettingsClass.FCP2_ENFORCE_FROST_PRIO_FILE_UPLOAD)) { // reset priority with our current value fcpTools.changeRequestPriority(putReq.getIdentifier(), ulItem.getPriority()); } else { // apply to uploaditem ulItem.setPriority(putReq.getPriority()); } } if (!putReq.isProgressSet() && !putReq.isSuccess() && !putReq.isFailed()) { if (ulItem.getState() == FrostUploadItem.STATE_WAITING) { ulItem.setState(FrostUploadItem.STATE_PROGRESS); } return; } if (putReq.isProgressSet()) { final int doneBlocks = putReq.getDoneBlocks(); final int totalBlocks = putReq.getTotalBlocks(); final boolean isFinalized = putReq.isFinalized(); if (totalBlocks > 0) { ulItem.setDoneBlocks(doneBlocks); ulItem.setTotalBlocks(totalBlocks); ulItem.setFinalized(isFinalized); ulItem.fireValueChanged(); } if (ulItem.getState() != FrostUploadItem.STATE_PROGRESS) { ulItem.setState(FrostUploadItem.STATE_PROGRESS); } } if (putReq.isSuccess()) { // maybe progress was not completely sent ulItem.setFinalized(true); if (ulItem.getTotalBlocks() > 0 && ulItem.getDoneBlocks() != ulItem.getTotalBlocks()) { ulItem.setDoneBlocks(ulItem.getTotalBlocks()); } final String chkKey = putReq.getUri(); if (ulItem.isExternal()) { ulItem.setState(FrostUploadItem.STATE_DONE); ulItem.setKey(chkKey); } else { final FcpResultPut result = new FcpResultPut(FcpResultPut.Success, chkKey); FileTransferManager.inst().getUploadManager().notifyUploadFinished(ulItem, result); } } if (putReq.isFailed()) { final String desc = putReq.getCodeDesc(); if (ulItem.isExternal()) { ulItem.setState(FrostUploadItem.STATE_FAILED); ulItem.setErrorCodeDescription(desc); } else { final int returnCode = putReq.getCode(); final boolean isFatal = putReq.isFatal(); final FcpResultPut result; if (returnCode == 9) { result = new FcpResultPut(FcpResultPut.KeyCollision, returnCode, desc, isFatal); } else if (returnCode == 5) { result = new FcpResultPut(FcpResultPut.Retry, returnCode, desc, isFatal); } else { result = new FcpResultPut(FcpResultPut.Error, returnCode, desc, isFatal); } FileTransferManager.inst().getUploadManager().notifyUploadFinished(ulItem, result); } } }
// Here's where the font is set on the editor pane, and we also keep // track of the panes in use for future font updates. public void install(JEditorPane pane) { if (Settings.debug) System.err.println("Installing kit into pane"); delegate.install(pane); panes.add(pane); pane.setFont(Settings.font); }
public void deinstall(JEditorPane pane) { if (Settings.debug) System.err.println("Deinstalling kit from pane"); panes.remove(pane); delegate.deinstall(pane); }
/* 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 addReferenceProperty(String propName) { referenceProperties.add(propName); }