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


Java PropertiesHelper类代码示例

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


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

示例1: JerseyApplication

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
@Inject
public JerseyApplication(ServiceLocator serviceLocator) {
	GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
	GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
    guiceBridge.bridgeGuiceInjector(AppLoader.injector);
    
    String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(
    		CommonProperties.MOXY_JSON_FEATURE_DISABLE,
               getConfiguration().getRuntimeType());
       property(disableMoxy, true);
       property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);

       // add the default Jackson exception mappers
       register(JsonParseExceptionMapper.class);
       register(JsonMappingExceptionMapper.class);
       register(JacksonJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
       
       packages(JerseyApplication.class.getPackage().getName());
       
    for (JerseyConfigurator configurator: AppLoader.getExtensions(JerseyConfigurator.class)) {
    	configurator.configure(this);
    }
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:24,代码来源:JerseyApplication.java

示例2: configure

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的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

示例3: registerJerseyJsonFeature

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的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

示例4: configure

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的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

示例5: getProperty

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
private String getProperty(String propertyName) {
    if (forcedPropertyMap.containsKey(propertyName)) {
        return forcedPropertyMap.get(propertyName);
    }

    final Properties systemProperties = AccessController.doPrivileged(PropertiesHelper.getSystemProperties());
    if (systemProperties.containsKey(propertyName)) {
        return systemProperties.getProperty(propertyName);
    }

    if (propertyMap.containsKey(propertyName)) {
        return propertyMap.get(propertyName);
    }

    return null;
}
 
开发者ID:Ellychou,项目名称:Todo-Jersey-Spring-MyBatis,代码行数:17,代码来源:SpringContextJerseyTest.java

示例6: getPort

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
/**
 * Get the port to be used for test application deployments.
 *
 * @return The HTTP port of the URI
 */
protected final int getPort() {
    final String value = AccessController.doPrivileged(PropertiesHelper.getSystemProperty(TestProperties.CONTAINER_PORT));
    if (value != null) {

        try {
            final int i = Integer.parseInt(value);
            if (i <= 0) {
                throw new NumberFormatException("Value not positive.");
            }
            return i;
        } catch (NumberFormatException e) {
            LOGGER.log(Level.CONFIG,
                    "Value of " + TestProperties.CONTAINER_PORT
                            + " property is not a valid positive integer [" + value + "]."
                            + " Reverting to default [" + TestProperties.DEFAULT_CONTAINER_PORT + "].",
                    e);
        }
    }
    return TestProperties.DEFAULT_CONTAINER_PORT;
}
 
开发者ID:Ellychou,项目名称:Todo-Jersey-Spring-MyBatis,代码行数:26,代码来源:SpringContextJerseyTest.java

示例7: SensorSafeOAuth1ServerFilter

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
/**
 * Create a new filter.
 * @param rc Resource config.
 */
@Inject
public SensorSafeOAuth1ServerFilter(Configuration rc) {
	// establish supported OAuth protocol versions
	HashSet<String> v = new HashSet<String>();
	v.add(null);
	v.add("1.0");
	versions = Collections.unmodifiableSet(v);

	// optional initialization parameters (defaulted)
	String realm = PropertiesHelper.getValue(rc.getProperties(), OAuth1ServerProperties.REALM, "default", String.class);
	/* Maximum age (in milliseconds) of timestamp to accept in incoming messages. */
	int maxAge = PropertiesHelper.getValue(rc.getProperties(), OAuth1ServerProperties.MAX_AGE, 300000);
	/* Average requests to process between nonce garbage collection passes. */
	int gcPeriod = PropertiesHelper.getValue(rc.getProperties(), OAuth1ServerProperties.GC_PERIOD, 100);
	ignorePathPattern = pattern(PropertiesHelper.getValue(rc.getProperties(), OAuth1ServerProperties.IGNORE_PATH_PATTERN,
			null, String.class)); // no pattern
	optional = PropertiesHelper.isProperty(rc.getProperties(), OAuth1ServerProperties.NO_FAIL);
	nonces = new NonceManager(maxAge, gcPeriod);

	// www-authenticate header for the life of the object
	wwwAuthenticateHeader = "OAuth realm=\"" + realm + "\"";
}
 
开发者ID:nesl,项目名称:SensorSafe,代码行数:27,代码来源:SensorSafeOAuth1ServerFilter.java

示例8: DrillRestServer

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
public DrillRestServer(final WorkManager workManager) {
  register(DrillRoot.class);
  register(StatusResources.class);
  register(StorageResources.class);
  register(ProfileResources.class);
  register(QueryResources.class);
  register(MetricsResources.class);
  register(ThreadsResources.class);
  register(FreemarkerMvcFeature.class);
  register(MultiPartFeature.class);
  property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);


  //disable moxy so it doesn't conflict with jackson.
  final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE, getConfiguration().getRuntimeType());
  property(disableMoxy, true);

  register(JsonParseExceptionMapper.class);
  register(JsonMappingExceptionMapper.class);
  register(GenericExceptionMapper.class);

  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  provider.setMapper(workManager.getContext().getConfig().getMapper());
  register(provider);

  register(new AbstractBinder() {
    @Override
    protected void configure() {
      bind(workManager).to(WorkManager.class);
      bind(workManager.getContext().getConfig().getMapper()).to(ObjectMapper.class);
      bind(workManager.getContext().getPersistentStoreProvider()).to(PStoreProvider.class);
      bind(workManager.getContext().getStorage()).to(StoragePluginRegistry.class);
    }
  });
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:36,代码来源:DrillRestServer.java

