|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
dsiutils
.
@Deprecated public interface FlyweightPrototype<T extends FlyweightPrototype<T>>
A prototype providing flyweight copies.
MG4J uses often flyweight copies to implement multithreading on read-only (but maybe stateful) classes. An instance of a class implementing this interface is not necessarily thread safe, but it can be (thread-) safely copied many times (i.e., it can be used as a prototype). All copies will share as much as possible of the class read-only state (so they are flyweight). This is the case, for instance, of term processors, document factories, document collections, and scorers.
In the case an implementation is stateless, it can of course return always the same singleton
instance as a copy. At the other extreme, a stateful class may decide to synchronise its
methods and return itself as a copy instead. Note that in general the object returned
by copy()
must replicate the current state of the object, not
the object state at creation time. This might require some calls to methods that
modify the class internal state: in particular, one should always check whether such
methods are pointed out in the documentation of superclasses.
Warning: if copy()
accesses mutable internal state, setters
and copy()
must be suitably synchronised.
Implementing subclasses are invited to use covariant return-type overriding to
make copy()
return the right type.
Method Summary | |
---|---|
T |
copy()
Deprecated. Returns a copy of this object, sharing state with this object as much as possible. |
Method Detail |
---|
T copy()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |