jSyncManager

org.jSyncManager.API.Transport
Class SLPTransportInterface

java.lang.Object
  |
  +--org.jSyncManager.API.Transport.SLPTransportInterface
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DebugTransport, ModemTransport, SerialTransportInterface, USBTransportInterface

public abstract class SLPTransportInterface
extends java.lang.Object
implements java.io.Serializable

SLP Transport Abstract Class. This abstract class provides a standardized manner in which to define the possible transport mechanisms for a SLP packet, including various serial interfaces, and potentially through the embedding of SLP into other protocols.

Version:
$Revision: 1.7 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/04/23 00:22:53 $.
See Also:
Serialized Form

Field Summary
protected  javax.swing.JPanel configPanel
          A handle to the transports configuration panel.
protected  boolean connected
          Boolean flag to determine if connection has been established
 
Constructor Summary
SLPTransportInterface()
          Creates a new SLPTransportInterface.
 
Method Summary
abstract  void close()
          Closes the implemented transport.
protected abstract  javax.swing.JPanel constructConfigPanel()
          Constructs this transports configuration panel.
abstract  void flush()
          Flushes the input buffer of any remaining data.
 javax.swing.JPanel getConfigPanel()
          Gets a handle to this transports configuration panel.
protected  java.util.ResourceBundle getResourceBundle()
          Returns the handle to the current resource bundle.
abstract  java.lang.String getResourceBundleName()
          Returns the fully-qualified classname for the resources package to use for this transport.
abstract  java.lang.String getTransportDescription()
          Returns the description for this Transport Interface.
abstract  java.lang.String getTransportExceptionText(TransportException ex)
          Retrieves error information for a given TransportInitException.
abstract  java.lang.String getTransportName()
          Returns the name of this Transport Interface.
abstract  void initialize()
          Initialize the port.
abstract  void initialize(java.util.Properties properties, int id)
          Initialize the port.
 boolean isConnected()
          Getter for connected property.
 void loadResourceBundle()
          Loads the resources class returned by getResourceBundleName().
abstract  void open()
          Opens a read/write connection to the implemented transport.
abstract  byte readByte()
          Read a single byte from the underlying data stream.
protected  void setConnected(boolean connected)
          Setter for the connected property.
abstract  void writeBytes(byte[] data)
          Write an array of bytes to the underlying data stream.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configPanel

protected transient javax.swing.JPanel configPanel
A handle to the transports configuration panel.

connected

protected transient boolean connected
Boolean flag to determine if connection has been established
Constructor Detail

SLPTransportInterface

public SLPTransportInterface()
                      throws TransportException
Creates a new SLPTransportInterface. Subclasses should throw a TransportException if the underlying communications API is not available, or can't be properly constructed. It is suggested that transport developers attempt to dynamically load one of the core underlying API classes, and throw a TransportException if it isn't available, or isn't setup/configured correctly by the user.
Throws:
TransportException - thrown if there is any error during construction of the transport.
Method Detail

close

public abstract void close()
                    throws TransportException
Closes the implemented transport. This method should close the transport device being implemented.
Throws:
TransportException - throws any required exception.

flush

public abstract void flush()
                    throws TransportException
Flushes the input buffer of any remaining data.
Throws:
thrown - when a problem occurs with flushing the stream.

getTransportName

public abstract java.lang.String getTransportName()
Returns the name of this Transport Interface. This method will return a string containing the name of this transport interface. This is used when searching for and selecting from one of many available transport interfaces that are installed on the system.
Returns:
the name of this transport interface.

open

public abstract void open()
                   throws TransportException
Opens a read/write connection to the implemented transport. This method should open the transport device being implemented using default parameters.
Throws:
TransportException - any exception the underlying code may throw.

readByte

public abstract byte readByte()
Read a single byte from the underlying data stream. This method call should abstract the underlying data connection stream to allow the SLP protocol to read a single byte from the stream. This method shouldn't throw any exceptions. Instead, if you can't read data, return 0. The protocol stack will eventually detect that no valid data is being transmitted and will time-out automatically.

