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.api.transformer;
8   
9   /**
10   * A interface to denote that a transformer is discoverable. A Transformer can implement this interface so that
11   * when a transformation is being 'discovered' for a payload type the transformers implementing this interface
12   * will be included in the search. A 'priorityWeighting property is introduced with this interface that can be used
13   * to help select a transformer when there are two or more matches. The transformer with the highest priorityWeighting
14   * will be selected.
15   */
16  public interface DiscoverableTransformer
17  {
18      int MAX_PRIORITY_WEIGHTING = 10;
19      int MIN_PRIORITY_WEIGHTING = 1;
20      int DEFAULT_PRIORITY_WEIGHTING = MIN_PRIORITY_WEIGHTING;
21  
22      /**
23       * If 2 or more discoverable transformers are equal, this value can be used to select the correct one
24       *
25       * @return the priority weighting for this transformer. This is a value between
26       *         {@link #MIN_PRIORITY_WEIGHTING} and {@link #MAX_PRIORITY_WEIGHTING}.
27       */
28      int getPriorityWeighting();
29  
30      /**
31       * If 2 or more discoverable transformers are equal, this value can be used to select the correct one
32       *
33       * @param weighting the priority weighting for this transformer. This is a value between
34       *                  {@link #MIN_PRIORITY_WEIGHTING} and {@link #MAX_PRIORITY_WEIGHTING}.
35       */
36      void setPriorityWeighting(int weighting);
37  }