org.puremvc.java.multicore.core.model
Class Model

java.lang.Object
  extended by org.puremvc.java.multicore.core.model.Model
All Implemented Interfaces:
IModel

public class Model
extends Object
implements IModel

A Multiton IModel implementation.

In PureMVC, the Model class provides access to model objects (Proxies) by named lookup.

The Model assumes these responsibilities:

Your application must register IProxy instances with the Model. Typically, you use an ICommand to create and register IProxy instances once the Facade has initialized the Core actors.

See Also:
Proxy, IProxy

Field Summary
protected static Model instance
          Singleton instance.
protected static Map<String,Model> instanceMap
           
protected  String multitonKey
          The Multiton Key for this Core.
protected  Map<String,IProxy> proxyMap
          Mapping of proxyNames to IProxy instances.
 
Constructor Summary
protected Model(String key)
          Constructor.
 
Method Summary
static Model getInstance(String key)
          Model Multiton Factory method.
 boolean hasProxy(String proxyName)
          Check if a Proxy is registered
protected  void initializeModel()
          Initialize the Singleton Model instance.
 void registerProxy(IProxy proxy)
          Register an Proxy with the Model.
static void removeModel(String key)
          Remove an IModel instance
 IProxy removeProxy(String proxy)
          Remove an Proxy from the Model.
 IProxy retrieveProxy(String proxy)
          Retrieve an Proxy from the Model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

protected static Model instance
Singleton instance.


proxyMap

protected Map<String,IProxy> proxyMap
Mapping of proxyNames to IProxy instances.


multitonKey

protected String multitonKey
The Multiton Key for this Core.


instanceMap

protected static Map<String,Model> instanceMap
Constructor Detail

Model

protected Model(String key)
Constructor.

This IModel implementation is a Multiton so you should not call the constructor directly, but instead call the static Multiton Factory method Model.getInstance( multitonKey )

Throws:
Error - Error if instance for this Multiton key instance has already been constructed
Method Detail

initializeModel

protected void initializeModel()
Initialize the Singleton Model instance.

Called automatically by the constructor, this is your opportunity to initialize the Singleton instance in your subclass without overriding the constructor.


getInstance

public static Model getInstance(String key)
Model Multiton Factory method.

Returns:
the instance for this Multiton key

registerProxy

public void registerProxy(IProxy proxy)
Register an Proxy with the Model.

Specified by:
registerProxy in interface IModel
Parameters:
proxy - an Proxy to be held by the Model.

removeProxy

public IProxy removeProxy(String proxy)
Remove an Proxy from the Model.

Specified by:
removeProxy in interface IModel
Parameters:
proxy - name of the Proxy instance to be removed.

retrieveProxy

public IProxy retrieveProxy(String proxy)
Retrieve an Proxy from the Model.

Specified by:
retrieveProxy in interface IModel
Parameters:
proxy -
Returns:
the Proxy instance previously registered with the given proxyName.

removeModel

public static void removeModel(String key)
Remove an IModel instance

Parameters:
multitonKey - of IModel instance to remove

hasProxy

public boolean hasProxy(String proxyName)
Check if a Proxy is registered

Specified by:
hasProxy in interface IModel
Parameters:
proxyName -
Returns:
whether a Proxy is currently registered with the given proxyName.


Copyright © 2010. All Rights Reserved.