Guide 4: Integration Overview for Telnet Service Line History Example (4)

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 Line-History extension provides command history recall through up / down arrow as well as other useful features.

Introduction

Unlike the 2 first examples, the step-by-step process for building the example is not provided. A quick read of those examples should have given the big lines of how the library customization process works.

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

Integrating command history functionality

The telnetservice-linehistory library functionality are simple to add to an existing telnetservice integration. This example (Example4 ) extends Example3 and registers the line-history service extension:

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

That's it!

Going For a Test Run

Compile, run Example4. Try a few commands, up arrow brings the last applied command, further up arrows cycle through the history list. Down arrows cycle in reverse order. Ctrl-C cancels the current prompt active contents, Ctrl-L lists the current history contents.

Download the Example Source

The complete example sources can be downloaded at the project download section .