|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdk.rode.thesis.decorator.SequenceDecorator<E>
dk.rode.thesis.proxy.SynchronisedSequence<E>
E
- The type of generator delivered by this sequence.@ParticipantUsage(value="Subject", type=Sequence.class) @Participant(value="Proxy") public class SynchronisedSequence<E>
A synchronised sequence ensures thread-safe access to a
proxied sequence
if and only if the proxied
sequence is accessed through the proxy only. The lock used in the
proxied sequence instance.
A copy of a synchronised sequence will proxy the same original proxied object and use the same lock.
A synchronised sequence exhibit the same bounded
,
consistent
, and unique
properties as the proxied sequence.
Implementation notes:
A synchronised sequence corresponds to a smart reference as described
by Gamma et al. [Gamma95, p.209].
SequenceProxyFactory.getSynchronisedSequence(Sequence)
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
Sequence.State |
Field Summary | |
---|---|
private Object |
lock
The lock to synchronise on. |
Constructor Summary | |
---|---|
SynchronisedSequence(Sequence<E> sequence)
Constructor. |
|
SynchronisedSequence(Sequence<E> sequence,
Object lock)
Constructor. |
Method Summary | |
---|---|
SynchronisedSequence<E> |
copy()
Returns a copy of this sequence that will start at the same sequence index as this sequence. |
E |
current()
Returns the current element from this sequence. |
E |
next()
Returns the next element from this sequence. |
void |
reset()
Resets this sequence to start over if it is consistent. |
Methods inherited from class dk.rode.thesis.decorator.SequenceDecorator |
---|
bounded, consistent, equals, getSequence, getStringablePolicy, hashCode, state, toString, toString, unique |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
bounded, consistent, state, unique |
Methods inherited from interface dk.rode.thesis.strategy.Stringable |
---|
getStringablePolicy, toString |
Field Detail |
---|
private final Object lock
Constructor Detail |
---|
public SynchronisedSequence(@Participant(value="RealSubject") Sequence<E> sequence)
The lock used is sequence
.
sequence
- The sequence to proxy; cannot be null.
NullPointerException
- If sequence
is null.public SynchronisedSequence(@Participant(value="RealSubject") Sequence<E> sequence, Object lock)
sequence
- The sequence to proxy; cannot be null.lock
- The lock object to synchronise on; cannot be null.
NullPointerException
- If either argument is null.Method Detail |
---|
public SynchronisedSequence<E> copy()
Sequence
copy
in interface Sequence<E>
copy
in interface Copyable<Sequence<E>>
public E current()
Sequence
This method can be invoked even if Sequence.next()
has not been invoked yet, thus delivering the initial
value of this sequence.
current
in interface Sequence<E>
current
in class SequenceDecorator<E>
public E next()
Sequence
next
in interface Sequence<E>
next
in class SequenceDecorator<E>
Sequence.current()
,
Sequence.state()
public void reset()
Sequence
If this sequence is consistent
, the
sequence will restart.
reset
in interface Sequence<E>
reset
in class SequenceDecorator<E>
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |