/* Copyright (c) 2008, Centre for Educational Technology, Tallinn University Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ package ee.tlu.htk.waramu.fire; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import net.sourceforge.limbs.client.core.SparkCore; import net.sourceforge.limbs.client.core.SparkException; import net.sourceforge.limbs.client.sqi.SparkSQI; /** * * @author vahur */ public class Connection implements ServletContextListener { private SparkCore sc = null; private SparkSQI sqi = null; /** Creates a new instance of Connection */ public Connection() { } public void contextInitialized(ServletContextEvent sce) { //connect(); } public void contextDestroyed(ServletContextEvent sce) { //disconnect(); } public void connect() { try { sc = SparkCore.getInstance(); sqi = SparkSQI.getInstance(); sc.setVerbosity(SparkCore.VERBOSE ); sc.setSecurityParameters( "test1", "test1Pwd", "", "" ); sc.setMessageSigned( false ); sc.setUnsignedMessageAccepted( true ); sc.setLdapSuffix( "dc=eun,dc=org" ) ; sc.setLimbsUrl( "http://stove.test.eun.org:8080/" ); sc.setMqPrefix("calibrate" ); sc.turnConnectionOn("test1", "test1Pwd" ); // sqi LocalSQI localSQI = new LocalSQI(); sqi.setLocalAsynchronous(false); sqi.setLocalSQITarget(localSQI); sqi.startService(); } catch (SparkException ex) { ex.printStackTrace(); } } public void disconnect() { sc = SparkCore.getInstance(); sqi = SparkSQI.getInstance(); if ( sc.isReallyConnected() ) { try { //sqi.destroySession(null); sqi.stopService(); } catch (SparkException ex) { ex.printStackTrace(); } sc.turnConnectionOff(); } } }