<commit_before>package org.lightmare.remote.rpc.decoders;

import java.io.IOException;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
import org.lightmare.remote.rpc.wrappers.RpcWrapper;
import org.lightmare.utils.RpcUtils;
import org.lightmare.utils.serialization.NativeSerializer;

/**
 * Encoder class for netty remote procedure call
 * 
 * @author levan
 * 
 */
public class RpcEncoder extends SimpleChannelHandler {

    @Override
    public void writeRequested(ChannelHandlerContext ctx, MessageEvent ev)
	    throws IOException {

	RpcWrapper wrapper = (RpcWrapper) ev.getMessage();

	String beanName = wrapper.getBeanName();
	String methodName = wrapper.getMethodName();
	Class<?>[] paramTypes = wrapper.getParamTypes();
	Class<?> interfaceClass = wrapper.getInterfaceClass();
	Object[] params = wrapper.getParams();

	byte[] beanNameBt = beanName.getBytes("UTF8");
	byte[] beanMethodBt = NativeSerializer.serialize(methodName);
	byte[] paramTypesBt = NativeSerializer.serialize(paramTypes);
	byte[] interfaceClassBt = NativeSerializer.serialize(interfaceClass);
	byte[] paramBt = NativeSerializer.serialize(params);

	int paramsSize = RpcUtils.PROTOCOL_SIZE + beanNameBt.length
		+ beanMethodBt.length + paramTypesBt.length
		+ interfaceClassBt.length + paramBt.length;

	ChannelBuffer buffer = ChannelBuffers.buffer(paramsSize);

	buffer.writeInt(beanNameBt.length);
	buffer.writeInt(beanMethodBt.length);
	buffer.writeInt(paramTypesBt.length);
	buffer.writeInt(interfaceClassBt.length);
	buffer.writeInt(paramBt.length);

	buffer.writeBytes(beanNameBt);
	buffer.writeBytes(beanMethodBt);
	buffer.writeBytes(paramTypesBt);
	buffer.writeBytes(interfaceClassBt);
	buffer.writeBytes(paramBt);

	ChannelFuture future = ev.getFuture();
	Channels.write(ctx, future, buffer);

    }
}<commit_msg>code improvements for remote service classes<commit_after>package org.lightmare.remote.rpc.decoders;

import java.io.IOException;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
import org.lightmare.remote.rpc.wrappers.RpcWrapper;
import org.lightmare.utils.RpcUtils;
import org.lightmare.utils.serialization.NativeSerializer;

/**
 * Encoder class for netty remote procedure call
 * 
 * @author levan
 * 
 */
public class RpcEncoder extends SimpleChannelHandler {

    @Override
    public void writeRequested(ChannelHandlerContext ctx, MessageEvent ev)
	    throws IOException {

	RpcWrapper wrapper = (RpcWrapper) ev.getMessage();

	String beanName = wrapper.getBeanName();
	String methodName = wrapper.getMethodName();
	Class<?>[] paramTypes = wrapper.getParamTypes();
	Class<?> interfaceClass = wrapper.getInterfaceClass();
	Object[] params = wrapper.getParams();

	byte[] beanNameBt = beanName.getBytes("UTF8");
	byte[] beanMethodBt = NativeSerializer.serialize(methodName);
	byte[] paramTypesBt = NativeSerializer.serialize(paramTypes);
	byte[] interfaceClassBt = NativeSerializer.serialize(interfaceClass);
	byte[] paramBt = NativeSerializer.serialize(params);

	int paramsSize = RpcUtils.PROTOCOL_SIZE + beanNameBt.length
		+ beanMethodBt.length + paramTypesBt.length
		+ interfaceClassBt.length + paramBt.length;

	ChannelBuffer buffer = ChannelBuffers.buffer(paramsSize);

	buffer.writeInt(beanNameBt.length);
	buffer.writeInt(beanMethodBt.length);
	buffer.writeInt(paramTypesBt.length);
	buffer.writeInt(interfaceClassBt.length);
	buffer.writeInt(paramBt.length);

	buffer.writeBytes(beanNameBt);
	buffer.writeBytes(beanMethodBt);
	buffer.writeBytes(paramTypesBt);
	buffer.writeBytes(interfaceClassBt);
	buffer.writeBytes(paramBt);

	ChannelFuture future = ev.getFuture();
	Channels.write(ctx, future, buffer);
    }
}
{'fraction_non_alphanumeric': 0.11058150619637751, 'fraction_numerical': 0.00047664442326024784, 'mean_word_length': 6.299130434782609, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '827949', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1286, 'n_words': 221}