
org.objectweb.dream.protocol.rpc.InvocationChunk Maven / Gradle / Ivy
/**
* Dream
* Copyright (C) 2003-2004 INRIA Rhone-Alpes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: [email protected]
*
* Initial developer(s): Matthieu Leclercq
* Contributor(s):
*/
package org.objectweb.dream.protocol.rpc;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.objectweb.dream.message.AbstractChunk;
import org.objectweb.dream.util.Util;
public final class InvocationChunk extends AbstractChunk
{
private static final long serialVersionUID = 6117081492117202644L;
/** The default name of chunks of this type. */
public static final String DEFAULT_NAME = "invocation_chunk";
/** A constant empty object array. */
public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
private long invocationId;
private int methodId;
private Object[] parameters;
// ---------------------------------------------------------------------------
// Chunk methods
// ---------------------------------------------------------------------------
/**
* @return Returns the invocationId.
*/
public long getInvocationId()
{
return invocationId;
}
/**
* @param invocationId The invocationId to set.
*/
public void setInvocationId(long invocationId)
{
this.invocationId = invocationId;
}
/**
* @return Returns the methodId.
*/
public int getMethodId()
{
return methodId;
}
/**
* @param methodId The methodId to set.
*/
public void setMethodId(int methodId)
{
this.methodId = methodId;
}
/**
* @return Returns the parameters.
*/
public Object[] getParameters()
{
return parameters;
}
/**
* @param parameters The parameters to set.
*/
public void setParameters(Object[] parameters)
{
this.parameters = parameters;
}
// ---------------------------------------------------------------------------
// Implementation of the Chunk interface
// ---------------------------------------------------------------------------
/**
* @see AbstractChunk#newChunk()
*/
public InvocationChunk newChunk()
{
return new InvocationChunk();
}
/**
* @see AbstractChunk#transfertStateTo(AbstractChunk)
*/
public void transfertStateTo(InvocationChunk chunk)
{
chunk.invocationId = invocationId;
chunk.methodId = methodId;
chunk.parameters = parameters; // TODO clone array ?
}
/**
* @see org.objectweb.dream.pool.Recyclable#recycle()
*/
public void recycle()
{
invocationId = 0;
methodId = 0;
parameters = null;
}
// ---------------------------------------------------------------------------
// Implementation of the Externalizable interface
// ---------------------------------------------------------------------------
/**
* @see java.io.Externalizable#readExternal(ObjectInput)
*/
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException
{
invocationId = in.readLong();
methodId = in.readInt();
parameters = Util.readExternalObjectArray(in);
}
/**
* @see java.io.Externalizable#writeExternal(ObjectOutput)
*/
public void writeExternal(ObjectOutput out) throws IOException
{
out.writeLong(invocationId);
out.writeInt(methodId);
Util.writeExternalObjectArray(out, parameters);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy