io.atlassian.util.adapter.jakarta.servlet.http.JakartaHttpUpgradeHandlerAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jakarta-adapters Show documentation
Show all versions of jakarta-adapters Show documentation
A collection of classes for adapting Servlet API 4.0 objects to Servlet API 5.0 and vice versa.
package io.atlassian.util.adapter.jakarta.servlet.http;
import io.atlassian.util.adapter.javax.servlet.http.JavaXHttpUpgradeHandlerAdapter;
import io.atlassian.util.adapter.javax.servlet.http.JavaXWebConnectionAdapter;
import jakarta.servlet.http.HttpUpgradeHandler;
import jakarta.servlet.http.WebConnection;
import static io.atlassian.util.adapter.util.WrapperUtil.applyIfNonNull;
import static java.util.Objects.requireNonNull;
public class JakartaHttpUpgradeHandlerAdapter implements HttpUpgradeHandler {
private final javax.servlet.http.HttpUpgradeHandler delegate;
public static HttpUpgradeHandler from(javax.servlet.http.HttpUpgradeHandler delegate) {
if (delegate instanceof JavaXHttpUpgradeHandlerAdapter castDelegate) {
return castDelegate.getDelegate();
}
return applyIfNonNull(delegate, JakartaHttpUpgradeHandlerAdapter::new);
}
JakartaHttpUpgradeHandlerAdapter(javax.servlet.http.HttpUpgradeHandler delegate) {
this.delegate = requireNonNull(delegate);
}
public javax.servlet.http.HttpUpgradeHandler getDelegate() {
return delegate;
}
@Override
public void init(WebConnection wc) {
delegate.init(JavaXWebConnectionAdapter.from(wc));
}
@Override
public void destroy() {
delegate.destroy();
}
}