All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scudata.server.IProxy Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20241126
Show newest version
package com.scudata.server;

import java.util.ArrayList;

import com.scudata.common.Logger;

/**
 * ?????ӿڳ?????
 * 
 * @author Joancy
 *
 */
public abstract class IProxy
{
	int id = -1;
	IProxy parent = null;
	public ArrayList subProxies=null;
	long lastAccessTime = -1;
	
	/**
	 * ???캯??
	 * @param parent ??????
	 * @param id Ψһ???
	 */
	public IProxy(IProxy parent, int id){
		this.parent = parent;
		this.id = id;
	}
	
	/**
	 * ˢ?´????ķ???ʱ??
	 */
	public void access() {
		lastAccessTime = System.currentTimeMillis();
		if(parent!=null){
			parent.access();
		}
	}

	/**
	 * ???ô????ķ???ʱ??
	 */
	public void resetAccess() {
		lastAccessTime = -1;
	}
	
	/**
	 * ???ٴ???????
	 */
	public synchronized void destroy(){
//		?ȹ??Ӵ???
		if(subProxies!=null){
			for(int i=0;i();
		}
		subProxies.add(proxy);
	}
	
	/**
	 * ?Ƴ??Ӵ???
	 * @param proxy ?Ӵ???????
	 */
	public synchronized void removeProxy(IProxy proxy){
		if(subProxies!=null){
			subProxies.remove(proxy);
		}
	}

	/**
	 * ???ݱ?Ż?ȡ?Ӵ???
	 * @param id ???
	 * @return ?Ӵ???????
	 */
	public synchronized IProxy getProxy(int id){
		if(subProxies==null){
			return null;
		}
		for(int i=0;i timeOut) {
			Logger.debug(this + " is timeout.");
			destroy();
			return true;
		}
		return false;
	}
	
	/**
	 * ??ȡ???????
	 * @return ???
	 */
	public int getId(){
		return id;
	}
	
	/**
	 * ??ȡ??????
	 * @return ??????????
	 */
	public IProxy getParent(){
		return parent;
	}
	
	/**
	 * ??ȡ?Ӵ??????ܸ???
	 * @return ?Ӵ???????
	 */
	public synchronized int size(){
		if(subProxies==null) return 0;
		return subProxies.size();
	}
	
	/**
	 * ?رյ?ǰ???????ͷ???Դ
	 */
	public abstract void close();
	
	/**
	 * ??ȡ??????????????Ϣ
	 */
	public abstract String toString();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy