use of org.apache.karaf.shell.impl.console.osgi.secured.SecuredSessionFactoryImpl in project karaf by apache.
the class Activator method start.
@Override
public void start(final BundleContext context) throws Exception {
threadIO = new ThreadIOImpl();
threadIO.start();
sessionFactory = new SecuredSessionFactoryImpl(context, threadIO);
sessionFactory.getCommandProcessor().addConverter(new Converters(context));
sessionFactory.getCommandProcessor().addConstant(".context", context.getBundle(0).getBundleContext());
final CopyOnWriteArraySet<CommandLoggingFilter> listeners = new CopyOnWriteArraySet<>();
filterTracker = new ServiceTracker<>(context, CommandLoggingFilter.class, new ServiceTrackerCustomizer<CommandLoggingFilter, CommandLoggingFilter>() {
@Override
public CommandLoggingFilter addingService(ServiceReference<CommandLoggingFilter> reference) {
CommandLoggingFilter service = context.getService(reference);
listeners.add(service);
return service;
}
@Override
public void modifiedService(ServiceReference<CommandLoggingFilter> reference, CommandLoggingFilter service) {
}
@Override
public void removedService(ServiceReference<CommandLoggingFilter> reference, CommandLoggingFilter service) {
listeners.remove(service);
context.ungetService(reference);
}
});
filterTracker.open();
LoggingCommandSessionListener loggingCommandSessionListener = new LoggingCommandSessionListener();
loggingCommandSessionListener.setFilters(listeners);
sessionFactory.getCommandProcessor().addListener(loggingCommandSessionListener);
try {
EventAdminListener listener = new EventAdminListener(context);
sessionFactory.getCommandProcessor().addListener(listener);
eventAdminListener = listener;
} catch (NoClassDefFoundError error) {
// Ignore the listener if EventAdmin package isn't present
}
sessionFactory.register(new ManagerImpl(sessionFactory, sessionFactory));
sessionFactoryRegistration = context.registerService(SessionFactory.class, sessionFactory, null);
commandProcessorRegistration = context.registerService(CommandProcessor.class, sessionFactory.getCommandProcessor(), null);
actionExtender = new CommandExtender(sessionFactory);
actionExtender.start(context);
commandTracker = new CommandTracker(sessionFactory, context);
commandTracker.open();
converterTracker = new ConverterTracker(sessionFactory, context);
converterTracker.open();
listenerTracker = new ListenerTracker(sessionFactory, context);
listenerTracker.open();
if (Boolean.parseBoolean(context.getProperty(START_CONSOLE))) {
localConsoleManager = new LocalConsoleManager(context, sessionFactory);
localConsoleManager.start();
} else {
LOGGER.info("Not starting local console. To activate set " + START_CONSOLE + "=true");
}
}
Aggregations