KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > masterfs > providers > MountSupport


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.modules.masterfs.providers;
22
23 import java.io.IOException JavaDoc;
24 import org.openide.filesystems.FileSystem;
25
26 /**
27  * Enables to mount and unmount filesystems.
28  * The only way, how to get instance of MountSupport is to implement
29  * org.netbeans.modules.masterfs.providers.FileSystemProvider#initialize
30  * and keep passed instance of MountSupport. So, there is important to know, that
31  * only filesystems, that have registered implementation of FileSystemProvider can
32  * be mounted. There is obvious, that only already mounted filesystems can be unmounted.
33  *
34  * @see org.netbeans.modules.masterfs.providers.FileSystemProvider#initialize
35  * @author rm111737
36  */

37 final public class MountSupport {
38     /**
39      * Mounts a file system on mount point defined by parameter mountPoint.
40      * Once mounted filesystem must be first unmounted, before other filesystem can
41      * be mounted on the same mountPoint.
42      *
43      * @param mountPoint corresponds to java.io.File.getAbstractPath.
44      * But be aware, that this doesn't mean, that such file must really exist.
45      * MountPoint may also address virtual location.
46      * @param fs filesystem that should be mounted. FileObject hierarchy within a delegate FileSystem
47      * must precisely match the File hierarchy and must not hide any files which exist on disk.
48      * @throws java.io.IOException when mount fails e.g.: there already exists mounted filesystem
49      * assigned to passed mount point.
50      */

51     public void mount(String JavaDoc mountPoint, FileSystem fs) throws IOException JavaDoc {
52         delegate.mount (mountPoint, fs);
53     }
54
55     /**
56      * Unmounts already mounted filesystem.
57      * @param fs filesystem, taht should be unmounted
58      * @throws java.io.IOException when unmount fails e.g.: passed fs hasn't
59      * been mounted yet.
60      */

61     public void unmount(FileSystem fs) throws IOException JavaDoc {
62         delegate.unmount (fs);
63     }
64
65     /**
66      * Private constructor.
67      * @see org.netbeans.modules.masterfs.providers.FileSystemProvider#initialize
68      */

69     private MountSupport (org.netbeans.modules.masterfs.InternalMountSupport delegate) {
70         this.delegate = delegate;
71     }
72     
73
74     private static final class APIAccessImpl extends org.netbeans.modules.masterfs.APIAccess {
75         public MountSupport createMountSupport(org.netbeans.modules.masterfs.InternalMountSupport sup) {
76             return new MountSupport (sup);
77         }
78     }
79
80     static {
81         org.netbeans.modules.masterfs.APIAccess.DEFAULT = new APIAccessImpl ();
82     }
83
84     private org.netbeans.modules.masterfs.InternalMountSupport delegate;
85
86 }
87
Popular Tags