use of org.mule.runtime.extension.api.loader.ExtensionLoadingDelegate in project mule by mulesoft.
the class CraftedExtensionModelLoader method declareExtension.
@Override
protected void declareExtension(ExtensionLoadingContext context) {
Class<?> delegateType = getDelegateType(context, context.getExtensionClassLoader());
if (!ExtensionLoadingDelegate.class.isAssignableFrom(delegateType)) {
throw new IllegalArgumentException(format("Property '%s' was expected to point to an implementation of the '%s', but '%s' was found instead", TYPE_PROPERTY_NAME, ExtensionLoadingDelegate.class.getName(), delegateType.getClass().getName()));
}
if (!isInstantiable(delegateType, new ReflectionCache())) {
throw new IllegalArgumentException(format("Type '%s' is not instantiable. A concrete class with a public default constructor was expected", delegateType.getName()));
}
ExtensionLoadingDelegate delegate;
try {
delegate = (ExtensionLoadingDelegate) ClassUtils.instantiateClass(delegateType);
} catch (Throwable e) {
throw new MuleRuntimeException(createStaticMessage(format("Could not instantiate type '%s'", delegateType.getName())), e);
}
delegate.accept(context.getExtensionDeclarer(), context);
}
Aggregations