1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 abstract public class KeylessCCMHomeBase 38 extends org.omg.CORBA.LocalObject 39 implements org.omg.Components.KeylessCCMHomeOperations, 40 org.omg.Components.CCMHomeOperations, 41 org.omg.Components.HomeExecutor, 42 java.io.Serializable 43 { 44 static private String _class_name = "KeylessCCMHomeBase"; 46 private org.omg.Components.CCM2Context _context; 47 private org.omg.Components.Session2Context _mono_ctx; 48 private org.omg.Components.SegmentedSession2Context _segmented_ctx; 49 private java.util.ArrayList _component_refs; 50 51 protected 53 KeylessCCMHomeBase() 54 { 55 _context = null; 57 _mono_ctx = null; 58 _segmented_ctx = null; 59 _component_refs = new java.util.ArrayList (); 60 } 61 62 66 abstract protected String 67 getComponentRepid(); 68 69 protected org.omg.Components.SegmentDescr[] 71 getSegmentDescrs() 72 { 73 final String opname = "getSegmentDescrs"; 74 final String msg = "FAILED (op not impl, rethrown)"; 75 TheLogger.log(_class_name, opname, msg); 76 77 throw new org.omg.CORBA.NO_IMPLEMENT (); 78 } 79 80 84 final protected org.omg.Components.CCM2Context 85 getCCM2Context() 86 { 87 return _context; 88 } 89 90 final protected org.omg.Components.Session2Context 91 getSession2Context() 92 { 93 return _mono_ctx; 94 } 95 96 final protected org.omg.Components.SegmentedSession2Context 97 getSegSession2Context() 98 { 99 return _segmented_ctx; 100 } 101 102 106 final public void 107 set_ccm_context(org.omg.Components.CCM2Context ctx) 108 { 109 _context = ctx; 110 111 if (ctx instanceof org.omg.Components.Session2Context) { 112 _mono_ctx = (org.omg.Components.Session2Context)ctx; 113 } else if (ctx instanceof org.omg.Components.SegmentedSession2Context) { 114 _segmented_ctx = (org.omg.Components.SegmentedSession2Context)ctx; 115 } else { 116 final String opname = "set_ccm_context"; 118 final String msg = "FAILED (unsupported context: "+ctx.getClass()+")"; 119 TheLogger.error(_class_name, opname, msg); 120 } 121 122 String tid = null; 124 org.omg.CORBA.portable.ValueFactory vfact = null; 125 tid = org.omg.Components.ConnectionDescriptionHelper.id(); 127 vfact = new ConnectionDescriptionFactoryImpl(); 128 _context.register_valuefactory(tid, vfact); 129 130 tid = org.omg.Components.EmitterDescriptionHelper.id(); 132 vfact = new EmitterDescriptionFactoryImpl(); 133 _context.register_valuefactory(tid, vfact); 134 135 tid = org.omg.Components.FacetDescriptionHelper.id(); 137 vfact = new FacetDescriptionFactoryImpl(); 138 _context.register_valuefactory(tid, vfact); 139 140 tid = org.omg.Components.PublisherDescriptionHelper.id(); 142 vfact = new PublisherDescriptionFactoryImpl(); 143 _context.register_valuefactory(tid, vfact); 144 145 tid = org.omg.Components.ReceptacleDescriptionHelper.id(); 147 vfact = new ReceptacleDescriptionFactoryImpl(); 148 _context.register_valuefactory(tid, vfact); 149 150 tid = org.omg.Components.SubscriberDescriptionHelper.id(); 152 vfact = new SubscriberDescriptionFactoryImpl(); 153 _context.register_valuefactory(tid, vfact); 154 } 155 156 public org.omg.Components.ExecutorSegmentBase 158 create_component_segment(short sid) 159 { 160 final String opname = "create_component_segment"; 161 final String msg = "FAILED (op not impl, rethrown)"; 162 TheLogger.log(_class_name, opname, msg); 163 164 throw new org.omg.CORBA.NO_IMPLEMENT (); 165 } 166 167 171 final public org.omg.CORBA.IRObject 172 get_component_def() 173 { 174 final String opname = "get_component_def"; 175 final String msg = "FAILED (op not impl, rethrown)"; 176 TheLogger.log(_class_name, opname, msg); 177 178 throw new org.omg.CORBA.NO_IMPLEMENT (); 179 } 180 181 final public org.omg.CORBA.IRObject 182 get_home_def() 183 { 184 final String opname = "get_home_def"; 185 final String msg = "FAILED (op not impl, rethrown)"; 186 TheLogger.log(_class_name, opname, msg); 187 188 throw new org.omg.CORBA.NO_IMPLEMENT (); 189 } 190 191 final public void 192 remove_component(org.omg.Components.CCMObject comp) 193 throws org.omg.Components.RemoveFailure 194 { 195 org.omg.CORBA.Object [] refs = (org.omg.CORBA.Object [])_component_refs.toArray(new org.omg.CORBA.Object [0]); 197 for (int i=0;i<refs.length;i++) { 198 if (refs[i]._is_equivalent(comp)) { 199 _component_refs.remove(i); 201 202 comp.remove(); 204 205 getCCM2Context().remove_component(comp); 207 208 return ; 209 } 210 } 211 212 final String opname = "remove_component"; 214 TheLogger.debug(_class_name, opname, "FAILED (reference not found)"); 215 throw new org.omg.CORBA.BAD_PARAM (); 216 } 217 218 final public void 219 remove_home() 220 throws org.omg.Components.RemoveFailure 221 { 222 final String opname = "remove_home"; 223 final String msg = "FAILED (op not impl, rethrown)"; 224 TheLogger.log(_class_name, opname, msg); 225 226 throw new org.omg.CORBA.NO_IMPLEMENT (); 227 } 228 229 final public org.omg.Components.CCMObject[] 230 get_components() 231 { 232 return (org.omg.Components.CCMObject[])_component_refs.toArray(new org.omg.Components.CCMObject[0]); 233 } 234 235 final public org.omg.Components.Deployment.Container 236 get_container() 237 { 238 final String opname = "get_container"; 239 final String msg = "FAILED (op not impl, rethrown)"; 240 TheLogger.log(_class_name, opname, msg); 241 242 throw new org.omg.CORBA.NO_IMPLEMENT (); 243 } 244 245 249 final public org.omg.Components.CCMObject 250 create_component() 251 throws org.omg.Components.CreateFailure 252 { 253 String comp_repid = getComponentRepid(); 254 255 org.omg.CORBA.Object obj = null; 259 if (_mono_ctx!=null) { 260 obj = _mono_ctx.create_ref(comp_repid); 261 262 _component_refs.add(obj); 264 265 return org.omg.Components.CCMObjectHelper.unchecked_narrow(obj); 266 } else if (_segmented_ctx!=null) { 267 org.omg.Components.SegmentDescr[] seg_descrs = getSegmentDescrs(); 268 org.omg.Components.ComponentId cid = _segmented_ctx.create_main_segment(seg_descrs); 269 obj = _segmented_ctx.create_ref_from_cid(comp_repid, cid); 270 271 _component_refs.add(obj); 273 274 return org.omg.Components.CCMObjectHelper.unchecked_narrow(obj); 275 } else { 276 final String opname = "create_component"; 278 final String msg = "FAILED (unsupported context: "+_context.getClass()+")"; 279 TheLogger.error(_class_name, opname, msg); 280 return null; 281 } 282 } 283 } 284 | Popular Tags |