writeBytes

public abstract void writeBytes(byte[] data)
Write an array of bytes to the underlying data stream. This method call should abstract the underlying data connection stream to allow the SLP protocol to write an array of bytes to the stream. This method shouldn't throw any exceptions. If the data cannot be written, it should be discarded. The protocol stack will eventually detect that its transmissions are no longer acknowledged, and will time out automatically.
Parameters:
data - the bytes to be written to the underlying stream.

getConfigPanel

public final javax.swing.JPanel getConfigPanel()
Gets a handle to this transports configuration panel. This method is final. Do not override this. If you wish to provide a configurating JPanel, implement constructConfigPanel instead.
Returns:
a javax.swing.JPanel containing the transports settings panel.

constructConfigPanel

protected abstract javax.swing.JPanel constructConfigPanel()
Constructs this transports configuration panel. This method will be called the first time a transports configuration panel is requested. It is up to the specific transport implementation to handle its own configuration via a configuration JPanel. This JPanel may contain whatever controls you require.
Returns:
a javax.swing.JPanel containing the transports settings panel.

initialize

public abstract void initialize()
                         throws TransportException
Initialize the port. This method is called to initialize this transport using the objects stored settings. You should perform whatever setup you require here. These objects may be serialized, however it isn't guaranteed that the underlying API classes are also serializable. As such you should store any user settings as non-transient fields, and setup the transport based on those settings here. This method will be called whenever the port requires initialization. Note you may also call this method in your event handlers for when the user changes the transport settings. Your implementation should throw a TransportInitException if there isn't sufficient information to setup the transport. Applications can catch this exception and use it to display the necessary settings dialog to the use.
Throws:
TransportException - thrown if there isn't sufficient info to setup the transport, or if another exception has occurred.

initialize

public abstract void initialize(java.util.Properties properties,
                                int id)
                         throws TransportException
Initialize the port. This initializer is called when the port needs to be configured from a properties file. This is necessary for when the jConduit is constructed in a text-only or daemon application, which is unable to display the GUI configuration panel. The method accepts a transport ID number 'id', which should be used to differentiate the different ports defined in the properties file by using keys of the form "header.property.". This is necessary as such a property file may contain multiple sets of properties for different ports. Once the properties have been loaded, it is acceptable to call the initialize() method from within this method to initialize the connection, so long as the initialize() method contains no GUI code.
Parameters:
properties - a reference to the properties file containing configuration information.
id - the transport ID number to load data for.
Throws:
TransportException - if there is a problem initializing the transport.

getTransportExceptionText

public abstract java.lang.String getTransportExceptionText(TransportException ex)
Retrieves error information for a given TransportInitException. To ensure that we can keep code that uses the transport subclasses as generic as possible, this method should take a TransportInitException instance, inspect it, and provide a plaintext explaination for the error that can be shown to the user.
Parameters:
ex - the TransportInitException to be inspected.
Returns:
a String object containing a text explaination for the exception.

getResourceBundleName

public abstract java.lang.String getResourceBundleName()
Returns the fully-qualified classname for the resources package to use for this transport. Your Transport implementation should return a String containing the name of your ResourceBundle class here.
Returns:
a String object containing the fully qualified classname for a ResoureBundle class to use for this transport.

loadResourceBundle

public final void loadResourceBundle()
                              throws TransportException
Loads the resources class returned by getResourceBundleName().
See Also:
getResourceBundleName()

isConnected

public final boolean isConnected()
Getter for connected property.
Returns:
true if this transport is connected to the remote device, false otherwise.

setConnected

protected final void setConnected(boolean connected)
Setter for the connected property.
Parameters:
connected - true if this transport is now connected, false otherwise.

getTransportDescription

public abstract java.lang.String getTransportDescription()
Returns the description for this Transport Interface. This method will return a string containing the description for this transport interface.
Returns:
the description for this transport interface.

getResourceBundle

protected final java.util.ResourceBundle getResourceBundle()
Returns the handle to the current resource bundle.
Returns:
the ResourceBundle for use with this transport.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.