Class FlyweightFactory


public class FlyweightFactory
extends Object
The Flyweight factory maintains a pool of instantiated flyweights. When the client requests a shareable flyweight, the factory first searches the pool to see if there is already one available. If it is, the factory simply returns that instance. Otherwise it instantiates a new flywieght, adds it to the pool and returns a reference to the client.


Variable Index

 o flyweightPool
A pool of instantiated shared flyweights

Method Index

 o makeFlyweight (Object)
Search the pool for a shared flyweight as per the given parameter

Variables

 o flyweightPool
private Vector flyweightPool
A pool of instantiated shared flyweights. These are the only instances needed for these specific flyweights.

Methods

 o makeFlyweight
public Flyweight makeFlyweight(Object parameter)
Search the pool for a shared flyweight as per the given parameter. Return either an existing instance or create a new one if there is none already.

Parameters:
parameter - Used to determine which concrete flyweight is needed.
Returns:
Either an existing or new concrete instance.