Java Code Examples for org.apache.commons.configuration2.XMLConfiguration#getBoolean()

The following examples show how to use org.apache.commons.configuration2.XMLConfiguration#getBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmppMessageEngine.java    From vicinity-gateway-api with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor for the XMPP message engine. It initialises fields and a {@link java.util.Timer Timer} that periodically
 * in interval that is randomly set, executes the {@link #renewPresenceAndRoster() renewPresenceAndRoster} method.
 * 
 * @param objectId String with the object ID that connects via this engine.
 * @param password Password string for authentication.
 * @param config Configuration of the OGWAPI.
 * @param logger Logger of the OGWAPI. 
 * @param connectionDescriptor Connection descriptor that is using this particular instance of engine.
 */
public XmppMessageEngine(String objectId, String password, XMLConfiguration config, Logger logger, 
																	ConnectionDescriptor connectionDescriptor) {
	super(objectId, password, config, logger, connectionDescriptor);
	
	connection = null;
	chatManager = null;
	roster = null;
	
	// initialise map with opened chats
	openedChats = new HashMap<EntityBareJid, Chat>();
	
	// compute the random time in seconds after which a roster will be renewed
	long timeForRosterRenewal = (long) ((Math.random() * ((ROSTER_RELOAD_TIME_MAX - ROSTER_RELOAD_TIME_MIN) + 1)) 
			+ ROSTER_RELOAD_TIME_MIN) * 1000;
	
	logger.finest("The roster for " + objectId + " will be renewed every " 
			+ timeForRosterRenewal + "ms.");
	
	
	// timer for roster renewing
	Timer timerForRosterRenewal = new Timer();
	timerForRosterRenewal.schedule(new TimerTask() {
		@Override
		public void run() {
			renewPresenceAndRoster();
		}
	}, timeForRosterRenewal, timeForRosterRenewal);
	
	// enable debugging if desired
	boolean debuggingEnabled = config.getBoolean(CONFIG_PARAM_XMPPDEBUG, CONFIG_DEF_XMPPDEBUG);
	if (debuggingEnabled) {
		SmackConfiguration.DEBUG = debuggingEnabled;
		logger.config("XMPP debugging enabled.");
	}
}
 
Example 2
Source File: RestletThread.java    From vicinity-gateway-api with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor, initialises the configuration and logger instances.
 * 
 * @param config OGWAPI configuration.
 * @param logger OGWAPI Logger.
 */
public RestletThread(XMLConfiguration config, Logger logger, MessageCounter messageCounter){
	
	this.config = config;
	this.logger = logger;
	this.messageCounter = messageCounter;
	
	threadRunning = true;
	
	enableHttps = config.getBoolean(CONF_PARAM_APIENABLEHTTPS, CONF_DEF_APIENABLEHTTPS);
	if (enableHttps) {
		logger.config("HTTPS enabled.");
		
		keystoreFile = config.getString(CONF_PARAM_KEYSTOREFILE, CONF_DEF_KEYSTOREFILE);
		logger.config("Path to keystore file: " + keystoreFile);
		
		keystorePassword = config.getString(CONF_PARAM_KEYSTOREPASSWORD, CONF_DEF_KEYSTOREPASSWORD);
		keyPassword = config.getString(CONF_PARAM_KEYPASSWORD, CONF_DEF_KEYPASSWORD);
		
		keystoreType = config.getString(CONF_PARAM_KEYSTORETYPE, CONF_DEF_KEYSTORETYPE);
		logger.config("Keystore type is " + keystoreType);
		
	} else {
		logger.config("HTTPS disabled.");
	}
	
	port = config.getInt(CONF_PARAM_APIPORT, CONF_DEF_APIPORT);
	logger.config("Set to listen on port " + port);
}
 
Example 3
Source File: NeighbourhoodManagerConnector.java    From vicinity-gateway-api with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * 
 * @param config Configuration of the OGWAPI.
 * @param logger Logger of the OGWAPI.
 */
public NeighbourhoodManagerConnector(XMLConfiguration config, Logger logger) {
	
	this.logger = logger;
	
	agid = config.getString(CONFIG_PARAM_PLATFORMIDENTITY, CONFIG_DEF_PLATFORMIDENTITY);
	
	neighbourhoodManagerServer = 
			config.getString(CONFIG_PARAM_NEIGHBORHOODMANAGERSERVER, CONFIG_DEF_NEIGHBORHOODMANAGERSERVER);
	
	port = config.getInt(CONFIG_PARAM_NEIGHBOURHOODMANAGERPORT, CONFIG_DEF_NEIGHBOURHOODMANAGERPORT);
	
	securityEnabled = config.getBoolean(CONFIG_PARAM_PLATFORMSECURITY, CONFIG_DEF_PLATFORMSECURITY);

	secureComms = new SecureServerComms(config, logger);
}
 
Example 4
Source File: RestAgentConnector.java    From vicinity-gateway-api with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor. It is necessary to provide all parameters. If null is provided in place of any of them,
 * a storm of null pointer exceptions is imminent.
 *
 * @param config Configuration of the OGWAPI.
 * @param logger Logger of the OGWAPI.
 */
public RestAgentConnector(XMLConfiguration config, Logger logger){
	super(config, logger);

	// load configuration for dummy connector
	if (config.getBoolean(CONFIG_PARAM_CONNECTORRESTDUMMY, CONFIG_DEF_APIRESTAGENTDUMMY)) {
		logger.config("REST Agent Connector: Dummy payloads enabled, all calls to an Agent via this connector "
				+ "will be simulated.");
		dummyCalls = true;
	} else {
		logger.config("REST Agent Connector: Dummy payloads disabled, all calls to an Agent via this connector "
				+ "will be real.");
	}

	// load configuration for https
	if (config.getBoolean(CONFIG_PARAM_CONNECTORRESTUSEHTTPS, CONFIG_DEF_APIAGENTUSEHTTPS)){
		logger.config("REST Agent Connector: HTTPS protocol enabled for Agent communication.");
		useHttps = true;

		acceptSelfSigned = config.getBoolean(CONFIG_PARAM_HTTPSACCEPTSELFSIGNED, CONFIG_DEF_HTTPSACCEPTSELFSIGNED);

	} else {
		logger.config("REST Agent Connector: HTTPS protocol disabled for Agent communication.");
		useHttps = false;
		acceptSelfSigned = false;
	}

	// load authentication method
	agentAuthMethod = config.getString(CONFIG_PARAM_AUTHMETHOD, CONFIG_DEF_AUTHMETHOD);
	if (!agentAuthMethod.equals(CONFIG_DEF_AUTHMETHOD)) {
		// log it
	}
	agentUsername = config.getString(CONFIG_PARAM_AGENTUSERNAME, CONFIG_DEF_AGENTUSERNAME);
	agentPassword = config.getString(CONFIG_PARAM_AGENTPASSWORD, CONFIG_DEF_AGENTPASSWORD);

	// load timeout
	agentTimeout = config.getInt(CONFIG_PARAM_AGENTTIMEOUT, CONFIG_DEF_AGENTTIMEOUT);

	agentServiceUrl = assembleAgentServiceUrl();

	// initialize CloseableHttpClient
	initialize();
}
 
Example 5
Source File: PersistenceManager.java    From vicinity-gateway-api with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Constructor
 */
public PersistenceManager(XMLConfiguration config, Logger logger) {
	
	this.logger = logger;
	
	persistenceFile = config.getString(CONFIG_PARAM_DATADIR, CONFIG_DEF_PERSISTENCEFILE) + PERSISTENCE_FILENAME;
	thingDescriptionFile = config.getString(CONFIG_PARAM_DATADIR, CONFIG_DEF_PERSISTENCEFILE) + TD_FILENAME;
	
	// NM connector
	nmConnectionManager = new NeighbourhoodManagerConnector(config, logger);
	
	loadTDFromServer = config.getBoolean(CONFIG_PARAM_LOADTDFROMSERVER, CONFIG_DEF_LOADTDFROMSERVER);
	
	
}