Last active
October 31, 2015 17:03
-
-
Save hsyed/76573e255c8de6d2f83b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void run() { | |
if( application.isDirty() ) { | |
ClassLoader original = Thread.currentThread().getContextClassLoader(); | |
try { | |
Thread.currentThread().setContextClassLoader( Request.class.getClassLoader() ); | |
synchronized( this ) { | |
if( !isJerseyReady() ) { | |
Activator.logger.info("Initializing JAX-RS Container."); | |
// if jersey has not been initialized - use the init method | |
getServletContainer().init( servletConfig ); | |
Activator.logger.info("JAX-RS Container initialized."); | |
} else { | |
// otherwise reload | |
isJerseyReady = false; | |
getServletContainer().reload( ResourceConfig.forApplication( application ) ); | |
} | |
isJerseyReady = true; | |
} | |
} catch(Throwable t) { | |
handleTerminalError(t); | |
} finally { | |
Thread.currentThread().setContextClassLoader( original ); | |
} | |
} | |
} | |
private void handleTerminalError(Throwable t) { | |
Activator.logger.error("Error during JAX-RS Container initialization. Taking bundle down.", t); | |
try { | |
FrameworkUtil.getBundle(this.getClass()).stop(); | |
} catch (BundleException e) { | |
e.printStackTrace(); | |
Activator.logger.error("error during bundle teardown", e); | |
throw new RuntimeException(e); | |
} | |
throw new RuntimeException(t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment