Generic Connection Framework Example

Introduction

This is a simple Java application that demonstrates adding a new connection type that can be opened using the generic connection framework.
The actual connection is very simple, just adding enclosing each write in square brackets.

How it works

There are three main parts to this example
  1. The connection class
  2. Adding the class to the build
  3. Setting the user prefix for connections

Connection class

The connection class is the Java implementation of the class. All connection classes must be called Connection and extend the BaseConnection class. When a connection is opened, the setParameters method is invoked with the URL, the access mode and whether or not timeouts are enabled. The utility class ProtocolString should be used to parse the URL and this can then be used to set parameters on the new connection.

Adding the class to the build

The class needs to added to the build to make sure that it is available in the application. This is done in ANT by setting the property
    <property name="extra_classes" value="example.simple.Connection"/>

Setting the user prefix for connections

In order to be able to open the connection, the system needs to be told where to find the class. In this example, the connection type is 'simple' and can be found in example.simple.Connection.  The system needs to be told to look for user connections in the package example. This is done by adding the following property to config.xml.

    <property name="dct.connection.prefix.user" value="example"/>

Building the example

Change directory to the gcf example
    cd %LF_HOME%\examples\gcf

Rebuild the application
    ant clean all

Running the example

To run the example in the simulator
    lf2debug sw build\nondebug\gcf.lfa

To run the example on the board
    lfdownload build\nondebug\gcf.bin

Features

This example demonstrates the following SDK features.