if (recipe == null) {
throw new IllegalArgumentException("recipe == null");
}
// find the plugin environment for the bundle plugin of the given type
ServerPluginEnvironment pluginEnv = null;
for (ServerPluginEnvironment env : getPluginEnvironments()) {
BundlePluginDescriptorType descriptor = (BundlePluginDescriptorType) env.getPluginDescriptor();
if (bundleTypeName.equals(descriptor.getBundle().getType())) {
pluginEnv = env;
break;
}
}
if (pluginEnv == null) {
throw new IllegalArgumentException("Bundle type [" + bundleTypeName + "] is not known to the system");
}
// get the facet and call the parse method in the appropriate classloader
String pluginName = pluginEnv.getPluginKey().getPluginName();
ServerPluginComponent component = getServerPluginComponent(pluginName);
BundleServerPluginFacet facet = (BundleServerPluginFacet) component; // we know this cast will work because our loadPlugin ensured so
getLog().debug("Bundle server plugin [" + pluginName + "] is parsing a bundle recipe");
ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(pluginEnv.getPluginClassLoader());
RecipeParseResults results = facet.parseRecipe(recipe);
ensureDisplayNameIsSet(results);
return results;
} finally {
Thread.currentThread().setContextClassLoader(originalContextClassLoader);