1 26 27 package org.objectweb.openccm.ir3; 28 29 38 39 public class IFR 40 { 41 47 48 protected java.util.Map tie2impl_; 49 50 51 protected org.omg.PortableServer.POA rootPOA_; 52 53 54 protected ComponentRepository_impl repository_; 55 56 62 65 public 66 IFR() 67 { 68 this(true); 69 } 70 71 77 public 78 IFR(boolean with_mapping) 79 { 80 tie2impl_ = new java.util.HashMap (); 82 83 rootPOA_ = org.objectweb.openccm.corba.TheRootPOA.getRootPOA(); 84 85 repository_ = new ComponentRepository_impl(this, with_mapping); 88 } 89 90 96 99 public ComponentRepository_impl 100 getRepository() 101 { 102 return repository_; 103 } 104 105 108 public org.omg.CORBA.ORB 109 getTCF() 110 { 111 return org.objectweb.openccm.corba.TheORB.getORB(); 112 } 113 114 117 public void 118 activate(org.omg.PortableServer.Servant servant, 119 IFRObject impl) 120 { 121 log(100,"activate " + servant.toString() + " for " + impl.toString()); 122 activateServant(servant); 123 tie2impl_.put(servant, impl); 124 } 125 126 129 public void 130 deactivate(org.omg.PortableServer.Servant servant) 131 { 132 log(100,"deactivate " + servant.toString()); 133 deactivateServant(servant); 134 tie2impl_.remove(servant); 135 } 136 137 140 public IFRObject 141 toImpl(org.omg.CORBA.Object object) 142 { 143 org.omg.PortableServer.Servant servant = toServant(object); 144 if (servant == null) 145 return null; 146 147 IFRObject impl = (IFRObject)tie2impl_.get(servant); 148 return impl; 149 } 150 151 154 public void 155 activateServant(org.omg.PortableServer.Servant servant) 156 { 157 try 158 { 159 byte[] oid = rootPOA_.activate_object(servant); 160 } 161 catch(Exception ex) 162 { 163 ex.printStackTrace(); 164 } 165 } 166 167 170 public void 171 deactivateServant(org.omg.PortableServer.Servant servant) 172 { 173 try 174 { 175 byte[] oid = rootPOA_.servant_to_id(servant); 176 rootPOA_.deactivate_object(oid); 177 } 178 catch(Exception ex) 179 { 180 ex.printStackTrace(); 181 } 182 } 183 184 187 public org.omg.PortableServer.Servant 188 toServant(org.omg.CORBA.Object object) 189 { 190 if(object != null) 191 { 192 try 193 { 194 return rootPOA_.reference_to_servant(object); 195 } 196 catch(Exception ex) 197 { 198 ex.printStackTrace(); 199 } 200 } 201 return null; 202 } 203 204 207 public void 208 log(int level, String message) 209 { 210 if(level < 10) 211 System.err.println("(Level=" + level + "): " + message); 212 } 213 } 214 | Popular Tags |