com.bbn.openmap
Class MapHandler

java.lang.Object
  extended by java.beans.beancontext.BeanContextChildSupport
      extended by java.beans.beancontext.BeanContextSupport
          extended by java.beans.beancontext.BeanContextServicesSupport
              extended by com.bbn.openmap.MapHandler
All Implemented Interfaces:
java.beans.beancontext.BeanContext, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextServiceRevokedListener, java.beans.beancontext.BeanContextServices, java.beans.beancontext.BeanContextServicesListener, java.beans.DesignMode, java.beans.PropertyChangeListener, java.beans.VetoableChangeListener, java.beans.Visibility, java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.EventListener

public class MapHandler
extends java.beans.beancontext.BeanContextServicesSupport

The MapHandler is an extension of the BeanContextServicesSupport, with the added capability of being able to set the policy on handling SoloMapComponents. The MapHandler can be thought of as a generic map container, that contains the MapBean, all the layers that may be part of the map, and all the gesture handling components for that map. Given that definition, there are some OpenMap components that need to have a one-to-one relationship with a MapHandler. For instance, a MapHandler should only contain one MapBean, LayerHandler, MouseDelegator and PropertyHandler. Objects that have this one-to-one relationship with the MapHandler should implement the SoloMapComponent interface, so the MapHandler can control what happens when more than one instance of a particular SoloMapComponent type is added to the MapBean. Other objects that get added to the MapHandler that hook up with SoloMapComponents should expect that only one version of those components should be used - if another instance gets added to the MapHandler, the objects should disconnect from the SoloMapComponent that they are using, and connect to the new object added. With this behavior, these objects can gracefully adapt to the SoloMapComponent policies that are set in the MapHandler:

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.beans.beancontext.BeanContextServicesSupport
java.beans.beancontext.BeanContextServicesSupport.BCSSChild, java.beans.beancontext.BeanContextServicesSupport.BCSSProxyServiceProvider, java.beans.beancontext.BeanContextServicesSupport.BCSSServiceProvider
 
Nested classes/interfaces inherited from class java.beans.beancontext.BeanContextSupport
java.beans.beancontext.BeanContextSupport.BCSChild, java.beans.beancontext.BeanContextSupport.BCSIterator
 
Field Summary
protected  boolean addInProgress
           
protected  java.util.List<java.lang.Object> addLaterVector
           
protected  boolean DEBUG
           
static java.util.logging.Logger logger
           
protected  SoloMapComponentPolicy policy
           
 
Fields inherited from class java.beans.beancontext.BeanContextServicesSupport
bcsListeners, proxy, serializable, services
 
Fields inherited from class java.beans.beancontext.BeanContextSupport
bcmListeners, children, designTime, locale, okToUseGui
 
Fields inherited from class java.beans.beancontext.BeanContextChildSupport
beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport
 
Fields inherited from interface java.beans.beancontext.BeanContext
globalHierarchyLock
 
Fields inherited from interface java.beans.DesignMode
PROPERTYNAME
 
Constructor Summary
MapHandler()
           
 
Method Summary
 boolean add(java.lang.Object obj)
          Add an object to the MapHandler BeanContextSupport.
protected  void addLater(java.lang.Object obj)
          Call made from the add() method for objects that added when another object was being added, setting up a ConcurrentModificationException condition.
 void dispose()
          Calls dispose() on the contained MapBean and removes all objects from BeanContext.
<T> T
get(java.lang.Class<T> someClass)
          Given a Class, find the object in the MapHandler.
 java.lang.Object get(java.lang.String classname)
          Given a class name, find the object in the MapHandler.
<T> java.util.Collection<T>
getAll(java.lang.Class<T> someClass)
          Given a Class, find all the objects in the MapHandler that are assignment-compatible with that Class.
 java.util.Collection getAll(java.lang.String classname)
          Given a Class name, find all the objects in the MapHandler that are assignment-compatible object of that Class.
 SoloMapComponentPolicy getPolicy()
          Get the policy that sets the behavior of the MapHandler when it encounters the situation of multiple instances of a particular SoloMapComponent.
protected  boolean isAddInProgress()
           
 java.util.Iterator iterator()
          Create an iterator copy, to avoid ConcurrentModificationExceptions in the MapHandler if one of the components wants to add more components when the MapHandler is set as the BeanContext on them.
 void present(java.lang.Object obj)
          Method to call with an object you don't want to add to this MapHandler, but you want to make it available to all the MapHandlerChildren in it.
protected  void purgeLaterList()
          Call to add any objects on the addLaterVector to the MapHandler.
 boolean remove(java.lang.Object obj)
          Added because apparently, the BeanContext doesn't check to see if the object is also a membership listener to remove it from that list.
protected  void setAddInProgress(boolean value)
           
 void setPolicy(SoloMapComponentPolicy smcp)
          Set the policy of behavior for the MapHandler on how it should act when multiple instances of a certain SoloMapComponents are added to it.
 java.lang.String toString()
           
 
Methods inherited from class java.beans.beancontext.BeanContextServicesSupport
addBeanContextServicesListener, addService, addService, bcsPreDeserializationHook, bcsPreSerializationHook, childJustRemovedHook, createBCSChild, createBCSSServiceProvider, fireServiceAdded, fireServiceAdded, fireServiceRevoked, fireServiceRevoked, getBeanContextServicesPeer, getChildBeanContextServicesListener, getCurrentServiceClasses, getCurrentServiceSelectors, getService, hasService, initialize, initializeBeanContextResources, releaseBeanContextResources, releaseService, removeBeanContextServicesListener, revokeService, serviceAvailable, serviceRevoked
 
