|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.java4less.comm.CommConnector
Abstract class to be used for a variety of communication connections.
The basic idea is to have a very generic way to use any kind
of bi-directional communication.
Generic Example:
CommConnector cx = SpecificConnector( param1, param2, ... paramN ); try { cx.open(); ... while ( !done ) { ... cx.out.write( ... ); ... cx.in.read( ... ); ... } ... cx.close(); ... } catch ( CommException e ) { this.logger.severe( "Comm. Error: " + e.getMessage() ); } catch ( IOException e ) { cx.close(); this.logger.severe( "I/O Error: " + e.getMessage() ); }The hard work will be usually done in the open() method, and parameters needed to establish a connection will be usually passed in the sub-classes contructors or with sub-class specific methods.
Exceptions
ACommException
is usually thrown when the
connection cannot be established in the open() method.
Field Summary | |
java.io.InputStream |
in
Input Stream that retrieves data from the communications port. |
Logger |
logger
Logger object to be used to monitor the connexion attempts. |
java.io.OutputStream |
out
Output Stream that sends data to the communications port. |
Method Summary | |
abstract void |
close()
Closes communication channel. |
abstract void |
open()
Opens Communications channel so in & out streams can be used. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public java.io.InputStream in
public java.io.OutputStream out
public Logger logger
CommConnector cx = SpecificConnector( param1, param2, ... paramN ); cx.logger = Logger.getLogger("com.java4less.comm.logger"); cx.logger.setLevel( 7 );
Logger
Method Detail |
public abstract void open() throws CommException, java.io.IOException
CommException
java.io.IOException
public abstract void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |