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.registry; 8 9 import org.mule.api.transformer.DataType; 10 import org.mule.api.transformer.Transformer; 11 12 /** 13 * A TransformResolver is used to find transformers that match a certain criteria in the registry. 14 * Implementations of this interface will use some or all of the information passed in to discover 15 * a matching transformer. 16 * <p/> 17 * Any implementations of this interface must be registered with the registry before it will get 18 * picked up. Typically this is done using the <code>registry-bootstrap.properties</code>. 19 * 20 * @since 3.0.0 21 */ 22 public interface TransformerResolver 23 { 24 /** 25 * Possible registry actions that occur that will trigger an event fired via 26 * {@link #transformerChange(Transformer, RegistryAction)} method. 27 */ 28 enum RegistryAction 29 { 30 /** 31 * signals that a transformer was added to the registry 32 */ 33 ADDED, 34 /** 35 * signals that a transformer was removed from the registry 36 */ 37 REMOVED 38 } 39 40 /** 41 * Responsible for finding a transformer with the given criteria. Note that if a 42 * transformer is not found null should be return, an exception must NOT be 43 * thrown. 44 * 45 * @param source information about the source object including the object iself 46 * @param result information about the result object to transform to 47 * @return a transformer from the registry that matches the criteria or null if a 48 * transformer was not found 49 * @throws ResolverException Only thrown if an exception is thrown during the 50 * search, this exception will just be a wrapper 51 */ 52 Transformer resolve(DataType<?> source, DataType<?> result) throws ResolverException; 53 54 /** 55 * A callback that is called when a transformer is registered or unregistered 56 * from the registry. This is used in situations where the resolver caches 57 * transformers and the cache needs to be updated. 58 * 59 * @param transformer the transformer that has changed 60 * @param registryAction whether the transformer was added or removed 61 */ 62 void transformerChange(Transformer transformer, RegistryAction registryAction); 63 }