@Override public void initialize() throws Exception { super.initialize(); this.pluginThread.start(); }
/** * */ public Initializable() { readResolve(); }
/** * Initializes this object. This method is thread safe. * * @throws E * Thrown if the initialization failed. */ @Override public void initialize() throws E { synchronized (lock) { if (initialized) { throw new AlreadyInitializedException( "This object was already initialized. It is highly recommended to not call initialize multiple times during the lifecycle."); } // Set initialized flag to true, because some implementations use their own operations within // initialization. this.initialized = true; try { performInitialize(); } catch (Exception e) { // On exception finish this object finish(); throw e; } } }
/** * This method deinitializes this object. */ @Override public void finish() { synchronized (lock) { if (initialized) { try { performFinish(); } catch (Throwable e) { // Do not use a logger here. Logging would require dependencies that will present at classloading // time, but // not // when running in a plugin's runtime context. new Exception("The performFinish() operation was expected to be silent but threw an exception.", e) .printStackTrace(); } finally { initialized = false; } } } }
@Override public void finish() { this.pluginThread.interrupt(); try { this.pluginThread.join(); } catch (InterruptedException e) { // Do not use a logger here. Logging would require dependencies that will present at classloading time, but // not // when running in a plugin's runtime context. new Exception(String.format( "The thread of this limbus service plugin (%s) was requested to stop but didn't respond in the allowed time.", this.getClass() .getName())).printStackTrace(); } super.finish(); }