View Javadoc

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