/* This file is part of JFLICKS. JFLICKS 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 3 of the License, or (at your option) any later version. JFLICKS 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 JFLICKS. If not, see <http://www.gnu.org/licenses/>. */ package org.jflicks.transfer.system; import java.io.File; import java.util.Hashtable; import java.util.Properties; import org.jflicks.transfer.Transfer; import org.jflicks.util.BaseActivator; import org.jflicks.util.Util; import org.osgi.framework.BundleContext; import org.osgi.util.tracker.ServiceTracker; /** * Simple activator for the system video manager. * * @author Doug Barnum * @version 1.0 */ public class Activator extends BaseActivator { private SystemTransfer systemTransfer; /** * {@inheritDoc} */ public void start(BundleContext bc) { setBundleContext(bc); SystemTransfer st = new SystemTransfer(); setSystemTransfer(st); // Check for a properties file for transfer... File conf = new File("conf"); if ((conf.exists()) && (conf.isDirectory())) { File props = new File(conf, "transfer.properties"); if ((props.exists()) && (props.isFile())) { Properties p = Util.findProperties(props); if (p != null) { String maxRate = p.getProperty("maxRate"); if (maxRate != null) { st.setMaxRate(maxRate); } String minSize = p.getProperty("minSize"); if (minSize != null) { st.setMinSize(Util.str2long(minSize, st.getMinSize())); } } } } Hashtable<String, String> dict = new Hashtable<String, String>(); dict.put(Transfer.TITLE_PROPERTY, st.getTitle()); bc.registerService(Transfer.class.getName(), st, dict); } /** * {@inheritDoc} */ public void stop(BundleContext context) { SystemTransfer st = getSystemTransfer(); if (st != null) { st.close(); } } private SystemTransfer getSystemTransfer() { return (systemTransfer); } private void setSystemTransfer(SystemTransfer st) { systemTransfer = st; } }