All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.objectweb.dream.protocol.rpc.StubClassChunk 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;

/**
 * Chunk which contains one field class related to the stub that will be created.
 * 
 * @author Matthieu Leclercq
 */
public final class StubClassChunk extends AbstractChunk
{

  private static final long  serialVersionUID = 1L;

  /** The default name of chunks of this type. */
  public static final String DEFAULT_NAME     = "stub-class-chunk";

  private Class              stubClass;

  // ---------------------------------------------------------------------------
  // Chunk methods
  // ---------------------------------------------------------------------------

  /**
   * Default constructor.
   */
  public StubClassChunk()
  {
  }

  /**
   * @param stubClass the stub class.
   */
  public StubClassChunk(Class stubClass)
  {
    this.stubClass = stubClass;
  }

  /**
   * @return Returns the stubClass.
   */
  public Class getStubClass()
  {
    return stubClass;
  }

  /**
   * @param stubClass The stubClass to set.
   */
  public void setStubClass(Class stubClass)
  {
    this.stubClass = stubClass;
  }

  // ---------------------------------------------------------------------------
  // Implementation of the Chunk interface
  // ---------------------------------------------------------------------------

  /**
   * @see AbstractChunk#newChunk()
   */
  public StubClassChunk newChunk()
  {
    return new StubClassChunk();
  }

  /**
   * @see AbstractChunk#transfertStateTo(AbstractChunk)
   */
  public void transfertStateTo(StubClassChunk newInstance)
  {
    newInstance.stubClass = stubClass;
  }

  /**
   * @see org.objectweb.dream.pool.Recyclable#recycle()
   */
  public void recycle()
  {
    stubClass = null;
  }

  // ---------------------------------------------------------------------------
  // Implementation of the Externalizable interface
  // ---------------------------------------------------------------------------

  /**
   * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
   */
  public void readExternal(ObjectInput in) throws IOException,
      ClassNotFoundException
  {
    stubClass = (Class) in.readObject();
  }

  /**
   * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
   */
  public void writeExternal(ObjectOutput out) throws IOException
  {
    out.writeObject(stubClass);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy