1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class HomeLocalReceptaclesImpl 38 { 39 static private String _class_name = "HomeLocalReceptaclesImpl"; 41 private java.util.Hashtable _name2cnxs; 42 private CallInterceptorFactory _factory; 43 44 public 46 HomeLocalReceptaclesImpl() 47 { 48 _name2cnxs = null; 50 _factory = null; 51 } 52 53 public 55 HomeLocalReceptaclesImpl(CallInterceptorFactory ifact) 56 { 57 _name2cnxs = new java.util.Hashtable (); 59 _factory = ifact; 60 } 61 62 66 final public org.omg.Components.Cookie 67 connect(byte[] cid, String name, org.omg.CORBA.Object obj) 68 { 69 String rname = new String (cid)+":"+name; 71 java.util.ArrayList cnxs = (java.util.ArrayList )_name2cnxs.get(rname); 72 if (cnxs==null) { 73 cnxs = new java.util.ArrayList (); 74 _name2cnxs.put(rname, cnxs); 75 } 76 77 CookieImpl lck = new CookieImpl(name); 79 80 if (_factory!=null) { 82 org.omg.CORBA.Object inter = _factory.createStubInterceptor(name, obj); 83 LocalConnectionImpl cnx = new LocalConnectionImpl(lck, inter); 85 cnxs.add(cnx); 86 } else { 87 LocalConnectionImpl cnx = new LocalConnectionImpl(lck, obj); 89 cnxs.add(cnx); 90 } 91 92 return lck; 94 } 95 96 final public org.omg.CORBA.Object 97 disconnect(byte[] cid, org.omg.Components.Cookie ck) 98 throws org.omg.Components.InvalidSubscription 99 { 100 if (!(ck instanceof CookieImpl)) { 102 throw new org.omg.Components.InvalidSubscription(); 104 } 105 106 CookieImpl lck = (CookieImpl)ck; 108 String name = lck.getName(); 109 String rname = new String (cid)+":"+name; 110 111 java.util.ArrayList cnxs = (java.util.ArrayList )_name2cnxs.get(rname); 113 114 if (cnxs==null) { 115 throw new org.omg.Components.InvalidSubscription(); 116 } 117 118 org.omg.CORBA.Object res = null; 120 org.omg.Components.LocalConnection lcnx = null; 121 for (int i=0;i<cnxs.size();i++) { 122 lcnx = (org.omg.Components.LocalConnection)cnxs.get(i); 123 if (lcnx.ck().equals(ck)) { 124 res = (org.omg.CORBA.Object )cnxs.remove(i); 125 break; 126 } 127 } 128 129 if (res==null) { 131 throw new org.omg.Components.InvalidSubscription(); 132 } 133 134 return res; 135 } 136 137 final public org.omg.Components.LocalConnection[] 138 get_connections(byte[] cid, String name) 139 throws org.omg.Components.InvalidName 140 { 141 String rname = new String (cid)+":"+name; 143 java.util.ArrayList cnxs = (java.util.ArrayList )_name2cnxs.get(rname); 144 145 if (cnxs==null) { 146 throw new org.omg.Components.InvalidName(); 147 } 148 149 return (org.omg.Components.LocalConnection[])cnxs.toArray(new org.omg.Components.LocalConnection[0]); 150 } 151 } 152 | Popular Tags |