Search in sources :

Example 1 with SerializerConfig

use of com.google.api.server.spi.config.model.ApiSerializationConfig.SerializerConfig in project endpoints-java by cloudendpoints.

the class SystemService method registerLoadedService.

private int registerLoadedService(Class<?> serviceClass, Object service, ApiConfig apiConfig) throws ApiConfigException {
    String fullName = serviceClass.getName();
    if (!servicesByName.containsKey(fullName)) {
        // TODO: The bit below uses two maps to store per-API serialization configurations.
        // The first map maps service names to an api-version key, and the second map maps the key to
        // a serialization config. This is currently required because the API information is not kept
        // outside of this method, but it would be nice to find a better way to clean this up.
        String api = apiConfig.getName() + "-" + apiConfig.getVersion();
        initialConfigsByApi.put(api, apiConfig);
        ApiSerializationConfig serializationConfig = serializationConfigs.get(api);
        if (serializationConfig == null) {
            serializationConfig = new ApiSerializationConfig();
        }
        for (SerializerConfig rule : apiConfig.getSerializationConfig().getSerializerConfigs()) {
            serializationConfig.addSerializationConfig(rule.getSerializer());
        }
        serializationConfigs.put(api, serializationConfig);
        registerServiceFromName(service, serviceClass.getSimpleName(), api);
        registerServiceFromName(service, fullName, api);
        updateEndpointConfig(service, apiConfig, null);
        return apiConfig.getApiClassConfig().getMethods().size();
    }
    return DUPLICATE_SERVICE_REGISTER_COUNT;
}
Also used : SerializerConfig(com.google.api.server.spi.config.model.ApiSerializationConfig.SerializerConfig) ApiSerializationConfig(com.google.api.server.spi.config.model.ApiSerializationConfig)

Aggregations

ApiSerializationConfig (com.google.api.server.spi.config.model.ApiSerializationConfig)1 SerializerConfig (com.google.api.server.spi.config.model.ApiSerializationConfig.SerializerConfig)1