Guide 5: Integration Overview for Telnet Service Auto-Complete

Overview

The Telnet Service is a library that provides easy-to-integrate TELNET functionality to Java(TM) applications. Although its main purpose is to integrate servers as an administration console, its versatility puts creativity as the only limitation to its usage.

The Auto-Complete extension provides syntax auto-complete suggestions through Tab event, and depends on the Syntax Tree extension.

Introduction

The Auto-Complete extension is simple to integrate with an application that already has Telnet Service functionality extended with the Syntax Tree features. The following guide will show the steps to add auto-complete functionality.

Unlike the first few examples, this guide does not come with a set of source files. It is assumed that the reader has gone through the previous examples and by now understands how the system works.

It is therefore recommended to read those examples, check the 'Related Documentation' section below.

Integrating auto-complete functionality

The TelnetServiceExtensionAutoCompleteImpl is registered against the TelnetService . The ActionListenerAutoCompleteImpl must have a high priority; however, lesser than that of the JAAS action handler (if used).

If we were to add the auto-complete functionality to Example4:

public class Example4 extends Example3
{
    public void initialize() {
        super.initialize();
        
        super.telnetService.registerExtension(new TelnetServiceExtensionLineHistoryImpl());
        super.telnetService.registerExtension(new TelnetServiceExtensionAutoCompleteImpl());
    }
    
    public static void main(String[] args) throws TelnetServiceStartException {
        Example4 example = new Example4();
        example.initialize();
        example.run();
    }
}

That's it.

Note: to allow case insensitive auto-complete, set it to true :

        TelnetServiceExtensionAutoCompleteImpl autoCompleteExtension =
            new TelnetServiceExtensionAutoCompleteImpl();
        
        autoCompleteExtension.setIsCaseInsensitive(true);
        super.telnetService.registerExtension(autoCompleteExtension);

Going For a Test Run

Tab provides the next available operation suggestions, based on already typed text.