/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.growlnotification;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.service.systray.*;
import net.java.sip.communicator.util.*;
import org.jitsi.service.resources.*;
import org.jitsi.util.OSUtils; // disambiguation
import org.osgi.framework.*;
/**
* Activates the GrowlNotificationService
*
* @author Romain Kuntz
* @author Egidijus Jankauskas
* @author Lyubomir Marinov
*/
public class GrowlNotificationActivator
implements BundleActivator
{
/**
* The bundle context in which we started
*/
public static BundleContext bundleContext;
/**
* The Logger used by the GrowlNotificationActivator class
* and its instances for logging output.
*/
private static final Logger logger
= Logger.getLogger(GrowlNotificationActivator.class);
/**
* A reference to the resource management service.
*/
private static ResourceManagementService resourcesService;
/**
* A reference to the Growl notification service
*/
private static GrowlNotificationServiceImpl handler;
/**
* Initializes and starts a new GrowlNotificationService
* implementation on Mac OS X.
*
* @param bundleContext the BundleContext to register the new
* GrowlNotificationService implementation into
* @throws Exception if initializing and/or starting the new
* GrowlNotificationService implementation fails
*/
public void start(BundleContext bundleContext)
throws Exception
{
// This bundle is available for Mac OS X only.
if (!OSUtils.IS_MAC)
return;
if (logger.isInfoEnabled())
logger.info("Growl Notification... [Starting]");
GrowlNotificationActivator.bundleContext = bundleContext;
handler = new GrowlNotificationServiceImpl();
handler.start(bundleContext);
bundleContext.registerService(
PopupMessageHandler.class.getName(),
handler,
null);
if (logger.isInfoEnabled())
logger.info("Growl Notification... [Started]");
}
/**
* Stops this bundle.
*
* @param bundleContext the BundleContext to stop this bundle into
* @throws Exception if stopping this bundle fails
*/
public void stop(BundleContext bundleContext)
throws Exception
{
// This bundle is available for Mac OS X only.
if (!OSUtils.IS_MAC)
return;
handler.stop(bundleContext);
if (logger.isInfoEnabled())
logger.info("Growl Notification Service... [Stopped]");
}
/**
* Returns the ResourceManagementService obtained from the bundle
* context.
* @return the ResourceManagementService obtained from the bundle
* context
*/
public static ResourceManagementService getResources()
{
if (resourcesService == null)
{
resourcesService
= ResourceManagementServiceUtils.getService(bundleContext);
}
return resourcesService;
}
}