1 package org.jacorb.test.common; 2 3 22 23 import java.util.*; 24 import junit.framework.*; 25 import junit.extensions.TestSetup; 26 import org.omg.CORBA.ORB ; 27 28 32 33 public class ORBSetup extends TestSetup 34 { 35 private static ORB orb = null; 36 private static int count = 0; 37 38 public ORBSetup (Test test) 39 { 40 super (test); 41 } 42 43 public void setUp () 44 { 45 init (this); 46 } 47 48 public void tearDown () 49 { 50 destroy (); 51 } 52 53 public static ORB getORB () 54 { 55 return orb; 56 } 57 58 private static synchronized void init (ORBSetup obj) 59 { 60 if (count == 0) 61 { 62 String [] args = new String [0];; 63 Properties props = new Properties (); 64 65 props.setProperty 66 ("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB"); 67 props.setProperty 68 ("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton"); 69 70 orb = ORB.init (args, props); 71 } 72 count++; 73 } 74 75 private static synchronized void destroy () 76 { 77 if (count == 1) 78 { 79 orb = null; 80 } 81 count--; 82 } 83 } 84 | Popular Tags |