示例9: configure

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的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;
}
 
开发者ID:sorskod,项目名称:webserver,代码行数:32,代码来源:JsonJacksonFeature.java

示例10: init

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
protected void init(ScanResult result) {
  // FILTERS
  register(JSONPrettyPrintFilter.class);
  register(MediaTypeFilter.class);

  // RESOURCES
  for (Class<?> resource : result.getAnnotatedClasses(APIResource.class)) {
    register(resource);
  }

  // FEATURES
  register(DACAuthFilterFeature.class);
  register(DACJacksonJaxbJsonFeature.class);
  register(DACExceptionMapperFeature.class);

  // EXCEPTION MAPPERS
  register(JsonParseExceptionMapper.class);
  register(JsonMappingExceptionMapper.class);

  // PROPERTIES
  property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
  property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");

  final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
    getConfiguration().getRuntimeType());
  property(disableMoxy, true);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:APIServer.java

示例11: getSupportedExtensions

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
private static String[] getSupportedExtensions(final javax.ws.rs.core.Configuration config,
                                               final ServletContext servletContext) {
    String extension = FreemarkerMvcFeature.TEMPLATE_BASE_PATH + ".extensions";
    final Map<String, Object> properties = config.getProperties();
    String basePath = PropertiesHelper.getValue(properties, extension, String.class, null);
    if (StringUtils.isEmpty(basePath)) {
        return new String[]{"ftl"};
    }
    return basePath.split(",");
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:11,代码来源:FreemarkerViewProcessor.java

示例12: configure

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的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;
}
 
开发者ID:martinjmares,项目名称:javaone2015-cloudone,代码行数:32,代码来源:GsonFeature.java

示例13: PropertiesValueFactoryProvider

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
@Inject
public PropertiesValueFactoryProvider(MultivaluedParameterExtractorProvider mpep,
        ServiceLocator locator,
        Configuration configuration) {
    super(mpep, locator, Parameter.Source.UNKNOWN);
    this.serviceLocator = locator;
    this.i18nEnabled = PropertiesHelper.getValue(configuration.getProperties(),
            RuntimeType.SERVER, JerseyPropertiesFeature.ENABLE_I18N, false, null);
}
 
开发者ID:psamsotha,项目名称:jersey-properties,代码行数:10,代码来源:PropertiesValueFactoryProvider.java

示例14: AbstractTemplateProcessor

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
/**
 * <p>Constructor for AbstractTemplateProcessor.</p>
 *
 * @param config              a {@link javax.ws.rs.core.Configuration} object.
 * @param propertySuffix      a {@link java.lang.String} object.
 * @param supportedExtensions a {@link java.lang.String} object.
 */
public AbstractTemplateProcessor(Configuration config, String propertySuffix, String... supportedExtensions) {
    this.config = config;
    this.suffix = '.' + propertySuffix;
    Map<String, Object> properties = config.getProperties();
    String basePath = TemplateHelper.getBasePath(properties, propertySuffix);

    Collection<String> basePaths = TemplateHelper.getBasePaths(basePath);

    this.basePath = basePaths.toArray(new String[basePaths.size()]);

    Boolean cacheEnabled = PropertiesHelper.getValue(properties,
            MvcFeature.CACHE_TEMPLATES + this.suffix, Boolean.class, null);
    if (cacheEnabled == null) {
        cacheEnabled = PropertiesHelper.getValue(properties, MvcFeature.CACHE_TEMPLATES, false, null);
    }

    this.cache = cacheEnabled ? DataStructures.createConcurrentMap() : null;
    this.encoding = TemplateHelper.getTemplateOutputEncoding(config, this.suffix);

    this.supportedExtensions = Sets.newHashSet(Collections2.transform(
            Arrays.asList(supportedExtensions), input -> {
                input = input.toLowerCase();
                return input.startsWith(".") ? input : "." + input;
            }));

}
 
开发者ID:icode,项目名称:ameba,代码行数:34,代码来源:AbstractTemplateProcessor.java

示例15: DataViewMessageBodyWriter

import org.glassfish.jersey.internal.util.PropertiesHelper; //导入依赖的package包/类
/**
 * <p>Constructor for DataViewMessageBodyWriter.</p>
 *
 * @param application a {@link ameba.core.Application} object.
 */
@Inject
public DataViewMessageBodyWriter(Application application) {
    dataViewDisabled = "true".equals(application.getProperty(DISABLE_DATA_VIEW));
    defaultDataViewDisabled = "true".equals(application.getProperty(DISABLE_DEFAULT_DATA_VIEW));
    Map<String, Object> properties = application.getProperties();
    dataViewList = PropertiesHelper.getValue(properties, DATA_VIEW_LIST_KEY, DEFAULT_DATA_LIST, null);
    dataViewItem = PropertiesHelper.getValue(properties, DATA_VIEW_ITEM_KEY, DEFAULT_DATA_ITEM, null);
    dataViewNull = PropertiesHelper.getValue(properties, DATA_VIEW_NULL_KEY, DEFAULT_DATA_NULL, null);
}
 
开发者ID:icode,项目名称:ameba,代码行数:15,代码来源:DataViewMessageBodyWriter.java


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