/** * Through the method <code>registerLayer</code> you can add new layers to the platform. Here * we'll corroborate too that the layer is not added twice. * * @param abstractLayer layer instance. * @throws CantRegisterLayerException if something goes wrong. */ protected final void registerLayer(final AbstractLayer abstractLayer) throws CantRegisterLayerException { LayerReference layerReference = abstractLayer.getLayerReference(); layerReference.setPlatformReference(platformReference); try { if (layers.containsKey(layerReference)) throw new CantRegisterLayerException( "layer: " + layerReference.toString(), "Layer already exists in this platform."); abstractLayer.start(); layers.put(layerReference, abstractLayer); } catch (final CantStartLayerException e) { throw new CantRegisterLayerException( e, "layer: " + layerReference.toString(), "Error trying to start the layer."); } }
public final AbstractLayer getLayer(final LayerReference layerReference) throws LayerNotFoundException { if (layers.containsKey(layerReference)) return layers.get(layerReference); else throw new LayerNotFoundException("layer: " + layerReference.getLayer(), "layer not found."); }