public ResourceComponent buildResourceComponent(Resource resource) throws PluginContainerException,
ResourceTypeNotEnabledException {
ResourceType resourceType = resource.getResourceType();
if (PluginMetadataManager.TEST_PLATFORM_TYPE.equals(resourceType)) {
return new ResourceComponent() {
public AvailabilityType getAvailability() {
return AvailabilityType.UP;
}
public void start(ResourceContext context) {
}
public void stop() {
}
};
}
String className = pluginManager.getMetadataManager().getComponentClass(resourceType);
ResourceContainer resourceContainer = inventoryManager.getResourceContainer(resource);
if (resourceContainer == null) {
throw new PluginContainerException("Resource container not found for " + resource + " - cannot create ResourceComponent.");
}
ClassLoader resourceClassloader = resourceContainer.getResourceClassLoader();
if (resourceClassloader == null) {
throw new PluginContainerException("Resource classLoader not found for " + resource + " - cannot create ResourceComponent.");
}
ResourceComponent component = (ResourceComponent) instantiateClass(resourceClassloader, className);
if (log.isDebugEnabled()) {
log.debug("Created resource component [" + className + "] of resource type [" + resourceType + ']');
}
return component;