![JAR search and dependency download from the Maven repository](/logo.png)
host.anzo.simon.codec.base.MsgInterfaceLookupEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simon Show documentation
Show all versions of simon Show documentation
Simple Invocation of Methods Over Network, a kind of RMI replacement
The newest version!
/*
* Copyright (C) 2008 Alexander Christian . All rights reserved.
*
* This file is part of SIMON.
*
* SIMON is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SIMON is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SIMON. If not, see .
*/
package host.anzo.simon.codec.base;
import host.anzo.simon.codec.messages.MsgError;
import host.anzo.simon.codec.messages.MsgInterfaceLookup;
import host.anzo.simon.codec.messages.MsgNameLookup;
import lombok.extern.slf4j.Slf4j;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.demux.MessageEncoder;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
/**
* A {@link MessageEncoder} that encodes {@link MsgNameLookup}.
*
* @author ACHR
*/
@Slf4j
public class MsgInterfaceLookupEncoder extends AbstractMessageEncoder {
@Override
protected void encodeBody(IoSession session, T message, IoBuffer out) {
log.trace("begin. message={}", message);
log.trace("position before: {}", out.position());
try {
out.putPrefixedString(message.getCanonicalInterfaceName(), Charset.forName("UTF-8").newEncoder());
} catch (CharacterCodingException e) {
MsgError error = new MsgError();
error.setEncodeError();
error.setErrorMessage(
"Error while encoding interface lookup() request: Not able to write interface name '" +
message.getCanonicalInterfaceName() + "' due to CharacterCodingException.");
error.setRemoteObjectName(null);
error.setInitSequenceId(message.getSequence());
error.setThrowable(e);
sendEncodingError(out, session, error);
}
log.trace("position after: {}", out.position());
log.trace("end");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy