本文整理汇总了Java中java.rmi.server.Unreferenced类的典型用法代码示例。如果您正苦于以下问题:Java Unreferenced类的具体用法?Java Unreferenced怎么用?Java Unreferenced使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Unreferenced类属于java.rmi.server包,在下文中一共展示了Unreferenced类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refSetRemove
import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
* Remove endpoint from the reference set.
*/
synchronized private void refSetRemove(VMID vmid) {
// remove notification request
DGCImpl.getDGCImpl().unregisterTarget(vmid, this);
if (refSet.removeElement(vmid) && refSet.isEmpty()) {
// reference set is empty, so server can be garbage collected.
// remove object from table.
if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
DGCImpl.dgcLog.log(Log.VERBOSE,
"reference set is empty: target = " + this);
}
/*
* If the remote object implements the Unreferenced interface,
* invoke its unreferenced callback in a separate thread.
*/
Remote obj = getImpl();
if (obj instanceof Unreferenced) {
final Unreferenced unrefObj = (Unreferenced) obj;
AccessController.doPrivileged(
new NewThreadAction(() -> {
Thread.currentThread().setContextClassLoader(ccl);
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
unrefObj.unreferenced();
return null;
}, acc);
}, "Unreferenced-" + nextThreadNum++, false, true)).start();
// REMIND: access to nextThreadNum not synchronized; you care?
}
unpinImpl();
}
}
示例2: unreferenced
import java.rmi.server.Unreferenced; //导入依赖的package包/类
private synchronized void unreferenced() {
final Object obj = ref.get();
if (obj instanceof Unreferenced) {
/*
* Spawn unreferenced thread.
* Start this thread with setDaemon(false) to protect VM
* from exiting while unreferencing the object.
* The thread is started in non-system group
* (see comment for CreateThreadAction class).
*/
Thread uThread = ((Thread) AccessController.doPrivileged(
new CreateThreadAction(new Runnable() {
public void run() {
AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
((Unreferenced) obj).unreferenced();
return null;
}
}, acc);
}
}, "Unreferenced", false, false))); //$NON-NLS-1$
uThread.setContextClassLoader(loader);
uThread.start();
}
ref.makeStrong(false);
}
示例3: clean
import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
* A per {@link java.rmi.dgc.DGC#clean(ObjID[], long, VMID, boolean)}
* implementation of the dirty method
*
* @param vmid
* The {@link java.rmi.dgc.VMID} updated.
* @see java.rmi.dgc.DGC
*/
public final void clean(VMID vmid) {
if (vmIdExpirationTimeMap.containsKey(vmid)) {
vmIdExpirationTimeMap.remove(vmid);
dgcCount--;
if (vmIdExpirationTimeMap.isEmpty()) {
if (StrongRef instanceof Unreferenced) {
((Unreferenced) StrongRef).unreferenced();
}
StrongRef = null;
}
}
}
示例4: removeOlderThan
import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
* Eliminates the VMID's which's lease times had expired.
*
* @param time
* The time to be taken as bound.
* @return the eliminated VMIDs.
*/
public final Set<VMID> removeOlderThan(long time) {
/*
* The return value is not necesary, is there just for possible
* extensions.
*/
HashSet<VMID> retVMIDs = new HashSet<VMID>();
synchronized (vmIdExpirationTimeMap) {
Iterator<VMID> iter = vmIdExpirationTimeMap.keySet().iterator();
while (iter.hasNext()) {
VMID currentVMID = iter.next();
Long iterTime = vmIdExpirationTimeMap.get(currentVMID);
if (iterTime < time) {
iter.remove();
dgcCount--;
if (vmIdExpirationTimeMap.isEmpty()) {
if (StrongRef instanceof Unreferenced) {
((Unreferenced) StrongRef).unreferenced();
}
StrongRef = null;
}
retVMIDs.add(currentVMID);
}
}
}
return retVMIDs;
}
示例5: removeOlderThan
import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
* Eliminates the VMID's which's lease times had expired.
*
* @param time
* The time to be taken as bound.
* @return the eliminated VMIDs.
*/
public final Set<VMID> removeOlderThan(long time) {
/*
* The return value is not necesary, is there just for possible
* extensions.
*/
HashSet<VMID> retVMIDs = new HashSet<VMID>();
synchronized (vmIdExpirationTimeMap) {
Iterator<VMID> iter = vmIdExpirationTimeMap.keySet().iterator();
while (iter.hasNext()) {
VMID currentVMID = iter.next();
Long iterTime = vmIdExpirationTimeMap.get(currentVMID);
if (iterTime < time) {
iter.remove();
dgcCount--;
if (vmIdExpirationTimeMap.isEmpty()) {
if (StrongRef instanceof Unreferenced) {
((Unreferenced) StrongRef).unreferenced();
}
StrongRef = null;
}
retVMIDs.add(currentVMID);
}
}
}
return retVMIDs;
}
示例6: refSetRemove
import java.rmi.server.Unreferenced; //导入依赖的package包/类
/**
* Remove endpoint from the reference set.
*/
synchronized private void refSetRemove(VMID vmid) {
// remove notification request
DGCImpl.getDGCImpl().unregisterTarget(vmid, this);
if (refSet.removeElement(vmid) && refSet.isEmpty()) {
// reference set is empty, so server can be garbage collected.
// remove object from table.
if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
DGCImpl.dgcLog.log(Log.VERBOSE,
"reference set is empty: target = " + this);
}
/*
* If the remote object implements the Unreferenced interface,
* invoke its unreferenced callback in a separate thread.
*/
Remote obj = getImpl();
if (obj instanceof Unreferenced) {
final Unreferenced unrefObj = (Unreferenced) obj;
final Thread t =
java.security.AccessController.doPrivileged(
new NewThreadAction(new Runnable() {
public void run() {
unrefObj.unreferenced();
}
}, "Unreferenced-" + nextThreadNum++, false, true));
// REMIND: access to nextThreadNum not synchronized; you care?
/*
* We must manually set the context class loader appropriately
* for threads that may invoke user code (see bugid 4171278).
*/
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
t.setContextClassLoader(ccl);
return null;
}
});
t.start();
}
unpinImpl();
}
}