
it.tidalwave.actor.impl.DefaultCollaboration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of it-tidalwave-actor Show documentation
Show all versions of it-tidalwave-actor Show documentation
An experimental module which provides an implementation of an actor-based framework.
/*
* #%L
* *********************************************************************************************************************
*
* These Foolish Things - Miscellaneous utilities
* http://thesefoolishthings.tidalwave.it - git clone [email protected]:tidalwave/thesefoolishthings-src.git
* %%
* Copyright (C) 2009 - 2016 Tidalwave s.a.s. (http://tidalwave.it)
* %%
* *********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* *********************************************************************************************************************
*
* $Id$
*
* *********************************************************************************************************************
* #L%
*/
package it.tidalwave.actor.impl;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import java.io.Serializable;
import com.eaio.uuid.UUID;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import it.tidalwave.actor.Collaboration;
import it.tidalwave.actor.CollaborationCompletedMessage;
import it.tidalwave.actor.CollaborationStartedMessage;
import it.tidalwave.actor.annotation.Message;
import lombok.Getter;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import static lombok.AccessLevel.PRIVATE;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
@RequiredArgsConstructor(access = PRIVATE) @EqualsAndHashCode(of = "id") @Slf4j @ToString(of = "id")
public class DefaultCollaboration implements Serializable, Collaboration
{
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
private final static DefaultCollaboration NULL_DEFAULT_COLLABORATION = new DefaultCollaboration(new Object())
{
@Override
public void bindToCurrentThread()
{
}
@Override
public void unbindFromCurrentThread()
{
}
};
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
@RequiredArgsConstructor @ToString
private static class IdentityWrapper
{
@Nonnull
private final Object object;
@Override
public boolean equals (final Object object)
{
if ((object == null) || (getClass() != object.getClass()))
{
return false;
}
final IdentityWrapper other = (IdentityWrapper)object;
return this.object == other.object;
}
@Override
public int hashCode()
{
return object.hashCode();
}
}
private final static ThreadLocal THREAD_LOCAL = new ThreadLocal();
private final UUID id = new UUID();
@Nonnull @Getter
private final Object originatingMessage;
private final long startTime = System.currentTimeMillis();
@Getter
private boolean completed;
private final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy