// Wrap the component in a proxy that will provide locking and a timeout for the call to start().
component = container.createResourceComponentProxy(ResourceComponent.class, FacetLockType.READ,
COMPONENT_START_TIMEOUT, true, false, true);
} catch (Throwable t) {
container.setResourceComponentState(ResourceComponentState.STOPPED);
throw new PluginContainerException("Failed getting proxy for resource " + resource + ".", t);
}
try {
component.start(context);
container.setResourceComponentState(ResourceComponentState.STARTED);
resource.setConnected(true); // This tells the server-side that the resource has connected successfully.
} catch (Throwable t) {
// Don't leave in a STARTING state. Don't actually call component.stop(),
// because we're not actually STARTED
container.setResourceComponentState(ResourceComponentState.STOPPED);
StringBuilder messageBuilder = new StringBuilder("Failed to start component for ").append(resource);
if (isNotBlank(t.getMessage())) {
messageBuilder.append(" - ").append(t.getMessage());
}
if (t.getCause() != null) {
messageBuilder.append(" - Cause: ").append(t.getClass().getName());
if (isNotBlank(t.getCause().getMessage())) {
messageBuilder.append(": ").append(t.getCause().getMessage());
}
}
String message = messageBuilder.toString();
if (updatedPluginConfig || (t instanceof InvalidPluginConfigurationException)) {
if (log.isDebugEnabled()) {
log.debug("Resource has a bad config, waiting for this to go away: " + resource);
}
InventoryEventListener iel = new ResourceGotActivatedListener();
addInventoryEventListener(iel);
throw new InvalidPluginConfigurationException(message);
}
throw new PluginContainerException(message);
}
// We purposefully do not get availability of this resource yet
// We need availability checked during the normal availability executor timeframe.
// Otherwise, new resources will not have their availabilities shipped up to the server because