当前位置: 首页>>代码示例>>Java>>正文


Java FeatureContext类代码示例

本文整理汇总了Java中javax.ws.rs.core.FeatureContext的典型用法代码示例。如果您正苦于以下问题:Java FeatureContext类的具体用法?Java FeatureContext怎么用?Java FeatureContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FeatureContext类属于javax.ws.rs.core包,在下文中一共展示了FeatureContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {

	context.register(new AbstractBinder() {

		@Override
		protected void configure() {

			Injector injector = ClientGuiceBridgeFeature.getInjector(context.getConfiguration());
			ClientGuiceInjectInjector injectInjector = new ClientGuiceInjectInjector(injector);

			bind(injectInjector).to(new TypeLiteral<InjectionResolver<com.google.inject.Inject>>() {
			});
		}
	});

	return true;
}
 
开发者ID:bootique,项目名称:bootique-jersey-client,代码行数:19,代码来源:ClientGuiceBridgeFeature.java

示例2: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
  public boolean configure(final FeatureContext context) {
      
  	PluginLoader.INSTANCE.plugins.get().stream()
.filter(module -> module.jacksonFeatureProperties()!=null)
.map(Plugin::jacksonFeatureProperties)
.map(fn->fn.apply(context))
.forEach(map -> {
	addAll(map,context);
});
     
      
      JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
   		provider.setMapper(JacksonUtil.getMapper());
          context.register(provider, new Class[]{MessageBodyReader.class, MessageBodyWriter.class});
   
      return true;
  }
 
开发者ID:aol,项目名称:micro-server,代码行数:19,代码来源:JacksonFeature.java

