1 19 package org.netbeans.api.registry.mergedctx; 20 21 import org.netbeans.api.registry.Context; 22 import org.netbeans.api.registry.ContextException; 23 import org.openide.filesystems.FileObject; 24 import org.openide.filesystems.Repository; 25 26 import java.util.ArrayList ; 27 28 public class SetUpUtils { 29 private static Context subctx1; 30 private static Context subctx2; 31 private static Context subctx3; 32 33 static Context getSimpleContext(Context originalCtx) { 34 System.gc(); 35 System.gc(); 36 System.gc(); 37 ArrayList l = new ArrayList (); 38 try { 39 subctx1 = originalCtx.createSubcontext("first"); 40 l.add(getSubctx1()); 41 subctx2 = originalCtx.createSubcontext("second"); 42 l.add (getSubctx2()); 43 subctx3 = originalCtx.createSubcontext("third"); 44 l.add (getSubctx3()); 45 46 Context[] retVal = new Context [l.size()]; 47 l.toArray(retVal); 48 Context mretVal = Context.merge(retVal); 49 return mretVal; 50 } catch (ContextException e) { 51 throw new UnknownError (); 52 } 53 } 54 55 static FileObject getSimpleRoot () { 56 return Repository.getDefault ().getDefaultFileSystem ().findResource("first"); 57 } 58 59 static FileObject findSimpleResource (String resource) { 60 if (resource.startsWith("/")) 61 resource = resource.substring(1); 62 return Repository.getDefault ().getDefaultFileSystem ().findResource("first/"+resource); 63 } 64 65 static Context getSubctx1() { 66 return subctx1; 67 } 68 69 static Context getSubctx2() { 70 return subctx2; 71 } 72 73 static Context getSubctx3() { 74 return subctx3; 75 } 76 } 77 | Popular Tags |