Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2014. Escalon System-Entwicklung, Dietrich Schulten
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  */
package de.escalon.hypermedia.spring.de.escalon.hypermedia.spring.jackson;
Jackson Module which applies json-ld serialization to Spring Hateoas responses. Created by dschulten on 14.09.2014.
public class JacksonHydraModule extends SimpleModule {
    public JacksonHydraModule() {
        super("json-hydra-module"new Version(1, 0, 0, null"de.escalon.hypermedia""hydra-spring"));
        setMixInAnnotation(Resources.classResourcesMixin.class);
        setMixInAnnotation(Resource.classResourceMixin.class);
        addSerializer(Resource.classnew ResourceSerializer());
    }
    public void setupModule(SetupContext context) {
        super.setupModule(context);
        context.addBeanSerializerModifier(new BeanSerializerModifier() {
            public JsonSerializer<?> modifySerializer(
                    SerializationConfig config,
                    BeanDescription beanDesc,
                    JsonSerializer<?> serializer) {
                if (serializer instanceof BeanSerializerBase) {
                    return new JacksonHydraSerializer(
                            (BeanSerializerBaseserializer);
                } else {
                    return serializer;
                }
            }
        });
    }
New to GrepCode? Check out our FAQ X