示例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)) {
        //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

示例4: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public boolean configure(final FeatureContext featureContext) {
    final UserRepository userRepo = CDI.current().select(UserRepository.class).get();
    final Authenticator<String, User> authenticator = new GoogleAuthenticator(
            authConfig.getClientId(), userRepo, authConfig.getHostedDomain()
    );

    final Authenticator<String, User> cachingAuthenticator = new CachingAuthenticator<>(
            metricRegistry, authenticator, authConfig.getAuthenticationCachePolicy()
    );

    featureContext.register(new AuthDynamicFeature(
            new OAuthCredentialAuthFilter.Builder<User>()
            .setAuthenticator(cachingAuthenticator)
            .setPrefix("Bearer")
            .buildAuthFilter()));
    featureContext.register(new AuthValueFactoryProvider.Binder<>(User.class));

    return true;
}
 
开发者ID:PaperCutSoftware,项目名称:dust-api,代码行数:21,代码来源:AuthenticatorFeature.java

示例5: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {

    List<Annotation> authzSpecs = new ArrayList<>();

    Annotation classAuthzSpec =
        resourceInfo.getResourceClass().getAnnotation(AppkeyAnnotation.class);
    Annotation methodAuthzSpec =
        resourceInfo.getResourceMethod().getAnnotation(AppkeyAnnotation.class);

    if (classAuthzSpec != null)
        authzSpecs.add(classAuthzSpec);
    if (methodAuthzSpec != null)
        authzSpecs.add(methodAuthzSpec);

    if (!authzSpecs.isEmpty()) {
        context.register(AppkeyFilter.class);
    }
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:20,代码来源:AppkeyServiceFeature.java

示例6: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {

    List<Annotation> authzSpecs = new ArrayList<>();

    Annotation classAuthzSpec =
        resourceInfo.getResourceClass().getAnnotation(AuthAnnotation.class);
    Annotation methodAuthzSpec =
        resourceInfo.getResourceMethod().getAnnotation(AuthAnnotation.class);

    if (classAuthzSpec != null)
        authzSpecs.add(classAuthzSpec);
    if (methodAuthzSpec != null)
        authzSpecs.add(methodAuthzSpec);

    if (!authzSpecs.isEmpty()) {
        // 需要拦截的api
        context.register(AuthorizationFilter.class);
    }
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:21,代码来源:AuthServiceFeature.java

示例7: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
    CacheFor cc = resourceInfo.getResourceClass().getAnnotation(CacheFor.class);
    CacheFor mcc = resourceInfo.getResourceMethod().getAnnotation(CacheFor.class);
    if( mcc!=null ) {
        cc = mcc;
    }
    if (cc!=null) {
        if( cc.value() == 0 ) {
            context.register(NoCacheFilter.class);
        } else if( cc.value() > 0 ) {
            context.register(new CacheFilter("max-age= " + cc.unit().toSeconds(cc.value())));
        }
    } else {
        context.register(NoCacheFilter.class);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:18,代码来源:CacheForFilter.java

示例8: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
    if (context.getConfiguration().isEnabled(this.getClass())) {
        return false;
    }

    switch (context.getConfiguration().getRuntimeType()) {
    case SERVER:
        context.register(new ServerFilter(tracer));
        break;
    case CLIENT:
        context.register(new ClientFilter(tracer));
        break;
    default:
        LOGGER.error("Unknown runtime ({}), not registering Haystack feature", context.getConfiguration().getRuntimeType());
        return false;
    }
    return true;
}
 
开发者ID:ExpediaDotCom,项目名称:haystack-client-java,代码行数:20,代码来源:HaystackFeature.java

示例9: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
	if (context.getConfiguration().getProperties().containsKey(JacksonFeature.JAXRS_DISABLE_JACKSON_AUTO_CONFIG)) {
		LOGGER.debug(() -> "Skip JacksonJsonProvider registration, ["
				+ JacksonFeature.JAXRS_DISABLE_JACKSON_AUTO_CONFIG + "] property detected");
		return false;
	}

	if (!context.getConfiguration().isRegistered(JacksonJsonPropertyBoxProvider.class)) {
		LOGGER.debug(() -> "<Runtime: " + context.getConfiguration().getRuntimeType() + "> Registering provider ["
				+ JacksonJsonPropertyBoxProvider.class.getName() + "]");
		context.register(JacksonJsonPropertyBoxProvider.class);
	}
	return true;

}
 
开发者ID:holon-platform,项目名称:holon-json,代码行数:17,代码来源:JacksonProviderFeature.java

示例10: 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

示例11: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public boolean configure(final FeatureContext context) {
	PropertiesProvider propertiesProvider = new PropertiesProvider() {

		@Override
		public String getProperty(String key) {
			return (String) context.getConfiguration().getProperty(key);
		}
	};

	boot.setPropertiesProvider(propertiesProvider);
	boot.addModule(new JaxrsModule(securityContext));
	boot.boot();

	parameterProviderRegistry = buildParameterProviderRegistry();

	CrnkFilter crnkFilter = createCrnkFilter();
	context.register(crnkFilter);

	registerActionRepositories(context, boot);

	return true;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:24,代码来源:CrnkFeature.java

示例12: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
	// limit to SERVER runtime
	if (RuntimeType.SERVER == context.getConfiguration().getRuntimeType()) {

		// check disabled
		if (context.getConfiguration().getProperties().containsKey(DISABLE_AUTHENTICATION)) {
			LOGGER.debug(() -> "Skip AuthenticationFeature registration, [" + DISABLE_AUTHENTICATION
					+ "] property detected");
			return false;
		}

		if (!context.getConfiguration().isRegistered(AuthenticationDynamicFeature.class)) {
			context.register(AuthenticationDynamicFeature.class);
		}
		return true;
	}
	return false;
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:20,代码来源:AuthenticationFeature.java

示例13: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
    // 获取资源方法
    Method resourceMethod = resourceInfo.getResourceMethod();

    if (resourceMethod != null) {

        // 获取FormatJson注解
        ResponseFormat formatJson = resourceMethod.getAnnotation(ResponseFormat.class);

        if (formatJson == null || formatJson.type().equals(FormatType.JSON)) {
            context.register(DefaultWebFilter.class);
        }

    }
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:17,代码来源:DefaultFilterDynamicFeature.java

示例14: TestChain

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
public TestChain(TestServiceRunnerBase serviceRunner) {
    this.actions = ImmutableList.of();
    this.serviceLocator = new ServiceLocatorHolder();

    Feature lifecycleListener = new Feature() {
        @Inject
        public void setServiceLocator(ServiceLocator s) {
            serviceLocator.set(s);
        }

        @Override
        public boolean configure(FeatureContext context) {
            return false;
        }
    };
    this.serviceRunner = serviceRunner
            .serviceConfig(serviceRunner.getServiceConfig()
                    .registerInstance(lifecycleListener)
            );
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:21,代码来源:TestChain.java

示例15: configure

import javax.ws.rs.core.FeatureContext; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
	boolean modified = false;
	AccessControlAllowOriginRequestFilter accessControlAllowOriginRequestFilter = new AccessControlAllowOriginRequestFilter(
			originFilter);
	if (!context.getConfiguration().isRegistered(accessControlAllowOriginRequestFilter)) {
		context.register(accessControlAllowOriginRequestFilter);
		modified = true;
	}

	AccessControlAllowOriginResponseFilter accessControlAllowOriginResponseFilter = new AccessControlAllowOriginResponseFilter(
			originFilter);
	if (!context.getConfiguration().isRegistered(accessControlAllowOriginResponseFilter)) {
		context.register(accessControlAllowOriginResponseFilter);
		modified = true;
	}

	SimpleAccessControlAllowHeaderFilter simpleAccessControlAllowHeaderFilter = new SimpleAccessControlAllowHeaderFilter(
			allowedHeaders);
	if (!context.getConfiguration().isRegistered(simpleAccessControlAllowHeaderFilter)) {
		context.register(simpleAccessControlAllowHeaderFilter);
		modified = true;
	}
	return modified;
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:26,代码来源:CORSFeature.java


注:本文中的javax.ws.rs.core.FeatureContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。