All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.atlassian.util.adapter.javax.servlet.jsp.JavaXJspApplicationContextAdapter Maven / Gradle / Ivy

Go to download

A collection of classes for adapting Servlet API 4.0 objects to Servlet API 5.0 and vice versa.

There is a newer version: 0.1.0
Show newest version
package io.atlassian.util.adapter.javax.servlet.jsp;

import io.atlassian.util.adapter.jakarta.el.JakartaELContextListenerAdapter;
import io.atlassian.util.adapter.jakarta.servlet.jsp.JakartaJspApplicationContextAdapter;
import io.atlassian.util.adapter.javax.el.JavaXExpressionFactoryAdapter;

import javax.el.ELContextListener;
import javax.el.ELResolver;
import javax.el.ExpressionFactory;
import javax.servlet.jsp.JspApplicationContext;

import static io.atlassian.util.adapter.util.WrapperUtil.applyIfNonNull;
import static java.util.Objects.requireNonNull;

public class JavaXJspApplicationContextAdapter implements JspApplicationContext {

    private final jakarta.servlet.jsp.JspApplicationContext delegate;

    public static JspApplicationContext from(jakarta.servlet.jsp.JspApplicationContext delegate) {
        if (delegate instanceof JakartaJspApplicationContextAdapter castDelegate) {
            return castDelegate.getDelegate();
        }
        return applyIfNonNull(delegate, JavaXJspApplicationContextAdapter::new);
    }

    JavaXJspApplicationContextAdapter(jakarta.servlet.jsp.JspApplicationContext delegate) {
        this.delegate = requireNonNull(delegate);
    }

    public jakarta.servlet.jsp.JspApplicationContext getDelegate() {
        return delegate;
    }

    @Override
    public void addELResolver(ELResolver resolver) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public ExpressionFactory getExpressionFactory() {
        return JavaXExpressionFactoryAdapter.from(delegate.getExpressionFactory());
    }

    @Override
    public void addELContextListener(ELContextListener listener) {
        delegate.addELContextListener(JakartaELContextListenerAdapter.from(listener));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy