org.nakedobjects
Class Exploration

java.lang.Object
  extended byorg.nakedobjects.Application
      extended byorg.nakedobjects.Exploration
Direct Known Subclasses:
ExpensesExploration

public abstract class Exploration
extends Application

Template for creating a standalone application. To create a runnable application subclass this class and implement the classSet method listing therein the classes to be made available.

It is also possible to override the configurationFile, installObjectStore and installApplication methods, to change the configuration file, object store or viewing mechanism respectively. While it may occasionally be necessary to change the configuration file from its default, it is preferable to configure different object stores or viewing mechanism by changing the appropriate property within the configuration file.

See Also:
classSet(NakedClassList), configurationFile(), installObjectStore(), installApplication(NakedObjectStore)

Field Summary
static java.lang.String DEFAULT_CONFIG
           
static java.lang.String OBJECT_STORE
           
static java.lang.String VIEWING_MECHANISM
           
 
Constructor Summary
Exploration()
          invokes init method to perform the initialization.
 
Method Summary
protected  void addInstance(NakedObject object)
           
abstract  void classSet(NakedClassList classes)
          hook method which the subclass must implement to add any classes into the supplied NakedClassList
protected  java.lang.String configurationFile()
          hook method to return the name of the configuration file.
protected  NakedObject createInstance(java.lang.Class type)
          helper method to create an instance of the given type.
protected  NakedObject createInstance(java.lang.String typeName)
          helper method to create an instance of the given type.
protected  NakedObjectStore getObjectStore()
          returns the object store set up during initialization
protected  boolean hasNoInstances(java.lang.Class cls)
          convenience method provided for subclasses, indicating whether there are any instances of the specified class
protected  void init()
          Loads up a specified configuration file if there is one, else loads up the default config file if it exists.
protected  void initObjects()
          Hook method allowing subclass to initialize any objects.
protected  ObjectViewingMechanism installApplication(NakedObjectStore objectStore)
          Called by the init method, this is a hook method to return the viewing mechanism used to render the objects.
protected  NakedObjectStore installObjectStore()
          Called by the init method, this is a hook method to return the object store to be used to persist objects.
 
Methods inherited from class org.nakedobjects.Application
configureSystemLogging, hasProperty, loadConfiguration, set, setting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONFIG

public static final java.lang.String DEFAULT_CONFIG

OBJECT_STORE

public static final java.lang.String OBJECT_STORE
See Also:
Constant Field Values

VIEWING_MECHANISM

public static final java.lang.String VIEWING_MECHANISM
See Also:
Constant Field Values
Constructor Detail

Exploration

public Exploration()
invokes init method to perform the initialization.

See Also:
init()
Method Detail

classSet

public abstract void classSet(NakedClassList classes)
hook method which the subclass must implement to add any classes into the supplied NakedClassList

Parameters:
classes - - the list to which naked classes should be added.

getObjectStore

protected final NakedObjectStore getObjectStore()
returns the object store set up during initialization

See Also:
init()

configurationFile

protected java.lang.String configurationFile()
hook method to return the name of the configuration file. Called by init method.

The default implementation simply returns null, meaning that the default configuration file will be used.

See Also:
DEFAULT_CONFIG

createInstance

protected final NakedObject createInstance(java.lang.String typeName)
helper method to create an instance of the given type. Provided for subclasses that need to set up instances.

See Also:
initObjects()

createInstance

protected final NakedObject createInstance(java.lang.Class type)
helper method to create an instance of the given type. Provided for subclasses that need to set up instances.

See Also:
initObjects()

addInstance

protected void addInstance(NakedObject object)

hasNoInstances

protected final boolean hasNoInstances(java.lang.Class cls)
                                throws ObjectStoreException
convenience method provided for subclasses, indicating whether there are any instances of the specified class

Throws:
ObjectStoreException

init

protected final void init()
                   throws ConfigurationException,
                          ObjectStoreException
Loads up a specified configuration file if there is one, else loads up the default config file if it exists.

The configuration file to be loaded is determined by calling configurationFile method. If one is specified in this manner and it cannot be found an error will be given and the system will exit. Otherwise the default configuration file will be used.

The method then calls installObjectStore and installApplication to obtain the object store and viewing mechanisms respectively.

After the object store and viewing mechanisms have been initialized, the method calls the initObjects method. This is mostly a convenience during the Exploration phase, allowing commonly used test objects to be set up. Any such objects created are automatically made persistent.

Finally, the classSet method is called, so that the subclass can register the application's classes.

Any of these methods called can be overridden by subclasses as required.

Throws:
ConfigurationException
ObjectStoreException
See Also:
configurationFile(), DEFAULT_CONFIG, installObjectStore(), installApplication(NakedObjectStore), initObjects(), classSet(NakedClassList), NakedObjectStore.init()

initObjects

protected void initObjects()
                    throws ObjectStoreException
Hook method allowing subclass to initialize any objects. This is useful during the Exploration phase to set up any commonly used test phase (especially if the default TransientObjectStore is being returned by the installObjectStore method).

The default implementation of this method within this class does nothing.

Throws:
ObjectStoreException
See Also:
installObjectStore(), TransientObjectStore

installApplication

protected ObjectViewingMechanism installApplication(NakedObjectStore objectStore)
                                             throws ConfigurationException
Called by the init method, this is a hook method to return the viewing mechanism used to render the objects.

The default implementation checks for a nakedobjects.object-viewing-mechanism property (value of VIEWING_MECHANISM in the configuration file and uses the class specified there. If none is specified then it defaults to the GraphicalViewingMechanism class.

Throws:
ConfigurationException
See Also:
init(), VIEWING_MECHANISM, GraphicalViewingMechanism

installObjectStore

protected NakedObjectStore installObjectStore()
                                       throws ConfigurationException,
                                              ObjectStoreException
Called by the init method, this is a hook method to return the object store to be used to persist objects.

The default implementation checks for a nakedobjects.object-store property (value of OBJECT_STORE)in the configuration file and uses the class specified there. If none is specified then it defaults to the TransientObjectStore class, an object store implementation that provides no persistence between runs.

Throws:
ConfigurationException
ObjectStoreException
See Also:
init(), OBJECT_STORE, TransientObjectStore