break;
}
}
}
if (mixinDefinition == null) {
throw new DefinitionException("could not find definition for mixin: " + mixinClass.getName()
+ " (loader " + mixinClass.getClassLoader() + ")"
+ " from loader " + mixinCalledFromLoader);
}
String factoryClassName = mixinDefinition.getFactoryClassName();
try {
Class containerClass;
if (factoryClassName == null) {
containerClass = ContextClassLoader.loadClass(mixinClass.getClassLoader(), DEFAULT_MIXIN_FACTORY);
} else {
containerClass = ContextClassLoader.loadClass(mixinClass.getClassLoader(), factoryClassName);
}
Constructor constructor = containerClass.getConstructor(new Class[]{Class.class, DeploymentModel.class});
final MixinFactory factory = (MixinFactory) constructor.newInstance(
new Object[]{mixinClass, mixinDefinition.getDeploymentModel()}
);
return factory;
} catch (InvocationTargetException e) {
throw new DefinitionException(e.getTargetException().toString());
} catch (NoSuchMethodException e) {
throw new DefinitionException(
"mixin factory does not have a valid constructor ["
+ factoryClassName
+ "] need to have a signature like this [MyMixinFactory(Class mixin, DeploymentModel scope)]: "
+ e.toString()
);
} catch (Throwable e) {
StringBuffer cause = new StringBuffer();
cause.append("could not create mixin container using the implementation specified [");
cause.append(factoryClassName);
cause.append("] due to: ");
cause.append(e.toString());
throw new DefinitionException(cause.toString());
}
}