View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.json.transformers;
8   
9   import org.mule.api.lifecycle.InitialisationException;
10  import org.mule.api.transformer.DiscoverableTransformer;
11  import org.mule.transformer.AbstractMessageTransformer;
12  
13  import org.codehaus.jackson.map.ObjectMapper;
14  
15  import java.util.HashMap;
16  import java.util.Map;
17  
18  /**
19   * TODO
20   */
21  public abstract class AbstractJsonTransformer extends AbstractMessageTransformer implements DiscoverableTransformer
22  {
23      protected int weighting = DiscoverableTransformer.MAX_PRIORITY_WEIGHTING;
24  
25      private ObjectMapper mapper;
26  
27      private Map<Class<?>, Class<?>> sharedMixins = new HashMap<Class<?>, Class<?>>();
28  
29      @Override
30      public void initialise() throws InitialisationException
31      {
32          if (mapper == null)
33          {
34              mapper = new ObjectMapper();
35          }
36      }
37  
38      public ObjectMapper getMapper()
39      {
40          return mapper;
41      }
42  
43      public void setMapper(ObjectMapper mapper)
44      {
45          this.mapper = mapper;
46      }
47  
48      public int getPriorityWeighting()
49      {
50          return weighting;
51      }
52  
53      public void setPriorityWeighting(int weighting)
54      {
55          this.weighting = weighting;
56      }
57  
58      public Map<Class<?>, Class<?>> getMixins()
59      {
60          return sharedMixins;
61      }
62  
63      public void setMixins(Map<Class<?>, Class<?>> mixins)
64      {
65          this.sharedMixins = mixins;
66      }
67  }