// Path: core/src/main/java/org/pac4j/jax/rs/features/JaxRsContextFactoryProvider.java
// public class JaxRsContextFactoryProvider implements ContextResolver<JaxRsContextFactory> {
// 
//     @Context
//     private Providers providers;
// 
//     @Override
//     public JaxRsContextFactory getContext(Class<?> type) {
//         return context -> new JaxRsContext(getProviders(), context, getConfig().getSessionStore());
//     }
// 
//     protected Providers getProviders() {
//         assert providers != null;
//         return providers;
//     }
// 
//     protected Config getConfig() {
//         return new ProvidersContext(providers).resolveNotNull(Config.class);
//     }
// 
//     /**
//      * We need to provide a factory because it is not possible to get the {@link ContainerRequestContext} injected
//      * directly here...
//      */
//     @FunctionalInterface
//     public interface JaxRsContextFactory {
//         JaxRsContext provides(ContainerRequestContext context);
//     }
// }
// 
// Path: jersey228/src/main/java/org/pac4j/jax/rs/grizzly/pac4j/GrizzlyJaxRsContext.java
// public class GrizzlyJaxRsContext extends JaxRsContext {
// 
//     private final Request request;
// 
//     public GrizzlyJaxRsContext(Providers providers, ContainerRequestContext requestContext,
//             SessionStore sessionStore, Request request) {
//         super(providers, requestContext, sessionStore != null ? sessionStore : new GrizzlySessionStore());
//         this.request = request;
//     }
// 
//     public Request getRequest() {
//         return request;
//     }
// 
//     @Override
//     public String getRemoteAddr() {
//         return request.getRemoteAddr();
//     }
// }


import org.glassfish.grizzly.http.server.Request;
import org.pac4j.jax.rs.features.JaxRsContextFactoryProvider;
import org.pac4j.jax.rs.grizzly.pac4j.GrizzlyJaxRsContext;
import javax.inject.Inject;
import javax.inject.Provider;
package org.pac4j.jax.rs.grizzly.features;



/**
 * 
 * Extends {@link JaxRsContextFactoryProvider} to support the Grizzly container (without the need for servlet support)
 * and its session manager (i.e., pac4j indirect clients will work, contrary than with
 * {@link JaxRsContextFactoryProvider}).
 * 
 * @see JaxRsContextFactoryProvider
 * @author Victor Noel - Linagora
 * @since 1.0.0
 *
 */
public class GrizzlyJaxRsContextFactoryProvider extends JaxRsContextFactoryProvider {

    @Inject
    protected Provider<Request> requestProvider;

    @Override
    public JaxRsContextFactory getContext(Class<?> type) {
        Request request = requestProvider.get();
        assert request != null;
// Path: core/src/main/java/org/pac4j/jax/rs/features/JaxRsContextFactoryProvider.java
// public class JaxRsContextFactoryProvider implements ContextResolver<JaxRsContextFactory> {
// 
//     @Context
//     private Providers providers;
// 
//     @Override
//     public JaxRsContextFactory getContext(Class<?> type) {
//         return context -> new JaxRsContext(getProviders(), context, getConfig().getSessionStore());
//     }
// 
//     protected Providers getProviders() {
//         assert providers != null;
//         return providers;
//     }
// 
//     protected Config getConfig() {
//         return new ProvidersContext(providers).resolveNotNull(Config.class);
//     }
// 
//     /**
//      * We need to provide a factory because it is not possible to get the {@link ContainerRequestContext} injected
//      * directly here...
//      */
//     @FunctionalInterface
//     public interface JaxRsContextFactory {
//         JaxRsContext provides(ContainerRequestContext context);
//     }
// }
// 
// Path: jersey228/src/main/java/org/pac4j/jax/rs/grizzly/pac4j/GrizzlyJaxRsContext.java
// public class GrizzlyJaxRsContext extends JaxRsContext {
// 
//     private final Request request;
// 
//     public GrizzlyJaxRsContext(Providers providers, ContainerRequestContext requestContext,
//             SessionStore sessionStore, Request request) {
//         super(providers, requestContext, sessionStore != null ? sessionStore : new GrizzlySessionStore());
//         this.request = request;
//     }
// 
//     public Request getRequest() {
//         return request;
//     }
// 
//     @Override
//     public String getRemoteAddr() {
//         return request.getRemoteAddr();
//     }
// }


// Path: jersey228/src/main/java/org/pac4j/jax/rs/grizzly/features/GrizzlyJaxRsContextFactoryProvider.java
import org.glassfish.grizzly.http.server.Request;
import org.pac4j.jax.rs.features.JaxRsContextFactoryProvider;
import org.pac4j.jax.rs.grizzly.pac4j.GrizzlyJaxRsContext;
import javax.inject.Inject;
import javax.inject.Provider;

package org.pac4j.jax.rs.grizzly.features;



/**
 * 
 * Extends {@link JaxRsContextFactoryProvider} to support the Grizzly container (without the need for servlet support)
 * and its session manager (i.e., pac4j indirect clients will work, contrary than with
 * {@link JaxRsContextFactoryProvider}).
 * 
 * @see JaxRsContextFactoryProvider
 * @author Victor Noel - Linagora
 * @since 1.0.0
 *
 */
public class GrizzlyJaxRsContextFactoryProvider extends JaxRsContextFactoryProvider {

    @Inject
    protected Provider<Request> requestProvider;

    @Override
    public JaxRsContextFactory getContext(Class<?> type) {
        Request request = requestProvider.get();
        assert request != null;
        return context -> new GrizzlyJaxRsContext(getProviders(), context, getConfig().getSessionStore(), request);