www.pudn.com > sxg.rar > GatewayConf.java


/*
 * Copyright (c) 2003 Jens Mueller
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/**
 	This class provides static access to gateway's configuration. Variable values are set up
 	by setUpConfig() of SnmpXmlGateway

 	@author Jens Mueller
 */

import java.io.File;
import java.net.MalformedURLException;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.Branch;
import org.dom4j.XPath;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import sun.misc.ServiceConfigurationError;

public class GatewayConf
{
	private static String mib_repository_url				= "";
	private static boolean isConfigured						= false;
	private static boolean isSetAllowed					= false;
	private static long cachingTimeSecs					= 1;
	private static long cachePurgeIntervalSecs			= 60;
	
	/* Qualifiers used in get via Request-String */
	public static final String GET_ROOTELEMENT 	= "snmp-data";
	public static final String TRAP_ROOTELEMENT 	= "trap-data";
	public static final String GET_AGENTELEMENT 	= "context";
	public static final String GET_IPADDR 				= "@ipaddr";
	public static final String GET_HOSTNAME 			= "@hostname";
	public static final String GET_PORT		 			= "@port";
	public static final String GET_COMM_STR 			= "@community";
	public static final String GET_VERSION 				= "@version";
	public static final String GET_CACHING 				= "@caching";
	public static final String IPADDR 				= "ipaddr";
	public static final String HOSTNAME 			= "hostname";
	public static final String COMM_STR 			= "community";
	public static final String VERSION 				= "version";
	public static final String CACHING 				= "caching";
	public static final String TIME		 				= "time";
	public static final String PORT	 				= "port";
	
	public static final int DEFAULT_PORT					= 161;
	public static final String DEFAULT_COMM_STR	=	"public";
	
	public static final String XML_COMMENT 	= 	
	"generated by SnmpXmlGateway version 1.0, Copyright (C) 2003 Jens Mueller. "+
	"SnmpXmlGateway and output of SnmpXmlGateway comes with ABSOLUTELY NO WARRANTY.\n" +
	" This is free software, and you are welcome to redistribute" +
	" it under certain conditions; refer to the GNU GPL for details";
	
	public static synchronized boolean isConfigured()
	{
		return isConfigured;
	}
	
	public static synchronized String getRepositoryUrl()
	{
		return mib_repository_url;
	}

	public static synchronized long getCachingTimeSecs()
	{
		return cachingTimeSecs;
	}
	
	public static synchronized long getCachePurgeIntervalSecs()
	{
		return cachePurgeIntervalSecs;
	}
	

	public static synchronized void	setConfigured( boolean confval )
	{
		isConfigured = confval;
	}

	public static synchronized void	setRepositoryUrl( String url )
	{
		mib_repository_url = url;
	}

	public static synchronized void	setCachingTimeSecs( long secs )
	{
		cachingTimeSecs = secs;
	}

	public static synchronized void	setCachePurgerIntervalSecs( long secs )
	{
		cachePurgeIntervalSecs = secs;
	}
	
	public static synchronized boolean isSetAllowed()
	{
		return isSetAllowed;
	}
	
	public static synchronized void setSetAllowed( boolean value )
	{
		isSetAllowed = value;
	}
}