* Implementation of TCPMessageListener.onMessage
* method is called once request message come
*/
public void onMessage(@NotNull final ChannelContext channelContext) throws IOException {
if (logger.isLoggable(Level.FINE)) {
final Connection connection = channelContext.getConnection();
logger.log(Level.FINE, MessagesMessages.WSTCP_1103_WSTCP_DELEGATE_ON_MESSAGE(connection.getHost(), connection.getPort(),
connection.getLocalHost(), connection.getLocalPort()));
}
try {
TCPAdapter target = null;
if (channelContext.getChannelId() > 0) {
final WSTCPURI tcpURI = channelContext.getTargetWSURI();
target = getTarget(tcpURI);
} else {
target = getServiceChannelWSAdapter();
}
if (target != null) {
target.handle(channelContext);
} else {
TCPAdapter.sendErrorResponse(channelContext,
WSTCPError.createNonCriticalError(TCPConstants.UNKNOWN_CHANNEL_ID,
MessagesMessages.WSTCP_0026_UNKNOWN_CHANNEL_ID(channelContext.getChannelId())));
}
} catch (WSTCPException e) {
final Connection connection = channelContext.getConnection();
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0023_TARGET_EXEC_ERROR(connection.getHost(), connection.getPort()), e);
sendErrorResponse(channelContext, e.getError());
if (e.getError().isCritical()) {
channelContext.getConnectionSession().close();
}
} catch (JAXWSExceptionBase e) {
final Connection connection = channelContext.getConnection();
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0023_TARGET_EXEC_ERROR(connection.getHost(), connection.getPort()), e);
sendErrorResponse(channelContext, WSTCPError.createNonCriticalError(TCPConstants.GENERAL_CHANNEL_ERROR,
MessagesMessages.WSTCP_0025_GENERAL_CHANNEL_ERROR(MessagesMessages.WSTCP_0004_CHECK_SERVER_LOG())));
} catch (IOException e) {
final Connection connection = channelContext.getConnection();
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0023_TARGET_EXEC_ERROR(connection.getHost(), connection.getPort()), e);
throw e;
} catch (Exception e) {
final Connection connection = channelContext.getConnection();
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0023_TARGET_EXEC_ERROR(connection.getHost(), connection.getPort()), e);
sendErrorResponse(channelContext, WSTCPError.createNonCriticalError(TCPConstants.GENERAL_CHANNEL_ERROR,
MessagesMessages.WSTCP_0025_GENERAL_CHANNEL_ERROR(MessagesMessages.WSTCP_0004_CHECK_SERVER_LOG())));
} finally {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, MessagesMessages.WSTCP_1104_WSTCP_DELEGATE_ON_MESSAGE_COMPLETED());