nextgrid.api.pom
Interface Reference<T>

Type Parameters:
T - The type of the referenced value
All Superinterfaces:
java.lang.Cloneable, java.io.Serializable

public interface Reference<T>
extends java.io.Serializable, java.lang.Cloneable

Models an EndPointReference, that is, a reference to a remote process.

This reference must be filled in during workflow enaction.

Author:
Rodrigo Ruiz

Method Summary
 void addReader(Process reader)
          Adds a process to the readers list.
 void addWriter(Process writer)
          Adds a process to the writers list.
 boolean canCastFrom(java.lang.Class<?> type)
          Gets if the value can be converted from the specified type.
 boolean canCastTo(java.lang.Class<?> type)
          Gets if the value can be casted to the specified type.
 java.lang.Object castTo(java.lang.Class<?> type)
          Gets the value after casting it to the specified type.
 void clearLinks()
          Clears the reader and writer lists.
 Reference<T> copy()
          makes a deep copy of this instance.
 void dispose()
          Depending on the reference nature, it may be necessary to free resources, or perform some kind of finalisation.
 java.util.Set<Process> getReaders()
          Gets the reader processes attached to this reference.
 T getValue()
          Gets the referenced value.
 java.lang.Class<T> getValueType()
          Gets a class instance representing the type of referenced values.
 java.util.Set<Process> getWriters()
          Gets the writer processes attached to this reference.
 boolean isAvailable()
          Gets if the reference is available for reading.
 java.util.concurrent.locks.Lock readLock()
          Gets a lock for reading.
 void removeReader(Process reader)
          Removes a process from the readers list.
 void removeWriter(Process writer)
          Removes a process from the writers list.
 void reset()
          Clears the value and marks the reference as not available.
 void setAvailable(boolean available)
          Sets the available flag.
 void setValue(java.lang.Object value)
          Sets the referenced value.
 void waitAvailable()
          Waits until the reference is made available in another thread.
 java.util.concurrent.locks.Lock writeLock()
          Gets a lock for writing.
 

Method Detail

dispose

void dispose()
Depending on the reference nature, it may be necessary to free resources, or perform some kind of finalisation.


copy

Reference<T> copy()
makes a deep copy of this instance.

Returns:
A deep copy

clearLinks

void clearLinks()
Clears the reader and writer lists.


reset

void reset()
Clears the value and marks the reference as not available.


addReader

void addReader(Process reader)
Adds a process to the readers list.

Parameters:
reader - The process to add

addWriter

void addWriter(Process writer)
Adds a process to the writers list.

Parameters:
writer - The process to add

removeReader

void removeReader(Process reader)
Removes a process from the readers list.

Parameters:
reader - The process to remove

removeWriter

void removeWriter(Process writer)
Removes a process from the writers list.

Parameters:
writer - The process to remove

getWriters

java.util.Set<Process> getWriters()
Gets the writer processes attached to this reference.

Returns:
Returns the writers.

getReaders

java.util.Set<Process> getReaders()
Gets the reader processes attached to this reference.

Returns:
Returns the readers.

getValue

T getValue()
Gets the referenced value.

Returns:
The value

setValue

void setValue(java.lang.Object value)
Sets the referenced value.

Parameters:
value - The value

castTo

java.lang.Object castTo(java.lang.Class<?> type)
Gets the value after casting it to the specified type.

Parameters:
type - The target type
Returns:
An object instance of the specified type
Throws:
java.lang.ClassCastException - If the value cannot be correctly casted

getValueType

java.lang.Class<T> getValueType()
Gets a class instance representing the type of referenced values.

Returns:
A class instance

canCastTo

boolean canCastTo(java.lang.Class<?> type)
Gets if the value can be casted to the specified type.

This method is used by processes to validate input references.

Parameters:
type - The type to cast to
Returns:
true if it can

canCastFrom

boolean canCastFrom(java.lang.Class<?> type)
Gets if the value can be converted from the specified type.

This method is used by processes to validate output references.

Parameters:
type - The type to cast from
Returns:
true if it can

isAvailable

boolean isAvailable()
Gets if the reference is available for reading.

Returns:
true if it can be read

setAvailable

void setAvailable(boolean available)
Sets the available flag.

Parameters:
available - The new flag value

readLock

java.util.concurrent.locks.Lock readLock()
Gets a lock for reading.

Returns:
A lock instance

writeLock

java.util.concurrent.locks.Lock writeLock()
Gets a lock for writing.

Returns:
A lock instance

waitAvailable

void waitAvailable()
                   throws java.lang.InterruptedException
Waits until the reference is made available in another thread.

Throws:
java.lang.InterruptedException - If the thread is interrupted while waiting


Copyright © 2006-2008 Grid Systems, S.A.. All Rights Reserved.