This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
236 additions
and
57 deletions.
There are no files selected for viewing
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
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
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
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
44 changes: 44 additions & 0 deletions
44
...axrs.publisher/src/com/eclipsesource/jaxrs/publisher/internal/ServletContainerBridge.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.eclipsesource.jaxrs.publisher.internal; | ||
|
||
import javax.ws.rs.core.Request; | ||
|
||
import org.glassfish.jersey.server.ResourceConfig; | ||
import org.glassfish.jersey.servlet.ServletContainer; | ||
|
||
|
||
public class ServletContainerBridge implements Runnable { | ||
|
||
private final RootApplication application; | ||
private ServletContainer servletContainer; | ||
|
||
public ServletContainerBridge( RootApplication application ) { | ||
this.servletContainer = new ServletContainer( ResourceConfig.forApplication( application ) ); | ||
this.application = application; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
if( application.isDirty() ) { | ||
ClassLoader original = Thread.currentThread().getContextClassLoader(); | ||
try { | ||
Thread.currentThread().setContextClassLoader( Request.class.getClassLoader() ); | ||
getServletContainer().reload( ResourceConfig.forApplication( application ) ); | ||
} finally { | ||
Thread.currentThread().setContextClassLoader( original ); | ||
application.setDirty( false ); | ||
} | ||
} | ||
} | ||
|
||
public ServletContainer getServletContainer() { | ||
return servletContainer; | ||
} | ||
|
||
public void destroy() { | ||
servletContainer.destroy(); | ||
} | ||
|
||
public void reset() { | ||
this.servletContainer = new ServletContainer( ResourceConfig.forApplication( application ) ); | ||
} | ||
} |
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
Oops, something went wrong.