private <T extends ComponentSpec, I extends BaseComponentSpec> void doRegister(final ModelType<T> type, final ModelType<I> implementation, final ProjectSourceSet projectSourceSet, ComponentSpecContainer componentSpecs, final ProjectIdentifier projectIdentifier) {
componentSpecs.registerFactory(type.getConcreteClass(), new NamedDomainObjectFactory<T>() {
public T create(String name) {
FunctionalSourceSet componentSourceSet = projectSourceSet.maybeCreate(name);
ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(projectIdentifier.getPath(), name);
// safe because we implicitly know that U extends V, but can't express this in the type system
@SuppressWarnings("unchecked")
T created = (T) BaseComponentSpec.create(implementation.getConcreteClass(), id, componentSourceSet, instantiator);