Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java	(revision 29921)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java	(revision 29922)
@@ -146,5 +146,5 @@
             fis = new FileInputStream(file);
             ois = new ObjectInputStream(fis);
-            successfulRead = wmsLayer.read(ois, currentLambertZone);
+            successfulRead = wmsLayer.read(file, ois, currentLambertZone);
         } catch (Exception ex) {
             ex.printStackTrace(System.out);
@@ -195,5 +195,5 @@
                         ObjectOutputStream oos = new ObjectOutputStream(
                                 new BufferedOutputStream(new FileOutputStream(file)));
-                        wmsLayer.write(oos);
+                        wmsLayer.write(file, oos);
                         for (int i=0; i < size; i++) {
                             oos.writeObject(imagesToSave.get(i));
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 29921)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 29922)
@@ -5,4 +5,6 @@
 import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.io.session.SessionWriter.registerSessionLayerExporter;
+import static org.openstreetmap.josm.io.session.SessionReader.registerSessionLayerImporter;
 
 import java.awt.event.ActionEvent;
@@ -138,5 +140,6 @@
  *                 - workaround on address help tool when switching to full screen
  *                 - improvement when clicking on existing node address street in mode relation
- *                 - option to simplify raster images in 2 bits colors (like images served in the past).                   
+ *                 - option to simplify raster images in 2 bits colors (like images served in the past).
+ * 2.6 10-Sep-2013 - add JOSM "sessions" feature support (list of layers stored in a file)                   
  */
 public class CadastrePlugin extends Plugin {
@@ -208,4 +211,7 @@
 
         UploadAction.registerUploadHook(new CheckSourceUploadHook());
+        
+        registerSessionLayerExporter(WMSLayer.class , CadastreSessionExporter.class);
+        registerSessionLayerImporter("cadastre-fr", CadastreSessionImporter.class);
 
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionExporter.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionExporter.java	(revision 29922)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionExporter.java	(revision 29922)
@@ -0,0 +1,80 @@
+package cadastre_fr;
+
+import java.awt.Component;
+import java.awt.GridBagLayout;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+
+import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.io.session.SessionLayerExporter;
+import org.openstreetmap.josm.io.session.SessionWriter.ExportSupport;
+import org.openstreetmap.josm.tools.GBC;
+import org.w3c.dom.Element;
+
+public class CadastreSessionExporter implements SessionLayerExporter {
+
+    private WMSLayer layer;
+    private JCheckBox export;
+
+    public CadastreSessionExporter(WMSLayer layer) {
+        this.layer = layer;
+    }
+
+	@Override
+	public Collection<Layer> getDependencies() {
+        return Collections.emptySet();
+	}
+
+	@Override
+	public Component getExportPanel() {
+        final JPanel p = new JPanel(new GridBagLayout());
+        export = new JCheckBox();
+        export.setSelected(true);
+        final JLabel lbl = new JLabel(layer.getName(), layer.getIcon(), SwingConstants.LEFT);
+        lbl.setToolTipText(layer.getToolTipText());
+        p.add(export, GBC.std());
+        p.add(lbl, GBC.std());
+        p.add(GBC.glue(1,0), GBC.std().fill(GBC.HORIZONTAL));
+        return p;
+	}
+
+	@Override
+	public boolean shallExport() {
+        return export.isSelected();
+	}
+
+	@Override
+	public boolean requiresZip() {
+		return false;
+	}
+
+	@Override
+	public Element export(ExportSupport support) throws IOException {
+        Element layerEl = support.createElement("layer");
+        layerEl.setAttribute("type", "cadastre-fr");
+        layerEl.setAttribute("version", "0.1");
+
+        Element file = support.createElement("file");
+        layerEl.appendChild(file);
+
+        URI uri = layer.getAssociatedFile().toURI();
+        URL url = null;
+        try {
+            url = uri.toURL();
+        } catch (MalformedURLException e) {
+            throw new IOException(e);
+        }
+        file.appendChild(support.createTextNode(url.toString()));
+        return layerEl;
+	}
+
+}
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionImporter.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionImporter.java	(revision 29922)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionImporter.java	(revision 29922)
@@ -0,0 +1,70 @@
+package cadastre_fr;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.progress.ProgressMonitor;
+import org.openstreetmap.josm.io.GpxImporter;
+import org.openstreetmap.josm.io.IllegalDataException;
+import org.openstreetmap.josm.io.session.SessionLayerImporter;
+import org.openstreetmap.josm.io.session.SessionReader.ImportSupport;
+import org.w3c.dom.Element;
+
+public class CadastreSessionImporter implements SessionLayerImporter{
+
+	@Override
+	public Layer load(Element elem, ImportSupport support,
+			ProgressMonitor progressMonitor) throws IOException,
+			IllegalDataException {
+        String version = elem.getAttribute("version");
+        if (!"0.1".equals(version)) {
+            throw new IllegalDataException(tr("Version ''{0}'' of meta data for imagery layer is not supported. Expected: 0.1", version));
+        }
+        try {
+            XPathFactory xPathFactory = XPathFactory.newInstance();
+            XPath xpath = xPathFactory.newXPath();
+            XPathExpression fileExp = xpath.compile("file/text()");
+            String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING);
+            if (fileStr == null || fileStr.isEmpty()) {
+                throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex()));
+            }
+
+            fileStr = URLDecoder.decode(fileStr, "UTF-8");
+            fileStr = fileStr.substring(fileStr.indexOf(":/")+2);
+    		String filename = fileStr.substring(fileStr.lastIndexOf("/")+1,fileStr.length());
+            String ext = (filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length());
+            // create layer and load cache
+            if (ext.length() == 3 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z))
+                ext = ext.substring(2);
+            else if (ext.length() == 4 && ext.substring(0, CacheControl.cUTM20N.length()).equals(CacheControl.cUTM20N))
+                ext = ext.substring(3);
+            else if (ext.length() == 2 || ext.length() > 4)
+                throw new IllegalDataException(tr("Unexpected file extension. {0}", ext));
+
+            int layoutZone = Integer.parseInt(ext)-1;
+            WMSLayer wmsLayer = new WMSLayer("", "", layoutZone);
+            File file = new File(fileStr);
+            wmsLayer.grabThread.getCacheControl().loadCache(file, layoutZone);
+            return wmsLayer;
+
+        } catch (XPathExpressionException e) {
+            throw new RuntimeException(e);
+        }
+	}
+
+}
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 29921)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 29922)
@@ -15,4 +15,5 @@
 import java.awt.image.ImageObserver;
 import java.io.EOFException;
