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:
- You can set the MapHandler with the policy to let duplicate SoloMapComponents be added to the MapHandler. If a duplicate SoloMapComponent is added, then all objects using that type of SoloMapComponent should gracefully use the latest version added.
- The MapHandler can have to policy to limit the addition of duplicate SoloMapComponents. If a duplicate is added, and exception is thrown. In this case, the original SoloMapComponent must be removed from the MapHandler before the second instance is added.