FileDocCategorySizeDatePackage
NamingServiceExplorerFrame.javaAPI DocExample5548Thu Nov 08 00:22:54 GMT 2001com.ora.rmibook.chapter15.basicapps

NamingServiceExplorerFrame

public class NamingServiceExplorerFrame extends JFrame

Fields Summary
private JTextArea
_resultsArea
private JTextField
_pathField
private JTextField
_attributeNameField
private JTextField
_attributeValueField
private JButton
_queryNamingServiceButton
Constructors Summary
public NamingServiceExplorerFrame()

        buildGUI();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new ExitOnClose());
    
Methods Summary
private voidbuildGUI()

        JPanel mainPanel = new JPanel(new BorderLayout());

        _resultsArea = new JTextArea();
        mainPanel.add(new JScrollPane(_resultsArea), BorderLayout.CENTER);
        _queryNamingServiceButton = new JButton("Check Naming Service Contents");
        _queryNamingServiceButton.addActionListener(new QueryRegistry());
        _pathField = new JTextField();
        _attributeNameField = new JTextField();
        _attributeValueField = new JTextField();
        JPanel bottomPanel = new JPanel(new GridLayout(4, 2));

        bottomPanel.add(new JLabel("Attribute Name"));
        bottomPanel.add(_attributeNameField);
        bottomPanel.add(new JLabel("AttributeValue"));
        bottomPanel.add(_attributeValueField);
        bottomPanel.add(new JLabel("Context"));
        bottomPanel.add(_pathField);
        bottomPanel.add(_queryNamingServiceButton);
        mainPanel.add(bottomPanel, BorderLayout.SOUTH);
        getContentPane().add(mainPanel);
        setSize(250, 200);
    
private voiddisplayInformationForRemote(java.rmi.Remote remoteObject)

        if (null == remoteObject) {
            return;
        }
        Collection interfaces = getRemoteInterfacesForObject(remoteObject);

        if (null == interfaces) {
            return;
        }
        _resultsArea.append("Server implements the following remote interfaces\n");
        Iterator i = interfaces.iterator();

        while (i.hasNext()) {
            _resultsArea.append("\t" + i.next() + "\n");
        }
        return;
    
private java.util.CollectiongetRemoteInterfacesForObject(java.lang.Object object)

        Class objectType = object.getClass();
        Class[] interfaces = objectType.getInterfaces();
        Class remoteInterface = Remote.class;

        if ((null == interfaces) || (0 == interfaces.length)) {
            return null;
        }
        ArrayList returnValue = new ArrayList();
        int counter;

        for (counter = 0; counter < interfaces.length; counter++) {
            if (remoteInterface.isAssignableFrom(interfaces[counter])) {
                returnValue.add(interfaces[counter]);
            }
        }
        return returnValue;