return new PrototypeObjectFactory<T>(classMetadata);
}
protected static <T> ClassMetadata collectClassMetadata(final Class<T> cls,
boolean validateConstructor) {
ClassMetadata classMetadata = null;
if (ProviderMetadataCollector.isProvider(cls)) {
classMetadata = ProviderMetadataCollector.collectMetadata(cls);
} else if (ResourceMetadataCollector.isResource(cls)) {
classMetadata = ResourceMetadataCollector.collectMetadata(cls);
} else if (ApplicationMetadataCollector.isApplication(cls)) {
classMetadata = ApplicationMetadataCollector.collectMetadata(cls);
} else {
throw new IllegalArgumentException(Messages.getMessage("cannotCreateFactoryForClass", cls)); //$NON-NLS-1$
}
// validate that there is a valid constructor if needed
if (validateConstructor && classMetadata.getConstructor().getConstructor() == null) {
throw new IllegalStateException(Messages.getMessage("noValidConstructorFoundFor", cls //$NON-NLS-1$
.getCanonicalName()));
}
return classMetadata;
}