aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/exampleplugin/ExamplePluginActivator.java
blob: 7d1992b54ea27817d4acd4f55f763c54a91cfa6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * 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.plugin.exampleplugin;

import java.util.*;

import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*;

import org.osgi.framework.*;

/**
 * The <tt>ExamplePluginActivator</tt> is the entering point for the example
 * plugin bundle.
 *
 * @author Yana Stamcheva
 */
public class ExamplePluginActivator
    implements BundleActivator
{
    Logger logger = Logger.getLogger(ExamplePluginActivator.class);

    /**
     * Called when this bundle is started so the Framework can perform the
     * bundle-specific activities necessary to start this bundle. In the case
     * of our example plug-in we create our menu item and register it as a
     * plug-in component in the right button menu of the contact list.
     */
    public void start(BundleContext bc)
        throws Exception
    {
        final ExamplePluginMenuItem examplePlugin = new ExamplePluginMenuItem();

        Hashtable<String, String> containerFilter
            = new Hashtable<String, String>();
        containerFilter.put(
                Container.CONTAINER_ID,
                Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());

        bc.registerService(
            PluginComponentFactory.class.getName(),
            new PluginComponentFactory(
                    Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU)
            {
                @Override
                protected PluginComponent getPluginInstance()
                {
                    return examplePlugin;
                }
            },
            containerFilter);

        if (logger.isInfoEnabled())
            logger.info("CONTACT INFO... [REGISTERED]");
    }

    /**
     * Called when this bundle is stopped so the Framework can perform the
     * bundle-specific activities necessary to stop the bundle. In the case
     * of our example plug-in we have nothing to do here.
     */
    public void stop(BundleContext bc)
        throws Exception
    {
    }
}