use of org.mule.runtime.core.api.transformer.DiscoverableTransformer in project mule by mulesoft.
the class SimpleRegistryBootstrap method doRegisterTransformer.
@Override
protected void doRegisterTransformer(TransformerBootstrapProperty bootstrapProperty, Class<?> returnClass, Class<? extends Transformer> transformerClass) throws Exception {
Transformer trans = ClassUtils.instantiateClass(transformerClass);
if (!(trans instanceof DiscoverableTransformer)) {
throw new RegistrationException(CoreMessages.transformerNotImplementDiscoverable(trans));
}
if (returnClass != null) {
DataTypeParamsBuilder builder = DataType.builder().type(returnClass);
if (isNotEmpty(bootstrapProperty.getMimeType())) {
builder = builder.mediaType(bootstrapProperty.getMimeType());
}
trans.setReturnDataType(builder.build());
}
if (bootstrapProperty.getName() != null) {
trans.setName(bootstrapProperty.getName());
} else {
// Prefixes the generated default name to ensure there is less chance of conflict if the user registers
// the transformer with the same name
trans.setName("_" + trans.getName());
}
((MuleContextWithRegistries) muleContext).getRegistry().registerTransformer(trans);
}
Aggregations