本文整理匯總了Java中javax.ws.rs.core.FeatureContext.property方法的典型用法代碼示例。如果您正苦於以下問題:Java FeatureContext.property方法的具體用法?Java FeatureContext.property怎麽用?Java FeatureContext.property使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ws.rs.core.FeatureContext
的用法示例。
在下文中一共展示了FeatureContext.property方法的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包/類
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;
}
示例4: applyInternalCommonConfig
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
private void applyInternalCommonConfig(FeatureContext context, InternalCommonConfig internalCommonConfig)
{
for ( Class<?> clazz : internalCommonConfig.getClasses() )
{
log.info(String.format("Registering %s as a component", clazz));
context.register(clazz);
}
for ( Object obj : internalCommonConfig.getInstances() )
{
log.info(String.format("Registering instance of %s as a component", obj.getClass()));
context.register(obj);
}
for ( Map.Entry<String, Object> entry : internalCommonConfig.getProperties().entrySet() )
{
String key = entry.getKey();
Object value = entry.getValue();
log.info(String.format("Registering property key: %s\tvalue: %s", key, value));
context.property(key, value);
}
}
示例5: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
Class<?> resourceClass = resourceInfo.getResourceClass();
Method method = resourceInfo.getResourceMethod();
logger.info("getResourceClass: " + resourceClass);
logger.info("getResourceMethod: " + method);
context.property("new_dynamic_feature", resourceClass + "|" + method);
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:9,代碼來源:MyResourceSingleton.java
示例6: 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;
}
示例7: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(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 Jackson.
if (!config.isRegistered(JacksonJaxbJsonProvider.class)) {
// add the Jackson exception mappers with application/json output
context.register(JsonMappingExceptionMapper.class);
context.register(JsonParseExceptionMapper.class);
if (EntityFilteringFeature.enabled(config)) {
context.register(JacksonFilteringFeature.class);
context.register(FilteringJacksonJaxbJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
} else {
context.register(JacksonJaxbJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
}
}
return true;
}
示例8: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(FeatureContext context) {
final Configuration config = context.getConfiguration();
context.property("jersey.config." + config.getRuntimeType().toString().toLowerCase(Locale.ENGLISH) + ".jsonFeature", "JacksonFeature");
context.register(JsonParseExceptionMapper.class, Priorities.ENTITY_CODER);
context.register(JsonMappingExceptionMapper.class, Priorities.ENTITY_CODER);
context.register(JacksonJsonProviderForJsonMediaType.class, Priorities.ENTITY_CODER);
return true;
}
示例9: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(FeatureContext context) {
final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.'
+ context.getConfiguration().getRuntimeType().name().toLowerCase();
context.property(disableMoxy, true);
// add the default Jackson exception mappers
context.register(JsonParseExceptionMapper.class);
context.register(JsonMappingExceptionMapper.class);
context.register(JacksonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
return true;
}
示例10: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
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.
String propName = PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE,
config.getRuntimeType());
context.property(propName, JSON_FEATURE);
// Register
context.register(GsonProvider.class);
if (gsonBuilder != null) {
context.register(new ContextResolver<GsonBuilder>() {
@Override
public GsonBuilder getContext(Class type) {
return gsonBuilder;
}
});
}
return true;
}
示例11: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(final FeatureContext context) {
final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.' + context.getConfiguration().getRuntimeType().name().toLowerCase();
context.property(disableMoxy, true);
context.register(new JacksonJaxbJsonProvider(mapper, DEFAULT_ANNOTATIONS), MessageBodyReader.class, MessageBodyWriter.class);
return true;
}
示例12: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(final FeatureContext context) {
final Configuration config = context.getConfiguration();
//client side only configuration
if (RuntimeType.CLIENT == config.getRuntimeType()) {
if (!config.isRegistered(JWSJerseyFilter.class)){
context.property(JWSJerseyFilter.JWS_FILTER_KEY, key);
context.register(JWSJerseyFilter.class);
return true;
}
}
return false;
}
示例13: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public boolean configure(final FeatureContext context) {
// disable Jersey default BeanValidation feature
context.property(ServerProperties.BV_FEATURE_DISABLE, "true");
context.register(new ValidationBinder())
.register(ValidationExceptionMapper.class)
.register(ValidationConfigurationContextResolver.class);
return true;
}
示例14: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
public boolean configure(FeatureContext context) {
// this gives everyone access to the LinkRest services
context.property(LinkRestRuntime.LINK_REST_CONTAINER_PROPERTY, injector);
@SuppressWarnings("unchecked")
Map<String, Class> bodyWriters =
injector.getInstance(Key.getMapOf(String.class, Class.class, LinkRestRuntime.BODY_WRITERS_MAP));
for (Class<?> type : bodyWriters.values()) {
context.register(type);
}
context.register(ResponseStatusDynamicFeature.class);
context.register(EntityUpdateReader.class);
context.register(EntityUpdateCollectionReader.class);
for (Class<?> c : extraComponents) {
context.register(c);
}
for (Feature f : extraFeatures) {
f.configure(context);
}
return true;
}
示例15: configure
import javax.ws.rs.core.FeatureContext; //導入方法依賴的package包/類
@Override
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;
}