View Javadoc

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