KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > core > testutils > RepositoryImpl


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 package org.netbeans.modules.websvc.core.testutils;
21
22 import java.io.File JavaDoc;
23 import java.net.URL JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26 import org.openide.filesystems.FileSystem;
27 import org.openide.filesystems.LocalFileSystem;
28 import org.openide.filesystems.MultiFileSystem;
29 import org.openide.filesystems.Repository;
30 import org.openide.filesystems.XMLFileSystem;
31 import org.xml.sax.SAXException JavaDoc;
32
33 /**
34  *
35  * @author Lukas Jungmann
36  */

37 public class RepositoryImpl extends Repository {
38     
39     /** Creates a new instance of RepositotyImpl */
40     public RepositoryImpl() throws Exception JavaDoc {
41         super(mksystem());
42     }
43     
44     private static FileSystem mksystem() throws Exception JavaDoc {
45         LocalFileSystem lfs = new LocalFileSystem();
46         File JavaDoc systemDir = new File JavaDoc(System.getProperty("websvc.core.test.repo.root"));
47         systemDir.mkdirs();
48         lfs.setRootDirectory(systemDir);
49         lfs.setReadOnly(false);
50         List JavaDoc<FileSystem> layers = new ArrayList JavaDoc<FileSystem>();
51         layers.add(lfs);
52         // get layer for the TestServer
53
//addLayer(layers, "org/netbeans/modules/j2ee/test/testserver/resources/layer.xml");
54
// get layer for project types
55
// addLayer(layers, "org/netbeans/modules/web/project/ui/resources/layer.xml");
56
// addLayer(layers, "org/netbeans/modules/j2ee/ejbjarproject/ui/resources/layer.xml");
57
addLayer(layers, "org/netbeans/modules/java/j2seproject/ui/resources/layer.xml");
58 // addLayer(layers, "org/netbeans/modules/j2ee/clientproject/ui/resources/layer.xml");
59
// get layer for the websvc/core
60
addLayer(layers, "org/netbeans/modules/websvc/core/resources/mf-layer.xml");
61         // get layer for the java support (for Main class template)
62
// addLayer(layers, "org/netbeans/modules/java/resources/mf-layer.xml");
63
MultiFileSystem mfs = new MultiFileSystem((FileSystem[]) layers.toArray(new FileSystem[layers.size()]));
64         return mfs;
65     }
66     
67     private static void addLayer(List JavaDoc<FileSystem> layers, String JavaDoc layerRes) throws SAXException JavaDoc {
68         URL JavaDoc layerFile = RepositoryImpl.class.getClassLoader().getResource(layerRes);
69         assert layerFile != null;
70         layers.add(new XMLFileSystem(layerFile));
71     }
72     
73 }
74
Popular Tags