use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class ConfigurationAdminUpdateStressTest method startup.
// ----------------------- Initialization -------------------------------------------
@Before
public void startup() {
bundleContext.registerService(LogService.class.getName(), this, null);
_tracker = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
_tracker.open();
}
use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class ClassUtils method getPackageAdmin.
public static Object getPackageAdmin() {
if (m_packageAdmin == null) {
synchronized (ClassUtils.class) {
if (m_packageAdmin == null) {
m_packageAdmin = new ServiceTracker(m_context, PACKAGEADMIN_CLASS, null);
m_packageAdmin.open();
}
}
}
return m_packageAdmin.getService();
}
use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class Activator method start.
public void start(BundleContext context) {
m_context = context;
// Register impl service implementation.
String[] classes = { org.apache.felix.shell.ShellService.class.getName(), org.ungoverned.osgi.service.shell.ShellService.class.getName() };
context.registerService(classes, m_shell = new ShellServiceImpl(), null);
// Create a service tracker to listen for command services.
String filter = "(|(objectClass=" + org.apache.felix.shell.Command.class.getName() + ")(objectClass=" + org.ungoverned.osgi.service.shell.Command.class.getName() + "))";
try {
m_tracker = new ServiceTracker(context, FrameworkUtil.createFilter(filter), m_tracker);
} catch (InvalidSyntaxException ex) {
// This should never happen.
}
m_tracker.open();
// Register "bundlelevel" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new BundleLevelCommandImpl(m_context), null);
// Register "cd" command service.
classes = new String[2];
classes[0] = org.apache.felix.shell.Command.class.getName();
classes[1] = org.apache.felix.shell.CdCommand.class.getName();
context.registerService(classes, new CdCommandImpl(m_context), null);
// Register "find" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new FindCommandImpl(m_context), null);
// Register "headers" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new HeadersCommandImpl(m_context), null);
// Register "help" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new HelpCommandImpl(m_context), null);
// Register "inspect" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new InspectCommandImpl(m_context), null);
// Register "install" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new InstallCommandImpl(m_context), null);
// Register "log" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new LogCommandImpl(m_context), null);
// Register "ps" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new PsCommandImpl(m_context), null);
// Register "refresh" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new RefreshCommandImpl(m_context), null);
// Register "resolve" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new ResolveCommandImpl(m_context), null);
// Register "startlevel" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new StartLevelCommandImpl(m_context), null);
// Register "shutdown" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new ShutdownCommandImpl(m_context), null);
// Register "start" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new StartCommandImpl(m_context), null);
// Register "stop" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new StopCommandImpl(m_context), null);
// Register "sysprop" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new SystemPropertiesCommandImpl(), null);
// Register "uninstall" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new UninstallCommandImpl(m_context), null);
// Register "update" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new UpdateCommandImpl(m_context), null);
// Register "version" command service.
context.registerService(org.apache.felix.shell.Command.class.getName(), new VersionCommandImpl(m_context), null);
}
use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class BaseIntegrationTest method getService.
/**
* Obtains a service without waiting for it to become available.
* @param serviceName
* @return
* @throws Exception
*/
protected <T> T getService(String serviceName) throws Exception {
ServiceTracker tracker = new ServiceTracker(m_context, serviceName, null);
tracker.open();
T result;
try {
result = (T) tracker.getService();
} finally {
tracker.close();
}
return result;
}
use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class Activator method start.
/**
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public final void start(BundleContext context) throws Exception {
this.context = context;
this.tracker = new ServiceTracker(context, UserAdmin.class.getName(), this);
this.tracker.open();
}
Aggregations