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

org.objectweb.dream.queue.PushPushUnlockKey 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): Romain Lenglet
 */

package org.objectweb.dream.queue;


import org.objectweb.dream.InterruptedPushException;
import org.objectweb.dream.Push;
import org.objectweb.dream.PushException;
import org.objectweb.dream.message.Message;
import org.objectweb.dream.queue.buffer.UnlockKey;
import org.objectweb.dream.dreamannotation.DreamComponent;
import org.objectweb.fractal.fraclet.annotation.annotations.Interface;
import org.objectweb.fractal.fraclet.annotation.annotations.Provides;
import org.objectweb.fractal.fraclet.annotation.annotations.Requires;

/**
 * This component forwards incoming messages and then call
 * {@link UnlockKey#unlockKey()}.
 */
@DreamComponent(controllerDesc = "dreamUnstoppablePrimitive")
@Provides(interfaces = {
    @Interface(name = "in-push", signature = Push.class)})
public class PushPushUnlockKey  implements Push
{

  // ---------------------------------------------------------------------------
  // Client interfaces.
  // ---------------------------------------------------------------------------
  @Requires(name = "out-push")
  Push      outPushItf;
  @Requires(name = UnlockKey.ITF_NAME)
  UnlockKey unlockKeyItf;

  // ---------------------------------------------------------------------------
  // Implementation of the Push interface.
  // ---------------------------------------------------------------------------

  /**
   * @see Push#push(Message)
   */
  public void push(Message message) throws PushException
  {
    try
    {
      outPushItf.push(message);
    }
    finally
    {
      try
      {
        unlockKeyItf.unlockKey();
      }
      catch (InterruptedException e)
      {
        throw new InterruptedPushException(e);
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy