private VirtualMachine connect(String bndlPrefix, AttachingConnector connector, Map args) throws DebuggerException { if (bndlPrefix != null) { if (connector.transport().name().equals("dt_shmem")) { Argument a = (Argument) args.get("name"); if (a == null) println(bundle.getString(bndlPrefix + "_shmem_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_shmem")) .format(new Object[] {a.value()}), ERR_OUT); } else if (connector.transport().name().equals("dt_socket")) { Argument name = (Argument) args.get("hostname"); Argument port = (Argument) args.get("port"); if ((name == null) || (port == null)) println(bundle.getString(bndlPrefix + "_socket_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_socket")) .format(new Object[] {name.value(), port.value()}), ERR_OUT); } else println(bundle.getString(bndlPrefix), ERR_OUT); } // launch VM try { // S ystem.out.println ("attach to:" + ac + " : " + password); // NOI18N return connector.attach(args); } catch (Exception e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_connecting_to_debuggee")) .format(new Object[] {e.toString()}), e); } }
/** * @param source * @param oldScalarMap The previous ScalarMap of the ScalarMapAdapter. May be <code>null</code>. * @return The controlling ScalarMapAdapter of the display. * @throws RemoteException * @throws VisADException */ protected final synchronized ScalarMapAdapter accept( ScalarMapAdapter source, ScalarMap oldScalarMap) throws VisADException, RemoteException { ScalarMapAdapter adapter; if (oldScalarMap != null) { adapter = (ScalarMapAdapter) map.get(oldScalarMap); if ((adapter != null) && (adapter == source)) { map.remove(oldScalarMap); changed = true; } } ScalarMap newScalarMap = source.getScalarMap(); adapter = (ScalarMapAdapter) map.get(newScalarMap); if (adapter != null) { source.duplicate(adapter); } else { adapter = source; map.put(newScalarMap, source); changed = true; } if (changed) { updater.update(); } return adapter; }
private void addTagToMethod( Map<String, MethodInfo> methods, String tagText, MethodTagType tagType) { MethodInfo mi = methods.get(methodName); if (mi == null) { mi = new MethodInfo(); methods.put(methodName, mi); } if (tagType == MethodTagType.OMIT_FROM_UI) { mi.omitFromUI = true; return; } String[] tagParts = Iterables.toArray( Splitter.on(WHITESPACE_PATTERN) .trimResults() .omitEmptyStrings() .limit(2) .split(tagText), String.class); if (tagParts.length == 2) { if (tagType == MethodTagType.DESCRIPTION) { mi.descriptions.put(tagParts[0], tagParts[1]); } else { mi.useSchemas.put(tagParts[0], tagParts[1]); } } }
/** * Set the object to be edited. * * @param value The object to be edited. */ public void setObject(Object value) { if (!(_type.isInstance(value))) { throw new IllegalArgumentException(value.getClass() + " is not of type " + _type); } _value = value; // Disable event generation. _squelchChangeEvents = true; // Iterate over each property, doing a lookup on the associated editor // and setting the editor's value to the value of the property. Iterator it = _prop2Editor.keySet().iterator(); while (it.hasNext()) { PropertyDescriptor desc = (PropertyDescriptor) it.next(); PropertyEditor editor = (PropertyEditor) _prop2Editor.get(desc); Method reader = desc.getReadMethod(); if (reader != null) { try { Object val = reader.invoke(_value, null); editor.setValue(val); } catch (IllegalAccessException ex) { ex.printStackTrace(); } catch (InvocationTargetException ex) { ex.getTargetException().printStackTrace(); } } } // Enable event generation. _squelchChangeEvents = false; }
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; }
/** Returns DebuggerInfo. */ public DebuggerInfo getDebuggerInfo() { int i, k = tfParams.length; for (i = 0; i < k; i++) { Argument a = (Argument) args.get(tfParams[i].getName()); a.setValue(tfParams[i].getText()); } return new RemoteDebuggerInfo(ac, args); }
public static void setEntity(ConcreteAgent ent, Map attributes) { Map currentMap = (Map) RenderComponentManager.retrieveIDs("ConcreteAgent", ent.getPrefs(attributes).getView()); current = ent.getPrefs(attributes).getView(); if (ent != null && currentMap.get("_attributes_") != null && currentMap.get("_attributes_") instanceof ingenias.editor.rendererxml.AttributesPanel) { ((ingenias.editor.rendererxml.AttributesPanel) currentMap.get("_attributes_")).setEntity(ent); } if (currentMap.get("Id") != null) { if (ent != null && ent.getId() != null) { if (currentMap.get("Id") instanceof javax.swing.JLabel) { ((javax.swing.JLabel) (currentMap).get("Id")).setText(ent.getId().toString()); } else { if (currentMap.get("Id") instanceof javax.swing.text.JTextComponent) ((javax.swing.text.JTextComponent) (currentMap).get("Id")) .setText(ent.getId().toString()); } } else { if (currentMap.get("Id") instanceof javax.swing.JLabel) ((javax.swing.JLabel) (currentMap).get("Id")).setText(""); else { if (!(currentMap.get("Id") instanceof ingenias.editor.rendererxml.CollectionPanel)) ((javax.swing.text.JTextComponent) (currentMap).get("Id")).setText(""); } } } }
/** * This method restores the width of the specified column to its previous width. * * @param column The column to restore. */ private void restoreColumn(int column) { TableColumn tableColumn = table.getColumnModel().getColumn(column); Integer width = columnSizes.get(tableColumn); if (width != null) { table.getTableHeader().setResizingColumn(tableColumn); tableColumn.setWidth(width.intValue()); } }
public static void setEntity(WFResponsable ent) { Map currentMap = (Map) RenderComponentManager.retrieveIDs("WFResponsable", ent.getPrefs().getView()); if (currentMap.get("Label") != null) { if (ent != null && ent.getLabel() != null) { if (currentMap.get("Label") instanceof javax.swing.JLabel) { ((javax.swing.JLabel) (currentMap).get("Label")).setText(ent.getLabel().toString()); } else { if (currentMap.get("Label") instanceof javax.swing.text.JTextComponent) ((javax.swing.text.JTextComponent) (currentMap).get("Label")) .setText(ent.getLabel().toString()); } } else { if (currentMap.get("Label") instanceof javax.swing.JLabel) ((javax.swing.JLabel) (currentMap).get("Label")).setText(""); else { if (!(currentMap.get("Label") instanceof ingenias.editor.rendererxml.CollectionPanel)) ((javax.swing.text.JTextComponent) (currentMap).get("Label")).setText(""); } } } }
private void putFieldDescription(CompactFieldNode field, JSONObject port, TypeGraphVertex tgv) throws JSONException { OperatorClassInfo oci = classInfo.get(tgv.typeName); if (oci != null) { String fieldDesc = oci.fields.get(field.getName()); if (fieldDesc != null) { port.put("description", fieldDesc); return; } } for (TypeGraphVertex ancestor : tgv.getAncestors()) { putFieldDescription(field, port, ancestor); } }
/** * Remove an adapter * * @param adapter adapter to remove */ public final synchronized void remove(ScalarMapAdapter adapter) { adapter.removePropertyChangeListener(adapter.SCALAR_MAP, listener); ScalarMap scalarMap = adapter.getScalarMap(); ScalarMapAdapter source = (ScalarMapAdapter) map.get(scalarMap); if ((source != null) && (source == adapter)) { map.remove(scalarMap); changed = true; updater.update(); } }
private OperatorClassInfo getOperatorClassWithGetterSetter( TypeGraphVertex tgv, String setterName, String getterName) { OperatorClassInfo oci = classInfo.get(tgv.typeName); if (oci != null && (oci.getMethods.containsKey(getterName) || oci.setMethods.containsKey(setterName))) { return oci; } else { if (tgv.getAncestors() != null) { for (TypeGraphVertex ancestor : tgv.getAncestors()) { return getOperatorClassWithGetterSetter(ancestor, setterName, getterName); } } } return null; }
@Override public Image getIcon(final int iconType) { Image icon = img.get(iconType); if (icon != null) return icon; // try to get a special icon icon = BeanSupport.getBeanIcon(component.getBeanClass(), iconType); if (icon == null) { final String className = component.getBeanClass().getName(); final String classDetails = (String) component.getAuxValue(RADComponent.AUX_VALUE_CLASS_DETAILS); if (!iconsInitialized) { // getIconForClass invokes getNodes(true) which cannot be called in Mutex EventQueue.invokeLater( new Runnable() { @Override public void run() { Image icon = PaletteUtils.getIconForClass(className, classDetails, iconType, true); iconsInitialized = true; if (icon != null) { img.put(iconType, icon); fireIconChange(); } } }); } else { icon = PaletteUtils.getIconForClass(className, classDetails, iconType, false); } if (icon == null) { // get icon from BeanInfo java.beans.BeanInfo bi = component.getBeanInfo(); if (bi != null) { icon = bi.getIcon(iconType); } if (icon == null) { // use default icon icon = super.getIcon(iconType); } } } img.put(iconType, icon); return icon; }
/** * Returns, the <tt>TransportManager</tt> instance for the channel-bundle with ID * <tt>channelBundleId</tt>. If no instance exists and <tt>create</tt> is <tt>true</tt>, one will * be created. * * @param channelBundleId the ID of the channel-bundle for which to return the * <tt>TransportManager</tt>. * @param create whether to create a new instance, if one doesn't exist. * @return the <tt>TransportManager</tt> instance for the channel-bundle with ID * <tt>channelBundleId</tt>. */ IceUdpTransportManager getTransportManager(String channelBundleId, boolean create) { IceUdpTransportManager transportManager; synchronized (transportManagers) { transportManager = transportManagers.get(channelBundleId); if (transportManager == null && create && !isExpired()) { try { // FIXME: the initiator is hard-coded // We assume rtcp-mux when bundle is used, so we make only // one component. transportManager = new IceUdpTransportManager(this, true, 1); } catch (IOException ioe) { throw new UndeclaredThrowableException(ioe); } transportManagers.put(channelBundleId, transportManager); } } return transportManager; }
public static void setEntity(Plan ent, Map attributes) { Map currentMap = (Map) RenderComponentManager.retrieveIDs("Plan", ent.getPrefs(attributes).getView()); current = ent.getPrefs(attributes).getView(); if (ent != null && currentMap.get("_attributes_") != null && currentMap.get("_attributes_") instanceof ingenias.editor.rendererxml.AttributesPanel) { ((ingenias.editor.rendererxml.AttributesPanel) currentMap.get("_attributes_")).setEntity(ent); } if (currentMap.get("Tasks") != null && currentMap.get("Tasks") instanceof ingenias.editor.rendererxml.CollectionPanel) { try { ((ingenias.editor.rendererxml.CollectionPanel) currentMap.get("Tasks")) .setCollection("Tasks", ent.Tasks, ent.Tasks.getType()); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } } if (currentMap.get("Tasks") != null && currentMap.get("Tasks") instanceof ingenias.editor.rendererxml.CollectionPanel) { try { ((ingenias.editor.rendererxml.CollectionPanel) currentMap.get("Tasks")) .setCollection("Tasks", ent.Tasks, ent.Tasks.getType()); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } } if (currentMap.get("Tasks") != null) { if (ent != null && ent.getTasks() != null) { if (currentMap.get("Tasks") instanceof javax.swing.JLabel) { ((javax.swing.JLabel) (currentMap).get("Tasks")).setText(ent.getTasks().toString()); } else { if (currentMap.get("Tasks") instanceof javax.swing.text.JTextComponent) ((javax.swing.text.JTextComponent) (currentMap).get("Tasks")) .setText(ent.getTasks().toString()); } } else { if (currentMap.get("Tasks") instanceof javax.swing.JLabel) ((javax.swing.JLabel) (currentMap).get("Tasks")).setText(""); else { if (!(currentMap.get("Tasks") instanceof ingenias.editor.rendererxml.CollectionPanel)) ((javax.swing.text.JTextComponent) (currentMap).get("Tasks")).setText(""); } } } if (currentMap.get("Id") != null) { if (ent != null && ent.getId() != null) { if (currentMap.get("Id") instanceof javax.swing.JLabel) { ((javax.swing.JLabel) (currentMap).get("Id")).setText(ent.getId().toString()); } else { if (currentMap.get("Id") instanceof javax.swing.text.JTextComponent) ((javax.swing.text.JTextComponent) (currentMap).get("Id")) .setText(ent.getId().toString()); } } else { if (currentMap.get("Id") instanceof javax.swing.JLabel) ((javax.swing.JLabel) (currentMap).get("Id")).setText(""); else { if (!(currentMap.get("Id") instanceof ingenias.editor.rendererxml.CollectionPanel)) ((javax.swing.text.JTextComponent) (currentMap).get("Id")).setText(""); } } } }
public JComponent getConcreteSubComponent(String fieldname, Entity ent, Map map) { Map<String, JComponent> currentMap = (Map) RenderComponentManager.retrieveIDs("Plan", ent.getPrefs(map).getView()); return currentMap.get(fieldname); }
public static void setEntity(DeploymentUnitByTypeMSEntity ent) { Map currentMap = (Map) RenderComponentManager.retrieveIDs( "DeploymentUnitByTypeMSEntity", ent.getPrefs().getView()); if (ent != null && currentMap.get("_attributes_") != null && currentMap.get("_attributes_") instanceof ingenias.editor.rendererxml.AttributesPanel) { ((ingenias.editor.rendererxml.AttributesPanel) currentMap.get("_attributes_")).setEntity(ent); } if (currentMap.get("InitialState") != null) { if (ent != null && ent.getInitialState() != null) { if (currentMap.get("InitialState") instanceof javax.swing.JLabel) { ((javax.swing.JLabel) (currentMap).get("InitialState")) .setText(ent.getInitialState().toString()); } else { if (currentMap.get("InitialState") instanceof javax.swing.text.JTextComponent) ((javax.swing.text.JTextComponent) (currentMap).get("InitialState")) .setText(ent.getInitialState().toString()); } } else { if (currentMap.get("InitialState") instanceof javax.swing.JLabel) ((javax.swing.JLabel) (currentMap).get("InitialState")).setText(""); else { if (!(currentMap.get("InitialState") instanceof ingenias.editor.rendererxml.CollectionPanel)) ((javax.swing.text.JTextComponent) (currentMap).get("InitialState")).setText(""); } } } if (currentMap.get("NumberInstances") != null) { if (ent != null && ent.getNumberInstances() != null) { if (currentMap.get("NumberInstances") instanceof javax.swing.JLabel) { ((javax.swing.JLabel) (currentMap).get("NumberInstances")) .setText(ent.getNumberInstances().toString()); } else { if (currentMap.get("NumberInstances") instanceof javax.swing.text.JTextComponent) ((javax.swing.text.JTextComponent) (currentMap).get("NumberInstances")) .setText(ent.getNumberInstances().toString()); } } else { if (currentMap.get("NumberInstances") instanceof javax.swing.JLabel) ((javax.swing.JLabel) (currentMap).get("NumberInstances")).setText(""); else { if (!(currentMap.get("NumberInstances") instanceof ingenias.editor.rendererxml.CollectionPanel)) ((javax.swing.text.JTextComponent) (currentMap).get("NumberInstances")).setText(""); } } } if (currentMap.get("AgentTypeDeployed") != null) { if (ent != null && ent.getAgentTypeDeployed() != null) { if (currentMap.get("AgentTypeDeployed") instanceof javax.swing.JLabel) { ((javax.swing.JLabel) (currentMap).get("AgentTypeDeployed")) .setText(ent.getAgentTypeDeployed().toString()); } else { if (currentMap.get("AgentTypeDeployed") instanceof javax.swing.text.JTextComponent) ((javax.swing.text.JTextComponent) (currentMap).get("AgentTypeDeployed")) .setText(ent.getAgentTypeDeployed().toString()); } } else { if (currentMap.get("AgentTypeDeployed") instanceof javax.swing.JLabel) ((javax.swing.JLabel) (currentMap).get("AgentTypeDeployed")).setText(""); else { if (!(currentMap.get("AgentTypeDeployed") instanceof ingenias.editor.rendererxml.CollectionPanel)) ((javax.swing.text.JTextComponent) (currentMap).get("AgentTypeDeployed")).setText(""); } } } if (currentMap.get("Id") != null) { if (ent != null && ent.getId() != null) { if (currentMap.get("Id") instanceof javax.swing.JLabel) { ((javax.swing.JLabel) (currentMap).get("Id")).setText(ent.getId().toString()); } else { if (currentMap.get("Id") instanceof javax.swing.text.JTextComponent) ((javax.swing.text.JTextComponent) (currentMap).get("Id")) .setText(ent.getId().toString()); } } else { if (currentMap.get("Id") instanceof javax.swing.JLabel) ((javax.swing.JLabel) (currentMap).get("Id")).setText(""); else { if (!(currentMap.get("Id") instanceof ingenias.editor.rendererxml.CollectionPanel)) ((javax.swing.text.JTextComponent) (currentMap).get("Id")).setText(""); } } } }
/* 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"); } } } } }
private void refresh(int index) { GridBagConstraints c = new GridBagConstraints(); // No connector ................ if (acs.size() == 0) { add(new JLabel(bundle.getString("CTL_No_Connector")), c); return; } // Connector switch ................ if (acs.size() > 1) { c.insets = new Insets(0, 0, 3, 3); add(new JLabel(bundle.getString("CTL_Connector")), c); cbConnectors = new JComboBox(); int i, k = acs.size(); for (i = 0; i < k; i++) { AttachingConnector ac = (AttachingConnector) acs.get(i); int jj = ac.name().lastIndexOf('.'); String s = (jj < 0) ? ac.name() : ac.name().substring(jj + 1); cbConnectors.addItem(s + " (" + ac.description() + ")"); } c = new GridBagConstraints(); c.insets = new Insets(0, 3, 3, 0); c.weightx = 1.0; c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.gridwidth = 0; cbConnectors.setSelectedIndex(index); cbConnectors.setActionCommand("SwitchMe!"); cbConnectors.addActionListener(this); add(cbConnectors, c); } ac = (AttachingConnector) acs.get(index); // Transport ................ c = new GridBagConstraints(); c.insets = new Insets(3, 0, 0, 3); add(new JLabel(bundle.getString("CTL_Transport")), c); JTextField tfTransport = new JTextField(ac.transport().name()); tfTransport.setEnabled(false); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(3, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfTransport, c); // Other params ................ args = ac.defaultArguments(); tfParams = new JTextField[args.size()]; Iterator it = args.keySet().iterator(); int i = 0; while (it.hasNext()) { String name = (String) it.next(); Argument a = (Argument) args.get(name); c = new GridBagConstraints(); c.insets = new Insets(6, 0, 0, 3); c.anchor = GridBagConstraints.WEST; add(new JLabel(a.label() + ": "), c); JTextField tfParam = new JTextField(a.value()); tfParams[i++] = tfParam; tfParam.setName(name); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(6, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfParam, c); } c = new GridBagConstraints(); c.weighty = 1.0; JPanel p = new JPanel(); p.setPreferredSize(new Dimension(1, 1)); add(p, c); }
private VirtualMachine launch(DebuggerInfo info) throws DebuggerException { // create process & read password for local debugging // create main class & arguments ............................................... StringBuffer sb = new StringBuffer(); sb.append(mainClassName); String[] infoArgs = info.getArguments(); int i, k = infoArgs.length; for (i = 0; i < k; i++) sb.append(" \"").append(infoArgs[i]).append('"'); // NOI18N String main = new String(sb); // create connector .............................................................. VirtualMachineManager vmm = Bootstrap.virtualMachineManager(); java.util.List lcs = vmm.launchingConnectors(); k = lcs.size(); for (i = 0; i < k; i++) if (((LaunchingConnector) lcs.get(i)).name().indexOf("RawCommandLineLaunch") >= 0) // NOI18N break; if (i == k) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Cannot_find_launcher")) .format( new Object[] { "RawCommandLineLaunch" // NOI18N })); } LaunchingConnector lc = (LaunchingConnector) lcs.get(i); String transport = lc.transport().name(); // create commandLine & NbProcessDescriptor .............................. NbProcessDescriptor debugerProcess; if (info instanceof ProcessDebuggerInfo) debugerProcess = ((ProcessDebuggerInfo) info).getDebuggerProcess(); else debugerProcess = ProcessDebuggerType.DEFAULT_DEBUGGER_PROCESS; // generate password String password; if (transport.equals("dt_shmem")) { // NOI18N connector = getAttachingConnectorFor("dt_shmem"); password = generatePassword(); args = connector.defaultArguments(); ((Argument) args.get("name")).setValue(password); } else { try { java.net.ServerSocket ss = new java.net.ServerSocket(0); password = "" + ss.getLocalPort(); // NOI18N ss.close(); } catch (java.io.IOException e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_Cannot_find_empty_local_port")) .format(new Object[] {e.toString()})); } connector = getAttachingConnectorFor("dt_socket"); args = connector.defaultArguments(); ((Argument) args.get("port")).setValue(password); } HashMap map = Utils.processDebuggerInfo( info, "-Xdebug -Xnoagent -Xrunjdwp:transport=" + // NOI18N transport + ",address=" + // NOI18N password + ",suspend=y ", // NOI18N main); MapFormat format = new MapFormat(map); String commandLine = format.format( debugerProcess.getProcessName() + " " + // NOI18N debugerProcess.getArguments()); println(commandLine, ERR_OUT); /* We mus wait on process start to connect... try { process = debugerProcess.exec (format); } catch (java.io.IOException exc) { finishDebugger (); throw new DebuggerException ( new MessageFormat (bundle.getString ("EXC_While_create_debuggee")). format (new Object[] { debugerProcess.getProcessName (), exc.toString () }), exc ); } return connect ( null, connector, args );*/ /* S ystem.out.println ("attaching: "); Utils.showConnectors (vmm.attachingConnectors ()); S ystem.out.println ("launching: "); Utils.showConnectors (vmm.launchingConnectors ()); S ystem.out.println ("listening: "); Utils.showConnectors (vmm.listeningConnectors ());*/ // set debugger-start arguments Map params = lc.defaultArguments(); ((Argument) params.get("command")) .setValue( // NOI18N commandLine); ((Argument) params.get("address")) .setValue( // NOI18N password); // launch VM try { return lc.launch(params); } catch (VMStartException exc) { showOutput(process = exc.process(), ERR_OUT, ERR_OUT); finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_create_debuggee")) .format( new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}), exc); } catch (Exception exc) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_create_debuggee")) .format( new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}), exc); } }
/** {@inheritDoc} */ @Override public Object getProperty(String propertyName) { return properties.get(propertyName); }
public String getDestinations(String messageBrokerId) { StringBuilder result = new StringBuilder(); MessageBroker broker = MessageBroker.getMessageBroker(messageBrokerId); result.append("<remotingDestinations>"); if (broker != null) { Service remotingService = broker.getServiceByType("flex.messaging.services.RemotingService"); if (remotingService != null) { Map destinations = remotingService.getDestinations(); Iterator destinationsIterator = destinations.keySet().iterator(); result.append("<destinations>"); if (destinationsIterator != null) { while (destinationsIterator.hasNext()) { RemotingDestination destination = (RemotingDestination) destinations.get(destinationsIterator.next()); if (destination != null) { result.append("<destination>"); result.append( (new StringBuilder("<destinationId>")) .append(destination.getId()) .append("</destinationId>") .toString()); result.append( (new StringBuilder("<adapterName>")) .append(destination.getAdapter().getClass().getName()) .append("</adapterName>") .toString()); result.append( (new StringBuilder("<source>")) .append(destination.getSource()) .append("</source>") .toString()); List channelIds = destination.getChannels(); Iterator channelIdsIterator = channelIds.iterator(); result.append("<channels>"); for (; channelIdsIterator.hasNext(); result.append( (new StringBuilder("<channel>")) .append((String) channelIdsIterator.next()) .append("</channel>") .toString())) ; result.append("</channels>"); SecurityConstraint secConstraint = destination.getSecurityConstraint(); result.append("<securityConstraint>"); if (secConstraint != null) { result.append( (new StringBuilder("<securityMethod>")) .append(secConstraint.getMethod()) .append("</securityMethod>") .toString()); result.append( (new StringBuilder("<securityRoles>")) .append(secConstraint.getRoles()) .append("</securityRoles>") .toString()); } result.append("</securityConstraint>"); String className = destination.getSource(); if (className != null) try { Class c = Class.forName("com.adams.dt.util.Abstract"); Field fields[] = c.getFields(); result.append("<fields>"); if (fields != null) { for (int i = 0; i < fields.length; i++) result.append( (new StringBuilder("<field>")) .append(fields[i].toString()) .append("</field>") .toString()); } result.append("</fields>"); Method methods[] = c.getMethods(); result.append("<methods>"); if (methods != null) { for (int i = 0; i < methods.length; i++) if (methods[i] != null && !methodsExclude.contains(methods[i].getName())) { result.append("<method>"); result.append( (new StringBuilder("<methodSignature>")) .append(methods[i].toString()) .append("</methodSignature>") .toString()); result.append( (new StringBuilder("<methodName>")) .append(methods[i].getName()) .append("</methodName>") .toString()); result.append( (new StringBuilder("<returnType>")) .append(methods[i].getReturnType().getName()) .append("</returnType>") .toString()); Class paramClasses[] = methods[i].getParameterTypes(); result.append("<params>"); if (paramClasses != null) { for (int j = 0; j < paramClasses.length; j++) if (paramClasses[j] != null) result.append( (new StringBuilder("<param>")) .append(paramClasses[j].getName()) .append("</param>") .toString()); } result.append("</params>"); result.append("</method>"); } } result.append("</methods>"); } catch (ClassNotFoundException e) { System.out.println(e.getMessage()); } result.append("</destination>"); } } result.append("</destinations>"); } } } result.append("</remotingDestinations>"); return result.toString(); }
private JSONArray getClassProperties(Class<?> clazz, int level) throws IntrospectionException { JSONArray arr = new JSONArray(); TypeDiscoverer td = new TypeDiscoverer(); try { for (PropertyDescriptor pd : Introspector.getBeanInfo(clazz).getPropertyDescriptors()) { Method readMethod = pd.getReadMethod(); if (readMethod != null) { if (readMethod.getDeclaringClass() == java.lang.Enum.class) { // skip getDeclaringClass continue; } else if ("class".equals(pd.getName())) { // skip getClass continue; } } else { // yields com.datatorrent.api.Context on JDK6 and // com.datatorrent.api.Context.OperatorContext with JDK7 if ("up".equals(pd.getName()) && com.datatorrent.api.Context.class.isAssignableFrom(pd.getPropertyType())) { continue; } } // LOG.info("name: " + pd.getName() + " type: " + pd.getPropertyType()); Class<?> propertyType = pd.getPropertyType(); if (propertyType != null) { JSONObject propertyObj = new JSONObject(); propertyObj.put("name", pd.getName()); propertyObj.put("canGet", readMethod != null); propertyObj.put("canSet", pd.getWriteMethod() != null); if (readMethod != null) { for (Class<?> c = clazz; c != null; c = c.getSuperclass()) { OperatorClassInfo oci = classInfo.get(c.getName()); if (oci != null) { MethodInfo getMethodInfo = oci.getMethods.get(readMethod.getName()); if (getMethodInfo != null) { addTagsToProperties(getMethodInfo, propertyObj); break; } } } // type can be a type symbol or parameterized type td.setTypeArguments(clazz, readMethod.getGenericReturnType(), propertyObj); } else { if (pd.getWriteMethod() != null) { td.setTypeArguments( clazz, pd.getWriteMethod().getGenericParameterTypes()[0], propertyObj); } } // if (!propertyType.isPrimitive() && !propertyType.isEnum() && !propertyType.isArray() && // !propertyType.getName().startsWith("java.lang") && level < MAX_PROPERTY_LEVELS) { // propertyObj.put("properties", getClassProperties(propertyType, level + 1)); // } arr.put(propertyObj); } } } catch (JSONException ex) { throw new RuntimeException(ex); } return arr; }
static MethodTagType from(String tag) { return TAG_TEXT_MAPPING.get(tag); }
public JSONObject describeOperator(String clazz) throws Exception { TypeGraphVertex tgv = typeGraph.getTypeGraphVertex(clazz); if (tgv.isInstantiable()) { JSONObject response = new JSONObject(); JSONArray inputPorts = new JSONArray(); JSONArray outputPorts = new JSONArray(); // Get properties from ASM JSONObject operatorDescriptor = describeClassByASM(clazz); JSONArray properties = operatorDescriptor.getJSONArray("properties"); properties = enrichProperties(clazz, properties); JSONArray portTypeInfo = operatorDescriptor.getJSONArray("portTypeInfo"); List<CompactFieldNode> inputPortfields = typeGraph.getAllInputPorts(clazz); List<CompactFieldNode> outputPortfields = typeGraph.getAllOutputPorts(clazz); try { for (CompactFieldNode field : inputPortfields) { JSONObject inputPort = setFieldAttributes(clazz, field); if (!inputPort.has("optional")) { inputPort.put( "optional", false); // input port that is not annotated is default to be not optional } if (!inputPort.has(SCHEMA_REQUIRED_KEY)) { inputPort.put(SCHEMA_REQUIRED_KEY, false); } inputPorts.put(inputPort); } for (CompactFieldNode field : outputPortfields) { JSONObject outputPort = setFieldAttributes(clazz, field); if (!outputPort.has("optional")) { outputPort.put( "optional", true); // output port that is not annotated is default to be optional } if (!outputPort.has("error")) { outputPort.put("error", false); } if (!outputPort.has(SCHEMA_REQUIRED_KEY)) { outputPort.put(SCHEMA_REQUIRED_KEY, false); } outputPorts.put(outputPort); } response.put("name", clazz); response.put("properties", properties); response.put(PORT_TYPE_INFO_KEY, portTypeInfo); response.put("inputPorts", inputPorts); response.put("outputPorts", outputPorts); OperatorClassInfo oci = classInfo.get(clazz); if (oci != null) { if (oci.comment != null) { String[] descriptions; // first look for a <p> tag String keptPrefix = "<p>"; descriptions = oci.comment.split("<p>", 2); if (descriptions.length == 0) { keptPrefix = ""; // if no <p> tag, then look for a blank line descriptions = oci.comment.split("\n\n", 2); } if (descriptions.length > 0) { response.put("shortDesc", descriptions[0]); } if (descriptions.length > 1) { response.put("longDesc", keptPrefix + descriptions[1]); } } response.put("category", oci.tags.get("@category")); String displayName = oci.tags.get("@displayName"); if (displayName == null) { displayName = decamelizeClassName(ClassUtils.getShortClassName(clazz)); } response.put("displayName", displayName); String tags = oci.tags.get("@tags"); if (tags != null) { JSONArray tagArray = new JSONArray(); for (String tag : StringUtils.split(tags, ',')) { tagArray.put(tag.trim().toLowerCase()); } response.put("tags", tagArray); } String doclink = oci.tags.get("@doclink"); if (doclink != null) { response.put("doclink", doclink + "?" + getDocName(clazz)); } else if (clazz.startsWith("com.datatorrent.lib.") || clazz.startsWith("com.datatorrent.contrib.")) { response.put("doclink", DT_OPERATOR_DOCLINK_PREFIX + "?" + getDocName(clazz)); } } } catch (JSONException ex) { throw new RuntimeException(ex); } return response; } else { throw new UnsupportedOperationException(); } }