當前位置: 首頁>>代碼示例>>Java>>正文


Java FeatureContext.getConfiguration方法代碼示例

本文整理匯總了Java中javax.ws.rs.core.FeatureContext.getConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java FeatureContext.getConfiguration方法的具體用法?Java FeatureContext.getConfiguration怎麽用?Java FeatureContext.getConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.core.FeatureContext的用法示例。


在下文中一共展示了FeatureContext.getConfiguration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    final String jsonFeature = CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), InternalProperties.JSON_FEATURE, JSON_FEATURE,
            String.class);
    // Other JSON providers registered.
    if (!JSON_FEATURE.equalsIgnoreCase(jsonFeature)) {
        return false;
    }
    // Disable other JSON providers.
    context.property(PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()), JSON_FEATURE);
    // Register FastJson.
    if (!config.isRegistered(FastJsonProvider.class)) {
        //DisableCircularReferenceDetect
        FastJsonProvider fastJsonProvider = new FastJsonProvider();
        FastJsonConfig fastJsonConfig = new FastJsonConfig();
        //fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.BrowserSecure);

        fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);

        fastJsonProvider.setFastJsonConfig(fastJsonConfig);

        context.register(fastJsonProvider, MessageBodyReader.class, MessageBodyWriter.class);
    }
    return true;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:Issue1341.java

示例2: registerJerseyJsonFeature

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
/**
 * Register a Jersey JSON provider feature only if another JSON provider is not already registered, checking
 * {@link #JERSEY_JSON_PROVIDER_PROPERTY} property value.
 * @param context Feature context
 * @param feature Feature to register
 * @param featureName Feature name to register
 * @return <code>true</code> if feature was registered, <code>false</code> otherwise
 */
private static boolean registerJerseyJsonFeature(FeatureContext context, Class<? extends Feature> feature,
		String featureName) {
	final Configuration config = context.getConfiguration();

	final String jsonFeature = CommonProperties.getValue(config.getProperties(), config.getRuntimeType(),
			JERSEY_JSON_PROVIDER_PROPERTY, featureName, String.class);
	if (!featureName.equalsIgnoreCase(jsonFeature)) {
		// Other JSON providers registered
		return false;
	}
	// Disable other JSON providers
	context.property(
			PropertiesHelper.getPropertyNameForRuntime(JERSEY_JSON_PROVIDER_PROPERTY, config.getRuntimeType()),
			featureName);
	// Register
	if (!config.isRegistered(feature)) {
		context.register(feature);
	}
	return true;
}
 
開發者ID:holon-platform,項目名稱:holon-json,代碼行數:29,代碼來源:GsonAutoDiscoverable.java

示例3: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(FeatureContext context) {
  Configuration configuration = context.getConfiguration();
  Boolean enabled = PropertyHelper.getProperty(configuration, RestServerV2.FIRST_TIME_API_ENABLE);
  Boolean testApiEnabled = PropertyHelper.getProperty(configuration, RestServerV2.TEST_API_ENABLE);

  // Default is not enabled
  if (enabled == null || !enabled) {
    return false;
  }

  boolean allowTestApis = testApiEnabled != null && testApiEnabled;

  // this is handled separately from firstTimeApi because we may enable the api only on master
  // but still register the filer on all nodes
  context.register(BootstrapResource.class);
  if (allowTestApis) {
    context.register(NoUserTestFilter.class);
  } else {
    context.register(NoUserFilter.class);
  }

  return true;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:25,代碼來源:FirstTimeFeature.java

示例4: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(FeatureContext context) {
  Configuration configuration = context.getConfiguration();
  Boolean enabled = PropertyHelper.getProperty(configuration, RestServerV2.TEST_API_ENABLE);

  // Default is not enabled
  if (enabled == null || !enabled) {
    return false;
  }

  for (Class<?> resource : scanResult.getAnnotatedClasses(RestResourceUsedForTesting.class)) {
    context.register(resource);
  }

  return true;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:17,代碼來源:TestResourcesFeature.java

示例5: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(FeatureContext context) {
  final Configuration configuration = context.getConfiguration();

  Boolean disabled = PropertyHelper.getProperty(configuration, RestServerV2.DAC_AUTH_FILTER_DISABLE);
  // Default is not disabled
  if (disabled != null && disabled) {
    return false;
  }

  context.register(DACAuthFilter.class);
  if (!configuration.isRegistered(RolesAllowedDynamicFeature.class)) {
    context.register(RolesAllowedDynamicFeature.class);
  }
  return true;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:17,代碼來源:DACAuthFilterFeature.java

示例6: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
public boolean configure(final FeatureContext context) {
	final Configuration config = context.getConfiguration();
	final String jsonFeature = CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), InternalProperties.JSON_FEATURE, JSON_FEATURE,
			String.class);
	// Other JSON providers registered.
	if (!JSON_FEATURE.equalsIgnoreCase(jsonFeature)) {
		return false;
	}
	// Disable other JSON providers.
	context.property(PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()), JSON_FEATURE);
	// Register FastJson.
	if (!config.isRegistered(FastJsonProvider.class)) {
		context.register(FastJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
	}
	return true;
}
 
開發者ID:ChineseLincoln,項目名稱:JerseyRestful,代碼行數:17,代碼來源:FastJsonFeature.java

示例7: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public void configure(FeatureContext context) {
    final int priorityInc = 3000;

    // Jersey MOXY provider have higher priority(7000), so we need set higher than it
    int priority = Priorities.USER + priorityInc;
    Configuration config = context.getConfiguration();

    if (!config.isRegistered(ParsecValidationExceptionMapper.class)) {
        context.register(ParsecValidationExceptionMapper.class, priority);
    }
    if (!config.isRegistered(ValidationConfigurationContextResolver.class)) {
        context.register(ValidationConfigurationContextResolver.class, priority);
    }
    if (!config.isRegistered(ParsecMoxyProvider.class)) {
        context.register(ParsecMoxyProvider.class, priority);
    }
    if (!config.isRegistered(JaxbExceptionMapper.class)) {
        context.register(JaxbExceptionMapper.class, priority);
    }
}
 
開發者ID:yahoo,項目名稱:parsec-libraries,代碼行數:22,代碼來源:ParsecValidationAutoDiscoverable.java

示例8: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(FeatureContext context) {
    Configuration configuration = context.getConfiguration();
    if (!configuration.isRegistered(ConfigPropertyResolver.class)) {
        LOGGER.debug("Register ConfigPropertyFeature");
        context.register(ConfigPropertyResolver.class);
        context.register(new AbstractBinder() {
            @Override
            protected void configure() {
                bind(ConfigPropertyResolver.class)
                        .to(new TypeLiteral<InjectionResolver<ConfigProperty>>() {})
                        .in(Singleton.class);
            }
        });
    }
    return true;
}
 
開發者ID:protoxme,項目名稱:protox-webapp-archetype,代碼行數:18,代碼來源:ConfigPropertyFeature.java

示例9: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();

    if (!config.isRegistered(VelocityViewProcessor.class)) {
        // Template Processor.
        context.register(VelocityViewProcessor.class);

        // MvcFeature.
        if (!config.isRegistered(MvcFeature.class)) {
            context.register(MvcFeature.class);
        }

        return true;
    }
    return false;
}
 
開發者ID:Feng-Zihao,項目名稱:jersey-mvc-velocity,代碼行數:18,代碼來源:VelocityMvcFeature.java

示例10: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();

    if (!config.isRegistered(FreemarkerViewProcessor.class)) {
        // Template Processor.
        context.register(FreemarkerViewProcessor.class);

        // MvcFeature.
        if (!config.isRegistered(MvcFeature.class)) {
            context.register(MvcFeature.class);
        }

        return true;
    }
    return false;
}
 
開發者ID:xuegongzi,項目名稱:rabbitframework,代碼行數:18,代碼來源:FreemarkerMvcFeature.java

示例11: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
/**
     * Property defines output encoding produced by
     * {@link org.glassfish.jersey.server.mvc.spi.TemplateProcessor}. The value
     * must be a valid encoding defined that can be passed to the
     * {@link java.nio.charset.Charset#forName(String)} method.
     *
     * <p/>
     * The default value is {@code UTF-8}.
     * <p/>
     * The name of the configuration property is <tt>{@value}</tt>.
     * <p/>
     *
     * @param context
     * @return 
     */
//    public static final String ENCODING = MvcFeature.ENCODING + SUFFIX;
    @Override
    public boolean configure(final FeatureContext context) {
        final Configuration config = context.getConfiguration();

        if (!config.isRegistered(JasperViewProcessor.class)) {
            // Template Processor.
            context.register(JasperViewProcessor.class);

            // MvcFeature.
            if (!config.isRegistered(MvcFeature.class)) {
                context.register(MvcFeature.class);
            }

            return true;
        }
        return false;
    }
 
開發者ID:marcosvpcortes,項目名稱:jersey-mvc-jasper,代碼行數:34,代碼來源:JasperMvcFeature.java

示例12: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public boolean configure(FeatureContext context) {
    Configuration configuration = context.getConfiguration();
    if (!configuration.isRegistered(UriConnegFilter.class)) {
        context.register(UriConnegFilter.class, Priorities.AUTHENTICATION - 100);
    }

    if (!context.getConfiguration().isRegistered(DownloadEntityFilter.class)) {
        context.register(DownloadEntityFilter.class);
    }

    if (!configuration.isRegistered(LoadBalancerRequestFilter.class)) {
        context.register(LoadBalancerRequestFilter.class);
    }
    return true;
}
 
開發者ID:icode,項目名稱:ameba,代碼行數:20,代碼來源:SysFilteringFeature.java

示例13: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();

    if (!config.isRegistered(EntityFieldsProcessor.class)) {

        // register EntityFilteringFeature
        if (!config.isRegistered(EntityFilteringFeature.class)) {
            context.register(EntityFilteringFeature.class);
        }
        // Entity Processors.
        context.register(EntityFieldsProcessor.class);
        // Scope Resolver.
        context.register(EntityFieldsScopeResolver.class);

        return true;
    }
    return false;
}
 
開發者ID:icode,項目名稱:ameba,代碼行數:23,代碼來源:EntityFieldsFilteringFeature.java

示例14: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public void configure(final FeatureContext context) {

    final Configuration config = context.getConfiguration();

    // Register FastJson.
    if (!config.isRegistered(FastJsonFeature.class) && autoDiscover) {

        context.register(FastJsonFeature.class);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:FastJsonAutoDiscoverable.java

示例15: configure

import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
public boolean configure(FeatureContext context) {
    context.property("jersey.config.server.disableMoxyJson", Boolean.valueOf(true));
    Configuration config = context.getConfiguration();
    context.property(getPropertyNameForRuntime("jersey.config.jsonFeature", config.getRuntimeType()), JSON_FEATURE);
    if (!config.isRegistered(JacksonJaxbJsonProvider.class)) {
        context.register(JsonParseExceptionMapper.class);
        context.register(JsonMappingExceptionMapper.class);
        context.register(JacksonJaxbJsonProvider.class, new Class[]{MessageBodyReader.class, MessageBodyWriter.class});
    }

    return true;
}
 
開發者ID:igorzg,項目名稱:payara-micro-docker-starter-kit,代碼行數:13,代碼來源:JacksonFeature.java


注:本文中的javax.ws.rs.core.FeatureContext.getConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。