本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}