public static void resetSystemError() { if (originalSystemErr != null) { redirectSystemError(originalSystemErr); } }
public static void resetSystemOut() { if (originalSystemOut != null) { redirectSystemOut(originalSystemOut); } }
/** * Stops the embedded Limbus Environment if started. * * @return Returns <code>true</code> if the engine terminated cleanly. If there were abandoned threads that did not * terminate on shutdown signal, <code>false</code> is returned. */ public boolean stopStage() { try { EngineLauncher.shutdownEngine(); EngineLauncher.waitForShutdown(); return !EngineLauncher.lastShutdownWasDirty; } finally { EngineLauncher.skipSystemExit = false; hasAccess = false; stageRunning.release(); } }
/** * Bootstraps an engine implementation specified by its class. * * @param engineClass * The engine class. * @throws Exception * Thrown on any bootstrap error. */ public static void bootstrap(Class<? extends Engine> engineClass) throws Exception { Engine engine; try { engine = getEngineByClass(engineClass); } catch (Exception e) { throw new Exception( String.format("Cannot get engine implementation using the specified class %s", engineClass.getName()), e); } bootstrap(engine); }
redirectSystemOuts(); createLoggingEnvironment(); createMonitoringEnvironment(); installShutdownHook(); internalShutdown(); throw e;
engine = getEngineForName(engineClassName); } else { engine = getEngineFromServices(); bootstrap(engine); printUsageInformation(options); } catch (Exception e) { e.printStackTrace();
@Override protected void performInitialize() throws Exception { this.routerStdOut = new RoutedOutputStream<Integer, T>(new ContextClassloaderSelector<T>(), getTargetWriter(), getDefaultTargetStdOut()); this.routerStdErr = new RoutedOutputStream<Integer, T>(new ContextClassloaderSelector<T>(), getTargetWriter(), getDefaultTargetStdErr()); this.recorderStdOut = new ThreadSensitiveRecorderStream(routerStdOut); this.recorderStdErr = new ThreadSensitiveRecorderStream(routerStdErr); // TODO - schuettec - 21.10.2016 : This is not a good but working solution. Selecting targets with more than one // condition is not possible for the moment. Selecting target writers is not possible too. To redirect the // Limbus Maintenance Console to original std/out, this is the only working solution without changing the // architecture. this.filterStdOut = new MaintenanceFilterStream(recorderStdOut); this.filterStdErr = new MaintenanceFilterStream(recorderStdErr); // Redirect system out EngineLauncher.redirectSystemOut(filterStdOut); EngineLauncher.redirectSystemError(filterStdErr); }
finishMonitoringEnvironment(); finishLoggingEnvironment(); } finally { resetSystemOuts();
@Override public void run() { MultiWindowTextGUI gui = console.getGui(); MessageDialogButton selectedButton = new MessageDialogBuilder().setTitle("Engine shutdown") .setText("Are you sure to stop all plugins and shutdown the engine?") .addButton(MessageDialogButton.Yes) .addButton(MessageDialogButton.No) .build() .showDialog(gui); if (selectedButton == MessageDialogButton.Yes) { EngineLauncher.shutdownEngine(); } } });
/** * Bootstraps a Limbus System engine that utilizes {@link LimbusSystem} to create a * runtime environment of components. * * @param system * The uninitialized configured {@link LimbusSystem} * @throws Exception * Thrown on any error while bootstrapping. */ public static void bootstrapLimbusSystem(LimbusSystem system) throws Exception { SystemEngine engine = new SystemEngine(system); bootstrap(engine); }
private static Engine getEngineForName(String engineClass) throws Exception { try { Class<Engine> engineCls = ReflectionUtil.loadServiceClass(engineClass, Engine.class); return getEngineByClass(engineCls); } catch (Exception e) { throw new Exception(String.format("Engine instance %s cannot be created.", engineClass), e); } }
/** * Configures the {@link EngineLauncher} to start an embedded Limbus Environment. This instance of {@link LimbusStage} * needs to acquire exclusive access to the {@link EngineLauncher}. * * @throws Exception * Thrown on any bootstrapping error or if no exclusive access could be acquired. */ public void startStage() throws Exception { hasAccess = stageRunning.tryAcquire(); denyNoAccess(); EngineLauncher.skipSystemExit = true; try { EngineLauncher.bootstrapLimbusSystem(system); deploy(); } catch (Exception e) { stopStage(); throw e; } }
/** * Bootstraps a Limbus System engine that utilizes {@link LimbusSystem} and a valid system description to create a * runtime environment of components. The system descriptor can be provided in the following ways: * <ul> * <li>Place a file <tt>limbus-system.xml</tt> in the Limbus configuration directory.</li> * <li>Place a Limbus Property file for class {@link SystemEngine} overriding the default system descriptor filename. * </li> * </ul> * * @throws Exception * Thrown on any bootstrapping error. */ public static void bootstrapLimbusSystem() throws Exception { Engine engine; try { engine = getEngineByClass(SystemEngine.class); } catch (Exception e) { throw new Exception( String.format("Cannot get engine implementation using the specified class %s", SystemEngine.class.getName()), e); } bootstrap(engine); }
/** * Bootstraps a Limbus System engine that utilizes {@link LimbusSystem} and a valid system description to create a * runtime environment of components. The system descriptor is specified via {@link InputStream}. * * @param systemDescriptor * The input stream representing the XML system descriptor. * * @throws SerializeException * Thrown if the {@link LimbusSystem} cannot be created from the specified system descriptor. * @throws Exception * Thrown on any error while bootstrapping. */ public static void bootstrapLimbusSystem(InputStream systemDescriptor) throws SerializeException, Exception { SystemEngine engine = new SystemEngine(systemDescriptor); bootstrap(engine); }