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

org.objectweb.dream.aggregator.PushPushDisaggregator 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): Vivien Quema, Romain Lenglet
 */

package org.objectweb.dream.aggregator;

import java.util.Iterator;

import org.objectweb.dream.Push;
import org.objectweb.dream.PushException;
import org.objectweb.dream.dreamannotation.DreamComponent;
import org.objectweb.dream.message.Message;
import org.objectweb.dream.message.MessageManagerType;
import org.objectweb.fractal.fraclet.annotation.annotations.Interface;
import org.objectweb.fractal.fraclet.annotation.annotations.Provides;
import org.objectweb.fractal.fraclet.annotation.annotations.Requires;

/**
 * Basic implementation of a Push/Push de-aggregator. Each sub message in the
 * pushed message is sent on the output. The pushed message is then deleted.
 */
@DreamComponent(controllerDesc = "dreamPrimitive")
@Provides(interfaces=@Interface(name = "in-push", signature=Push.class))
public class PushPushDisaggregator
    implements
      Push
{

  /** the message manager client interface of this component. */
  @Requires(name = "message-manager")
  protected MessageManagerType messageManagerItf;

  @Requires(name = "out-push")
  protected Push           outPushItf;

  // ---------------------------------------------------------------------------
  // Push Interface Implementation
  // ---------------------------------------------------------------------------
  
  /**
   * @see org.objectweb.dream.Push#push(Message)
   */
  public void push(Message message) throws PushException
  {
    Iterator iterator = messageManagerItf
        .getSubMessageIterator(message);
    while (iterator.hasNext())
    {
      Message subMessage = iterator.next();
      outPushItf.push(subMessage);
      messageManagerItf.removeSubMessage(message, subMessage);
    }
    messageManagerItf.deleteMessage(message);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy