Examples of the descriptor being used in client code.

Bridging the Gap Between Java Clients and EJBs Using XML

William Louth
Listing 5. Examples of the descriptor being used in client code.

// TreeCellRenderer
  Descriptor d = DescriptorLookup.getInstance().get(value);

// ListCellRenderer - getListCellRendererComponent method
  if ((value instanceof Describeable)) {
    // get the descriptor, ask it to determine the icon and text for the
    //  list item to be displayed
    Descriptor dd = DescriptorLookup.getInstance().get(value);
// FolderTableModel methods
public String getColumnName(int col) {
 // _props is a list of PropertyDescriptors that is set when the folder
 // table model is given a Folder object to display. Folder objects hold
 // only one type of Describeable object. The table model can get the
 // object descriptor relating to the type of contents and determine
 // the columns and so on.
 return ((PropertyDescriptor)_props.get(col)).getName();
public int getColumnCount() {
 return _props.size();
// The following 2 methods can handle any list of objects, i.e.,
// rows, without writing type-specific code.

public Object getValueAt(int row, int col) {
 Object value = null;
  try {
     _rows[row] = getValues((Describeable)_objs[row]);
     value = ((Object[])_rows[row])[col];
  } catch (Exception e) {
    value = e;
  return value;
private Object[] getValues(Describeable d) {
 int size = _props.size();
 Object[] props = new Object[size];
 for(int i = 0; i < size; i++)
   props[i]  = ((PropertyDescriptor)_props.get(i)).getValue(d);
 return props;