use of org.apache.qpid.server.logging.logback.LogbackLoggingSystemLauncherListener in project qpid-broker-j by apache.
the class InternalBrokerHolder method start.
public void start(final Map<String, Object> systemConfig) throws Exception {
if (Thread.getDefaultUncaughtExceptionHandler() == null) {
Thread.setDefaultUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER);
}
LOGGER.info("Starting internal broker (same JVM)");
_systemLauncher = new SystemLauncher(new LogbackLoggingSystemLauncherListener(), new SystemLauncherListener.DefaultSystemLauncherListener() {
@Override
public void onShutdown(final int exitCode) {
_systemLauncher = null;
}
@Override
public void exceptionOnShutdown(final Exception e) {
if (e instanceof IllegalStateException || e instanceof IllegalStateTransitionException) {
System.out.println("IllegalStateException occurred on broker shutdown in test " + getClassQualifiedTestName());
}
}
});
_systemLauncher.startup(systemConfig);
}
use of org.apache.qpid.server.logging.logback.LogbackLoggingSystemLauncherListener in project qpid-broker-j by apache.
the class EmbeddedBrokerPerClassAdminImpl method beforeTestClass.
@Override
public void beforeTestClass(final Class testClass) {
_preservedProperties = new HashMap<>();
try {
String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
_currentWorkDirectory = Files.createTempDirectory(String.format("qpid-work-%s-%s-", timestamp, testClass.getSimpleName())).toString();
ConfigItem[] configItems = (ConfigItem[]) testClass.getAnnotationsByType(ConfigItem.class);
Arrays.stream(configItems).filter(ConfigItem::jvm).forEach(i -> {
_preservedProperties.put(i.name(), System.getProperty(i.name()));
System.setProperty(i.name(), i.value());
});
Map<String, String> context = new HashMap<>();
context.put("qpid.work_dir", _currentWorkDirectory);
context.put("qpid.port.protocol_handshake_timeout", "1000000");
context.putAll(Arrays.stream(configItems).filter(i -> !i.jvm()).collect(Collectors.toMap(ConfigItem::name, ConfigItem::value, (name, value) -> value)));
Map<String, Object> systemConfigAttributes = new HashMap<>();
systemConfigAttributes.put(ConfiguredObject.CONTEXT, context);
systemConfigAttributes.put(ConfiguredObject.TYPE, System.getProperty("broker.config-store-type", "JSON"));
systemConfigAttributes.put(SystemConfig.STARTUP_LOGGED_TO_SYSTEM_OUT, Boolean.FALSE);
if (Thread.getDefaultUncaughtExceptionHandler() == null) {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
}
LOGGER.info("Starting internal broker (same JVM)");
List<SystemLauncherListener> systemLauncherListeners = new ArrayList<>();
systemLauncherListeners.add(new LogbackLoggingSystemLauncherListener());
systemLauncherListeners.add(new ShutdownLoggingSystemLauncherListener());
systemLauncherListeners.add(new PortExtractingLauncherListener());
_systemLauncher = new SystemLauncher(systemLauncherListeners.toArray(new SystemLauncherListener[systemLauncherListeners.size()]));
_systemLauncher.startup(systemConfigAttributes);
} catch (Exception e) {
throw new BrokerAdminException("Failed to start broker for test class", e);
}
}
use of org.apache.qpid.server.logging.logback.LogbackLoggingSystemLauncherListener in project qpid-broker-j by apache.
the class Main method startBroker.
protected void startBroker(Map<String, Object> attributes) throws Exception {
SystemLauncher systemLauncher = new SystemLauncher(new LogbackLoggingSystemLauncherListener(), new SystemLauncherListener.DefaultSystemLauncherListener() {
@Override
public void onShutdown(final int exitCode) {
if (exitCode != 0) {
shutdown(exitCode);
}
}
});
systemLauncher.startup(attributes);
}
Aggregations