Methods inherited from class java.beans.beancontext.BeanContextSupport
addAll, addBeanContextMembershipListener, avoidingGui, bcsChildren, childDeserializedHook, childJustAddedHook, classEquals, clear, contains, containsAll, containsKey, copyChildren, deserialize, dontUseGui, fireChildrenAdded, fireChildrenRemoved, getBeanContextPeer, getChildBeanContextChild, getChildBeanContextMembershipListener, getChildPropertyChangeListener, getChildSerializable, getChildVetoableChangeListener, getChildVisibility, getLocale, getResource, getResourceAsStream, instantiateChild, isDesignTime, isEmpty, isSerializing, needsGui, okToUseGui, propertyChange, readChildren, remove, removeAll, removeBeanContextMembershipListener, retainAll, serialize, setDesignTime, setLocale, size, toArray, toArray, validatePendingAdd, validatePendingRemove, vetoableChange, writeChildren
 
Methods inherited from class java.beans.beancontext.BeanContextChildSupport
addPropertyChangeListener, addVetoableChangeListener, firePropertyChange, fireVetoableChange, getBeanContext, getBeanContextChildPeer, isDelegated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, validatePendingSetBeanContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.beans.beancontext.BeanContext
addBeanContextMembershipListener, getResource, getResourceAsStream, instantiateChild, removeBeanContextMembershipListener
 
Methods inherited from interface java.beans.beancontext.BeanContextChild
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.beans.DesignMode
isDesignTime, setDesignTime
 
Methods inherited from interface java.beans.Visibility
avoidingGui, dontUseGui, needsGui, okToUseGui
 

Field Detail

logger

public static java.util.logging.Logger logger

policy

protected SoloMapComponentPolicy policy

DEBUG

protected boolean DEBUG

addInProgress

protected boolean addInProgress

addLaterVector

protected java.util.List<java.lang.Object> addLaterVector
Constructor Detail

MapHandler

public MapHandler()
Method Detail

setPolicy

public void setPolicy(SoloMapComponentPolicy smcp)
Set the policy of behavior for the MapHandler on how it should act when multiple instances of a certain SoloMapComponents are added to it.

See Also:
SoloMapComponentReplacePolicy, SoloMapComponentRejectPolicy

getPolicy

public SoloMapComponentPolicy getPolicy()
Get the policy that sets the behavior of the MapHandler when it encounters the situation of multiple instances of a particular SoloMapComponent.


setAddInProgress

protected void setAddInProgress(boolean value)

isAddInProgress

protected boolean isAddInProgress()

addLater

protected void addLater(java.lang.Object obj)
Call made from the add() method for objects that added when another object was being added, setting up a ConcurrentModificationException condition. This is a coping mechanism.


purgeLaterList

protected void purgeLaterList()
Call to add any objects on the addLaterVector to the MapHandler. These are objects that were previously added which another object was being added, setting up a ConcurrentModificationException condition. Part of the coping mechanism.


add

public boolean add(java.lang.Object obj)
Add an object to the MapHandler BeanContextSupport. Uses the current SoloMapComponentPolicy to handle the SoloMapComponents added. May throw MultipleSoloMapComponentException if the policy is a SoloMapComponentRejectPolicy and the SoloMapComponent is a duplicate type of another component already added.

Specified by:
add in interface java.util.Collection
Overrides:
add in class java.beans.beancontext.BeanContextSupport
Parameters:
obj - the map component to nest within this BeanContext.
Returns:
true if addition is successful, false if not.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

get

public java.lang.Object get(java.lang.String classname)
Given a class name, find the object in the MapHandler. If the class is not a SoloMapComponent and there are more than one of them in the MapHandler, you will get the first one found.


get

public <T> T get(java.lang.Class<T> someClass)
Given a Class, find the object in the MapHandler. If the class is not a SoloMapComponent and there are more than one of them in the MapHandler, you will get the first one found.


getAll

public java.util.Collection getAll(java.lang.String classname)
Given a Class name, find all the objects in the MapHandler that are assignment-compatible object of that Class. A Collection is always returned, although it may be empty.


getAll

public <T> java.util.Collection<T> getAll(java.lang.Class<T> someClass)
Given a Class, find all the objects in the MapHandler that are assignment-compatible with that Class. A Collection is always returned, although it may be empty.


remove

public boolean remove(java.lang.Object obj)
Added because apparently, the BeanContext doesn't check to see if the object is also a membership listener to remove it from that list. This method removes the object from that list, too, if it is a BeanContextMembershipListener.

Specified by:
remove in interface java.util.Collection
Overrides:
remove in class java.beans.beancontext.BeanContextSupport

present

public void present(java.lang.Object obj)
Method to call with an object you don't want to add to this MapHandler, but you want to make it available to all the MapHandlerChildren in it.

Parameters:
obj -

iterator

public java.util.Iterator iterator()
Create an iterator copy, to avoid ConcurrentModificationExceptions in the MapHandler if one of the components wants to add more components when the MapHandler is set as the BeanContext on them.

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Overrides:
iterator in class java.beans.beancontext.BeanContextSupport

dispose

public void dispose()
Calls dispose() on the contained MapBean and removes all objects from BeanContext.



Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details