FileDocCategorySizeDatePackage
ShareConfigImpl.javaAPI DocAzureus 3.0.3.42769Fri Dec 10 08:57:22 GMT 2004org.gudy.azureus2.pluginsimpl.local.sharing

ShareConfigImpl

public class ShareConfigImpl extends Object
author
parg

Fields Summary
protected ShareManagerImpl
manager
protected int
suspend_level
protected boolean
save_outstanding
protected AEMonitor
this_mon
Constructors Summary
Methods Summary
protected voidloadConfig(ShareManagerImpl _manager)


	 
	
			 
	
		manager	= _manager;
				
		try{
						
			Map map = FileUtil.readResilientConfigFile("sharing.config");
			
			List resources = (List) map.get("resources");
			
			if (resources == null){
				
				return;
			}
			
			Iterator  iter = resources.iterator();
			
			while (iter.hasNext()) {
				
				Map r_map = (Map) iter.next();
				
				manager.deserialiseResource( r_map );
			}
			
		}catch (Exception e) {
			
			Debug.printStackTrace( e );
		}
	
protected voidresumeSaving()

		try{
			this_mon.enter();
		
			suspend_level--;
			
			if ( suspend_level == 0 && save_outstanding ){
				
				save_outstanding	= false;
				
				saveConfig();
			}
		}finally{
			
			this_mon.exit();
		}
	
protected voidsaveConfig()

		try{
			this_mon.enter();
		
			if ( suspend_level > 0 ){
				
				save_outstanding = true;
				
				return;
			}
			
			Map map = new HashMap();
			
			List list = new ArrayList();
			
			map.put("resources", list);
			
			ShareResource[]	shares = manager.getShares();
			
			for (int i=0;i<shares.length;i++){
				
				Map	m = new HashMap();
				
				((ShareResourceImpl)shares[i]).serialiseResource( m );
				
				list.add( m );
			}
			
			FileUtil.writeResilientConfigFile("sharing.config", map);
			
		}finally{
			
			this_mon.exit();
		}
	
protected voidsuspendSaving()

		try{
			this_mon.enter();
		
			suspend_level++;
			
		}finally{
			
			this_mon.exit();
		}