1 package com.atlassian.plugin.osgi.container;
2
3 import org.osgi.framework.Bundle;
4 import org.osgi.framework.ServiceReference;
5 import org.osgi.util.tracker.ServiceTracker;
6 import org.twdata.pkgscanner.ExportPackage;
7
8 import java.io.File;
9 import java.util.Collection;
10 import java.util.List;
11
12 import com.atlassian.plugin.osgi.hostcomponents.HostComponentProvider;
13 import com.atlassian.plugin.osgi.hostcomponents.HostComponentRegistration;
14
15 /**
16 * Manages the OSGi container and handles any interactions with it
17 */
18 public interface OsgiContainerManager
19 {
20 /**
21 * Starts the OSGi container
22 *
23 * @throws OsgiContainerException If the container cannot be started
24 */
25 void start() throws OsgiContainerException;
26
27 /**
28 * Stops the OSGi container
29 *
30 * @throws OsgiContainerException If the container cannot be stopped
31 */
32 void stop() throws OsgiContainerException;
33
34 /**
35 * Installs a bundle into a running OSGI container
36 * @param file The bundle file to install
37 * @return The created bundle
38 * @throws OsgiContainerException If the bundle cannot be loaded
39 */
40 Bundle installBundle(File file) throws OsgiContainerException;
41
42 /**
43 * @return If the container is running or not
44 */
45 boolean isRunning();
46
47 /**
48 * Gets a list of installed bundles
49 *
50 * @return An array of bundles
51 */
52 Bundle[] getBundles();
53
54 /**
55 * Gets a list of service references
56 * @return An array of service references
57 */
58 ServiceReference[] getRegisteredServices();
59
60 /**
61 * Gets a list of host component registrations
62 *
63 * @return A list of host component registrations
64 */
65 List<HostComponentRegistration> getHostComponentRegistrations();
66
67 /**
68 * Gets a service tracker to follow a service registered under a certain interface
69 *
70 * @param interfaceClassName The interface class as a String
71 * @return A service tracker to follow all instances of that interface
72 * @throws IllegalStateException If the OSGi container is not running
73 * @since 2.1
74 */
75 ServiceTracker getServiceTracker(String interfaceClassName);
76 }