use of org.osgi.framework.Bundle in project sling by apache.
the class SlingTldLocationsCache method printConfiguration.
public void printConfiguration(final PrintWriter pw) {
pw.println("Currently available JSP Taglibs:");
final SortedMap<String, String> taglibs = new TreeMap<String, String>();
for (final Map.Entry<String, TldLocationEntry> entry : tldLocations.entrySet()) {
final long bundleId = entry.getValue().getBundleId();
final Bundle bundle = bundleContext.getBundle(bundleId);
if (bundle != null) {
taglibs.put(entry.getKey(), String.format("%s (%s)", bundle.getSymbolicName(), bundleId));
} else {
// really shouldn't happen
taglibs.put(entry.getKey(), String.format("INVALID BUNDLE ID: %s", bundleId));
}
}
for (final Map.Entry<String, String> entry : taglibs.entrySet()) {
pw.printf(" %s - %s\n", entry.getKey(), entry.getValue());
}
}
use of org.osgi.framework.Bundle in project sling by apache.
the class LogSupportTest method prepare.
@Before
@SuppressWarnings("unchecked")
public void prepare() throws Exception {
bundle = Mockito.mock(Bundle.class);
Mockito.when(bundle.getSymbolicName()).thenReturn("foo.bundle");
Mockito.when(bundle.getBundleId()).thenReturn(42L);
StartLevel startLevel = Mockito.mock(StartLevel.class);
logSupport = new LogSupport(startLevel);
Field loggerField = LogSupport.class.getDeclaredField("loggers");
loggerField.setAccessible(true);
Map<Long, Logger> loggers = (Map<Long, Logger>) loggerField.get(logSupport);
testLogger = getMockInfoLogger();
loggers.put(bundle.getBundleId(), testLogger);
}
use of org.osgi.framework.Bundle in project sling by apache.
the class BundleBundleVersionInfoTest method testSnapshot.
@Test
public void testSnapshot() {
final String name = "some.bundle";
final Version version = new Version("1.0.4.SNAPSHOT");
final long lastMod = 0;
final Bundle b = getMockBundle(name, version, lastMod);
BundleVersionInfo<?> vi = new BundleBundleVersionInfo(b);
assertEquals("Symbolic name matches", name, vi.getBundleSymbolicName());
assertEquals("Version matches", version, vi.getVersion());
assertTrue("isBundle", vi.isBundle());
assertTrue("Bundle is a snapshot", vi.isSnapshot());
assertEquals("Last-Modified matches", BundleVersionInfo.BND_LAST_MODIFIED_MISSING, vi.getBundleLastModified());
assertTrue("Bundle is stored as source", vi.getSource() == b);
}
use of org.osgi.framework.Bundle in project sling by apache.
the class Activator method start.
public void start(BundleContext bundleContext) {
// install handler for uncaught exceptions
oldHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(this);
// install thread handler shell command
register(bundleContext, new String[] { "org.apache.felix.shell.Command" }, new ServiceFactory() {
public void ungetService(final Bundle bundle, final ServiceRegistration reg, final Object consoleObject) {
// nothing to do
}
public Object getService(final Bundle bundle, final ServiceRegistration reg) {
return new ThreadDumpCommand();
}
}, null);
// install Web Console configuration printer
final Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("felix.webconsole.label", "slingthreads");
props.put("felix.webconsole.title", "Threads");
props.put("felix.webconsole.configprinter.modes", "always");
final ThreadDumperPanel tdp = new ThreadDumperPanel();
register(bundleContext, new String[] { tdp.getClass().getName() }, tdp, props);
}
use of org.osgi.framework.Bundle in project sling by apache.
the class AdapterManagerTest method createBundle.
/**
* Helper method to create a mock bundle
*/
protected Bundle createBundle(String name) {
final Bundle bundle = this.context.mock(Bundle.class, name);
this.context.checking(new Expectations() {
{
allowing(bundle).getBundleId();
will(returnValue(1L));
}
});
return bundle;
}
Aggregations