View Javadoc

1   /*
2    * $Id: AbstractJsonTransformer.java 19250 2010-08-30 16:53:14Z dirk.olmes $
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  package org.mule.module.json.transformers;
11  
12  import org.mule.api.lifecycle.InitialisationException;
13  import org.mule.api.transformer.DiscoverableTransformer;
14  import org.mule.transformer.AbstractMessageTransformer;
15  
16  import java.util.HashMap;
17  import java.util.Map;
18  
19  import org.codehaus.jackson.map.ObjectMapper;
20  
21  /**
22   * TODO
23   */
24  public abstract class AbstractJsonTransformer extends AbstractMessageTransformer implements DiscoverableTransformer
25  {
26      protected int weighting = DiscoverableTransformer.MAX_PRIORITY_WEIGHTING;
27  
28      private ObjectMapper mapper;
29  
30      private Map<Class<?>, Class<?>> sharedMixins = new HashMap<Class<?>, Class<?>>();
31  
32      @Override
33      public void initialise() throws InitialisationException
34      {
35          if (mapper == null)
36          {
37              mapper = new ObjectMapper();
38          }
39      }
40  
41      public ObjectMapper getMapper()
42      {
43          return mapper;
44      }
45  
46      public void setMapper(ObjectMapper mapper)
47      {
48          this.mapper = mapper;
49      }
50  
51      public int getPriorityWeighting()
52      {
53          return weighting;
54      }
55  
56      public void setPriorityWeighting(int weighting)
57      {
58          this.weighting = weighting;
59      }
60  
61      public Map<Class<?>, Class<?>> getMixins()
62      {
63          return sharedMixins;
64      }
65  
66      public void setMixins(Map<Class<?>, Class<?>> mixins)
67      {
68          this.sharedMixins = mixins;
69      }
70  }