/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.dynamo.event;

import com.silverwrist.dynamo.iface.Request;
import com.silverwrist.dynamo.iface.ScriptEngineRegisterObject;

/**
 * An event which is posted to all registered
 * {@link com.silverwrist.dynamo.event.ScriptEngineStartListener ScriptEngineStartListener} objects when a new
 * instance of a script engine is started.  It passes along an instance of
 * {@link com.silverwrist.dynamo.iface.ScriptEngineRegisterObject ScriptEngineRegisterObject} so that new
 * objects can be registered with the new script engine.
 *
 * @author Eric J. Bowersox &lt;erbo@silcom.com&gt;
 * @version X
 */
public class ScriptEngineStartEvent extends DynamoEventObject
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private transient ScriptEngineRegisterObject m_registrar;  // allows registering new objects

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  /**
   * Constructs a new <CODE>ScriptEngineStartEvent</CODE>.
   *
   * @param request The current request.
   * @param registrar The script engine's
   *        {@link com.silverwrist.dynamo.iface.ScriptEngineRegisterObject ScriptEngineRegisterObject} interface.
   */
  public ScriptEngineStartEvent(Request request, ScriptEngineRegisterObject registrar)
  {
    super(request);
    m_registrar = registrar;

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Overrides from class DynamoEventObject
   *--------------------------------------------------------------------------------
   */

  /**
   * Returns a string representation of the object. In general, the <CODE>toString</CODE> method returns a string
   * that "textually represents" this object. 
   *
   * @return A string representation of the object.
   */
  public String toString()
  {
    return "ScriptEngineStartEvent: request = " + source + ", registrar = " + m_registrar;

  } // end toString

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  /**
   * Returns the current {@link com.silverwrist.dynamo.iface.Request Request} associated with the event.
   *
   * @return The current request associated with the event.
   */
  public Request getRequest()
  {
    return (Request)getSource();

  } // end getRequest

  /**
   * Returns the instance of {@link com.silverwrist.dynamo.iface.ScriptEngineRegisterObject ScriptEngineRegisterObject}
   * associated with the script engine that's currently starting up.
   *
   * @return The instance of <CODE>ScriptEngineRegisterObject</CODE> for the new script engine.
   */
  public ScriptEngineRegisterObject getRegistrar()
  {
    return m_registrar;

  } // end getRegistrar

} // end class ScriptEngineStartEvent
