org.glassfish.jersey.server.internal.inject.AbstractContainerRequestValueFactory Java Examples

The following examples show how to use org.glassfish.jersey.server.internal.inject.AbstractContainerRequestValueFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RateLimitBundle.java    From ratelimitj with Apache License 2.0 5 votes vote down vote up
@Override
protected Factory<RequestRateLimiterFactory> createValueFactory(final Parameter parameter) {
    final RateLimiting annotation = parameter.getAnnotation(RateLimiting.class);
    if (null == annotation) {
        return null;
    } else {
        return new AbstractContainerRequestValueFactory<RequestRateLimiterFactory>() {
            @Override
            public RequestRateLimiterFactory provide() {
                return requestRateLimiterFactory;
            }
        };
    }
}
 
Example #2
Source File: RateLimit429EnforcerFilterTest.java    From ratelimitj with Apache License 2.0 5 votes vote down vote up
@Override
protected Factory<?> createValueFactory(final Parameter parameter) {
    final RateLimiting annotation = parameter.getAnnotation(RateLimiting.class);
    if (null == annotation) {
        return null;
    } else {
        return new AbstractContainerRequestValueFactory<RequestRateLimiterFactory>() {
            @Override
            public RequestRateLimiterFactory provide() {
                return requestRateLimiterFactory;
            }
        };
    }
}
 
Example #3
Source File: AuthResolver.java    From keywhiz with Apache License 2.0 5 votes vote down vote up
@Override protected Factory<?> createValueFactory(final Parameter parameter) {
  final Class<?> classType = parameter.getRawType();
  final Auth auth = parameter.getAnnotation(Auth.class);

  if (auth == null) {
    return null;
  }

  if (classType.equals(Client.class)) {
    return new AbstractContainerRequestValueFactory<Client>() {
      @Override public Client provide() {
        return clientAuthFactory.provide(getContainerRequest());
      }
    };
  }

  if (classType.equals(AutomationClient.class)) {
    return new AbstractContainerRequestValueFactory<AutomationClient>() {
      @Override public AutomationClient provide() {
        return automationClientAuthFactory.provide(getContainerRequest());
      }
    };
  }

  if (classType.equals(User.class)) {
    return new AbstractContainerRequestValueFactory<User>() {
      @Override public User provide() {
        return userAuthFactory.provide(getContainerRequest());
      }
    };
  }

  return null;
}
 
Example #4
Source File: AuthValueFactoryProvider.java    From dropwizard-simpleauth with Apache License 2.0 5 votes vote down vote up
@Override
public AbstractContainerRequestValueFactory<?> createValueFactory(final Parameter parameter) {
  if (parameter.getAnnotation(Auth.class) == null) {
    return null;
  }

  if (parameter.getRawType() == Optional.class) {
    return new OptionalContainerRequestValueFactory(parameter);
  } else {
    return new StandardContainerReqeustValueFactory(parameter);
  }
}
 
Example #5
Source File: DummyAuth.java    From dropwizard-experiment with MIT License 5 votes vote down vote up
@Override
protected Factory<?> createValueFactory(Parameter parameter) {
    if (!parameter.isAnnotationPresent(Auth.class)) {
        return null;
    }

    return new AbstractContainerRequestValueFactory<Principal>() {
        public Principal provide() {
            return user;
        }
    };
}