|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nakedobjects.runtime.persistence.objectfactory.ObjectFactoryAbstract
public abstract class ObjectFactoryAbstract
Abstract adapter for ObjectFactory.
Implementation note: rather than use the *Aware interfaces, we
instead look up dependencies from the NakedObjectsContext. This is
necessary, for the PersistenceSession at least, because class
enhancers may hold a reference to the factory as part of the generated
bytecode. Since the PersistenceSession could change over the lifetime
of the instance (eg when using the InMemoryObjectStore), we must
always look the PersistenceSession from the
NakedObjectsContext. The same applies to the ServicesInjector.
In theory it would be possible to cache the SpecificationLoader and
inject using SpecificationLoaderAware, but since we are already using
the NakedObjectsContext, decided instead to use the same approach throughout.
| Nested Class Summary | |
|---|---|
static class |
ObjectFactoryAbstract.Mode
|
| Constructor Summary | |
|---|---|
ObjectFactoryAbstract()
|
|
ObjectFactoryAbstract(ObjectFactoryAbstract.Mode mode)
|
|
| Method Summary | ||
|---|---|---|
void |
close()
Default implementation does nothing. |
|
protected abstract
|
doInstantiate(java.lang.Class<T> cls)
Hook method for subclasses to override. |
|
protected PersistenceSession |
getPersistenceSession()
|
|
protected ServicesInjector |
getServicesInjector()
|
|
protected SpecificationLoader |
getSpecificationLoader()
|
|
|
instantiate(java.lang.Class<T> cls)
Should instantiate the object, and in addition initialize the domain object (for example, inject any services and repositories into it). |
|
void |
open()
Default implementation does nothing. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ObjectFactoryAbstract()
public ObjectFactoryAbstract(ObjectFactoryAbstract.Mode mode)
| Method Detail |
|---|
public <T> T instantiate(java.lang.Class<T> cls)
throws ObjectInstantiationException
ObjectFactory
instantiate in interface ObjectFactoryObjectInstantiationExceptionpublic void open()
open in interface SessionScopedComponentpublic void close()
close in interface SessionScopedComponent
protected abstract <T> T doInstantiate(java.lang.Class<T> cls)
throws ObjectInstantiationException
ObjectInstantiationExceptionprotected SpecificationLoader getSpecificationLoader()
protected PersistenceSession getPersistenceSession()
protected ServicesInjector getServicesInjector()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||