Пример #1
0
 /**
  * Extract and return service locator from {@link javax.ws.rs.core.FeatureContext featureContext}.
  * The method can be used to inject custom types into a {@link javax.ws.rs.core.Feature}.
  *
  * <p>Note that features are utilized during initialization phase when not all providers are
  * registered yet. It is undefined which injections are already available in this phase.
  *
  * @param featureContext Feature context.
  * @return Service locator.
  * @throws java.lang.IllegalArgumentException when {@code writerInterceptorContext} is not a
  *     default Jersey instance provided by Jersey in {@link
  *     javax.ws.rs.core.Feature#configure(javax.ws.rs.core.FeatureContext)} method.
  */
 public static ServiceLocator getServiceLocator(FeatureContext featureContext) {
   if (!(featureContext instanceof ServiceLocatorSupplier)) {
     throw new IllegalArgumentException(
         LocalizationMessages.ERROR_SERVICE_LOCATOR_PROVIDER_INSTANCE_FEATURE_CONTEXT(
             featureContext.getClass().getName()));
   }
   return ((ServiceLocatorSupplier) featureContext).getServiceLocator();
 }