1 package org.jacorb.poa; 2 3 22 23 import org.jacorb.poa.except.*; 24 25 import org.omg.PortableServer.CurrentPackage.NoContext ; 26 27 import java.util.*; 28 29 36 37 public class Current 38 extends org.omg.PortableServer._CurrentLocalBase 39 { 42 private Hashtable threadTable = new Hashtable(); 43 45 private Current() 46 { 47 } 48 49 public static Current _Current_init() 50 { 51 return new Current(); 52 } 53 54 public synchronized void _addContext(Thread t, InvocationContext c) 55 { 56 Vector cv = (Vector) threadTable.get(t); 57 58 if (cv == null) { 59 cv = new Vector(); 60 threadTable.put(t, cv); 61 } 62 63 cv.addElement(c); 64 } 65 66 public synchronized void _removeContext(Thread t) 67 { 68 Vector cv = (Vector) threadTable.get(t); 69 70 if (cv != null) { 71 72 cv.removeElementAt(cv.size()-1); 73 74 if (cv.size() == 0) { 75 threadTable.remove(t); 76 } 77 } 78 } 79 80 public byte[] get_object_id() 81 throws NoContext 82 { 83 return getInvocationContext().getObjectId(); 84 } 85 86 public org.omg.CORBA.Object get_reference () 87 throws NoContext 88 { 89 return get_servant()._this_object (getORB ()); 90 } 91 92 public org.omg.PortableServer.Servant get_servant () 93 throws NoContext 94 { 95 return getInvocationContext().getServant (); 96 } 97 98 public org.omg.PortableServer.POA get_POA () 99 throws NoContext 100 { 101 return getInvocationContext().getPOA (); 102 } 103 104 synchronized private InvocationContext getInvocationContext() 105 throws NoContext 106 { 107 Thread ct = Thread.currentThread(); 108 109 Vector cv = (Vector) threadTable.get(ct); 110 111 if (cv != null) 112 { 113 InvocationContext c = (InvocationContext) cv.lastElement(); 114 115 if (c != null) 116 { 117 return c; 118 } 119 } 120 121 throw new NoContext (); 122 } 123 124 protected org.omg.CORBA.ORB getORB() 125 throws NoContext 126 { 127 return getInvocationContext().getORB(); 128 } 129 130 protected org.omg.PortableServer.Servant getServant() 131 throws NoContext 132 { 133 return getInvocationContext().getServant(); 134 } 135 } 136 | Popular Tags |