src/share/classes/sun/rmi/transport/ObjectTable.java

Print this page




 158                 } else {
 159                     return false;
 160                 }
 161             }
 162         }
 163     }
 164 
 165     /**
 166      * Add target to object table.  If it is not a permanent entry, then
 167      * make sure that reaper thread is running to remove collected entries
 168      * and keep VM alive.
 169      */
 170     static void putTarget(Target target) throws ExportException {
 171         ObjectEndpoint oe = target.getObjectEndpoint();
 172         WeakRef weakImpl = target.getWeakImpl();
 173 
 174         if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
 175             DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
 176         }
 177 
 178         Remote impl = target.getImpl();
 179         if (impl == null) {
 180             throw new ExportException(
 181                 "internal error: attempt to export collected object");
 182         }
 183 
 184         synchronized (tableLock) {

 185             if (objTable.containsKey(oe)) {
 186                 throw new ExportException(
 187                     "internal error: ObjID already in use");
 188             } else if (implTable.containsKey(weakImpl)) {
 189                 throw new ExportException("object already exported");
 190             }
 191 
 192             objTable.put(oe, target);
 193             implTable.put(weakImpl, target);
 194 
 195             if (!target.isPermanent()) {
 196                 incrementKeepAliveCount();
 197             }
 198         }

 199     }
 200 
 201     /**
 202      * Remove target from object table.
 203      *
 204      * NOTE: This method must only be invoked while synchronized on
 205      * the "tableLock" object, because it does not do so itself.
 206      */
 207     private static void removeTarget(Target target) {
 208         // assert Thread.holdsLock(tableLock);
 209 
 210         ObjectEndpoint oe = target.getObjectEndpoint();
 211         WeakRef weakImpl = target.getWeakImpl();
 212 
 213         if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
 214             DGCImpl.dgcLog.log(Log.VERBOSE, "remove object " + oe);
 215         }
 216 
 217         objTable.remove(oe);
 218         implTable.remove(weakImpl);




 158                 } else {
 159                     return false;
 160                 }
 161             }
 162         }
 163     }
 164 
 165     /**
 166      * Add target to object table.  If it is not a permanent entry, then
 167      * make sure that reaper thread is running to remove collected entries
 168      * and keep VM alive.
 169      */
 170     static void putTarget(Target target) throws ExportException {
 171         ObjectEndpoint oe = target.getObjectEndpoint();
 172         WeakRef weakImpl = target.getWeakImpl();
 173 
 174         if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
 175             DGCImpl.dgcLog.log(Log.VERBOSE, "add object " + oe);
 176         }
 177 






 178         synchronized (tableLock) {
 179             if (target.getImpl() != null) {
 180                 if (objTable.containsKey(oe)) {
 181                     throw new ExportException(
 182                         "internal error: ObjID already in use");
 183                 } else if (implTable.containsKey(weakImpl)) {
 184                     throw new ExportException("object already exported");
 185                 }
 186 
 187                 objTable.put(oe, target);
 188                 implTable.put(weakImpl, target);
 189 
 190                 if (!target.isPermanent()) {
 191                     incrementKeepAliveCount();
 192                 }
 193             }
 194         }
 195     }
 196 
 197     /**
 198      * Remove target from object table.
 199      *
 200      * NOTE: This method must only be invoked while synchronized on
 201      * the "tableLock" object, because it does not do so itself.
 202      */
 203     private static void removeTarget(Target target) {
 204         // assert Thread.holdsLock(tableLock);
 205 
 206         ObjectEndpoint oe = target.getObjectEndpoint();
 207         WeakRef weakImpl = target.getWeakImpl();
 208 
 209         if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
 210             DGCImpl.dgcLog.log(Log.VERBOSE, "remove object " + oe);
 211         }
 212 
 213         objTable.remove(oe);
 214         implTable.remove(weakImpl);