+import java.io.File;
 import java.io.IOException;
 import java.io.ObjectInputStream;
@@ -131,5 +132,6 @@
     public void destroy() {
         // if the layer is currently saving the images in the cache, wait until it's finished
-        grabThread.cancel();
+        if(grabThread != null)
+        		grabThread.cancel();
         grabThread = null;
         super.destroy();
@@ -439,6 +441,7 @@
      * @throws IOException
      */
-    public void write(ObjectOutputStream oos) throws IOException {
+    public void write(File associatedFile, ObjectOutputStream oos) throws IOException {
         currentFormat = this.serializeFormatVersion;
+        setAssociatedFile(associatedFile);
         oos.writeInt(this.serializeFormatVersion);
         oos.writeObject(this.location);    // String
@@ -467,5 +470,5 @@
      * @throws ClassNotFoundException
      */
-    public boolean read(ObjectInputStream ois, int currentLambertZone) throws IOException, ClassNotFoundException {
+    public boolean read(File associatedFile, ObjectInputStream ois, int currentLambertZone) throws IOException, ClassNotFoundException {
         currentFormat = ois.readInt();;
         if (currentFormat < 2) {
@@ -478,4 +481,5 @@
         this.lambertZone = ois.readInt();
         this.setRaster(ois.readBoolean());
+        setAssociatedFile(associatedFile);
         if (currentFormat >= 4)
             ois.readBoolean();
