package com.perforce.workshop.tjuricek.p4oauth.jetty; import com.perforce.p4java.server.IOptionsServer; import com.perforce.workshop.tjuricek.p4oauth.storage.IOptionsServerSupplier; import com.perforce.workshop.tjuricek.p4oauth.util.ThreadMemoizingSupplier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; /** * Should be the last handler called, which will release any allocated * IOptionsServer back into the thread pool. */ public class OptionsServerReleaseHandler extends AbstractHandler { private static final Logger logger = LogManager.getFormatterLogger(OptionsServerReleaseHandler.class); // It is assumed that the wrapped server here is the IOptionsServerSupplier private ThreadMemoizingSupplier<IOptionsServer> serverSupplier; public OptionsServerReleaseHandler(ThreadMemoizingSupplier<IOptionsServer> serverSupplier) { this.serverSupplier = serverSupplier; } @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (serverSupplier.getCached() != null) { IOptionsServerSupplier poolSupplier = (IOptionsServerSupplier)serverSupplier.getWrapped(); poolSupplier.release(serverSupplier.release()); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 9157 | tjuricek | Added basic "authorization code" workflow test. | ||
#1 | 9095 | tjuricek | Added some basic test data and renamed "workspace" to "workshop" in package name | ||
//guest/tjuricek/p4oauth/src/main/java/com/perforce/workspace/tjuricek/p4oauth/jetty/OptionsServerReleaseHandler.java | |||||
#1 | 9089 | tjuricek |
Moving some code that worked via some manual validation to the workshop. This just implements a basic code authorization grant scheme. Automated tests are forthcoming, awating some gradle plugin work that should sit outside of this project. |