@Override
protected ConnectFuture connect0(
SocketAddress remoteAddress, SocketAddress localAddress,
IoSessionInitializer<? extends ConnectFuture> sessionInitializer) {
CommPortIdentifier portId;
Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();
SerialAddress portAddress = (SerialAddress) remoteAddress;
// looping around found ports
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (log.isDebugEnabled()) {
log.debug("Serial port discovered : " + portId.getName());
}
if (portId.getName().equals(portAddress.getName())) {
try {
if (log.isDebugEnabled()) {
log
.debug("Serial port found : "
+ portId.getName());
}
SerialPort serialPort = initializePort("Apache MINA",
portId, portAddress);