createDroneCallable(registry, injectionPoint);
}
private <DRONE> void configureDrone(DroneRegistry registry, InjectionPoint<DRONE> injectionPoint) {
ArquillianDescriptor descriptor = arquillianDescriptor.get();
DroneContext context = droneContext.get();
Validate.stateNotNull(descriptor, "ArquillianDescriptor should not be null");
Validate.stateNotNull(context, "DroneContext should be available while working with method scoped instances");
if (context.isDroneConfigurationStored(injectionPoint)) {
logger.log(Level.WARNING, "Couldn''t configure drone for injection point {0}, " +
"because it was already configured!", injectionPoint);
return;
}
Configurator<DRONE, ?> configurator = registry.getEntryFor(injectionPoint.getDroneType(), Configurator.class);
beforeDroneConfiguredEvent.fire(new BeforeDroneConfigured(configurator, injectionPoint));
DroneConfiguration configuration;
// If nobody else provided the configuration
if (!context.isDroneConfigurationStored(injectionPoint)) {
configuration = configurator.createConfiguration(descriptor, injectionPoint);
context.storeDroneConfiguration(injectionPoint, configuration);
} else {
configuration = context.getDroneConfiguration(injectionPoint, DroneConfiguration.class);
}
afterDroneConfiguredEvent.fire(new AfterDroneConfigured(configuration, injectionPoint));
}