Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* $Id: EventGroup.java 23797 2012-02-02 04:07:49Z dfeist $
* --------------------------------------------------------------------------------------
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
*
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.routing;
import org.mule.DefaultMessageCollection;
import org.mule.DefaultMuleEvent;
import org.mule.api.MuleContext;
import org.mule.api.MuleEvent;
import org.mule.api.MuleException;
import org.mule.api.MuleMessage;
import org.mule.api.MuleMessageCollection;
import org.mule.api.MuleSession;
import org.mule.api.config.MuleProperties;
import org.mule.api.store.ListableObjectStore;
import org.mule.api.store.ObjectStoreException;
import org.mule.api.store.ObjectStoreManager;
import org.mule.session.DefaultMuleSession;
import org.mule.util.ClassUtils;
import org.mule.util.store.DeserializationPostInitialisable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.collections.IteratorUtils;
/**
* EventGroup is a holder over events grouped by a common group Id. This
* can be used by components such as routers to managed related events.
*/
// @ThreadSafe
public class EventGroup implements Comparable, Serializable, DeserializationPostInitialisable
{
/**
* Serial version
*/
private static final long serialVersionUID = 953739659615692697L;
public static final MuleEvent[] EMPTY_EVENTS_ARRAY = new MuleEvent[0];
public static final String MULE_ARRIVAL_ORDER_PROPERTY = MuleProperties.PROPERTY_PREFIX + "ARRIVAL_ORDER";
transient private ObjectStoreManager objectStoreManager = null;
private final Object groupId;
transient ListableObjectStore events;
private final long created;
private final int expectedSize;
transient private MuleContext muleContext;
private final String storePrefix;
private String commonRootId = null;
private static boolean hasNoCommonRootId = false;
private int arrivalOrderCounter = 0;
public static final String DEFAULT_STORE_PREFIX = "DEFAULT_STORE";
public EventGroup(Object groupId, MuleContext muleContext)
{
this(groupId, muleContext, -1, false, DEFAULT_STORE_PREFIX);
}
public EventGroup(Object groupId,
MuleContext muleContext,
int expectedSize,
boolean storeIsPersistent,
String storePrefix)
{
super();
this.created = System.nanoTime();
this.muleContext = muleContext;
this.storePrefix = storePrefix;
String storeKey = storePrefix + ".eventGroup." + groupId;
this.events = getObjectStoreManager().getObjectStore(storeKey, storeIsPersistent);
this.expectedSize = expectedSize;
this.groupId = groupId;
}
/**
* Compare this EventGroup to another one. If the receiver and the argument both
* have groupIds that are {@link Comparable}, they are used for the comparison;
* otherwise - since the id can be any object - the group creation time stamp is
* used as fallback. Older groups are considered "smaller".
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
@SuppressWarnings("unchecked")
public int compareTo(EventGroup other)
{
Object otherId = other.getGroupId();
if (groupId instanceof Comparable> && otherId instanceof Comparable>)
{
return ((Comparable