public class BasicFactory extends Object implements Factory
Factory
this
class instantiates the objects using the JDK standard ServiceLoader
. A single factory instance will maintain a single
instance of each class and subsequent call on the same factory object to the
method get(Class)
will return the same class instance for the same
interface.
The implementation also checks that the argument passed to the method is an interface and not a class.
Constructor and Description |
---|
BasicFactory() |
Modifier and Type | Method and Description |
---|---|
void |
clean()
Clean the factory.
|
<T extends FactoryManaged> |
get(Class<T> interfAce)
Get an instance of the interface.
|
public <T extends FactoryManaged> T get(Class<T> interfAce)
public void clean()
Factory
When the factory creates thread singletons (thread local instances) then this is important to call this method to release the objects before the thread finishes.
Copyright © 2013 Verhas and Verhas Software Craftsmen. All Rights Reserved.