Prevent empty calls to ACAC #register and #scan

This commit is contained in:
Chris Beams 2011-05-06 19:01:11 +00:00
parent d2faef44fa
commit 84a63b6d4b
1 changed files with 3 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package org.springframework.context.annotation;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.Assert;
/**
* Standalone application context, accepting annotated classes as input - in particular
@ -126,6 +127,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
* @see #refresh()
*/
public void register(Class<?>... annotatedClasses) {
Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified");
this.reader.register(annotatedClasses);
}
@ -137,6 +139,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
* @see #refresh()
*/
public void scan(String... basePackages) {
Assert.notEmpty(basePackages, "At least one base package must be specified");
this.scanner.scan(basePackages);
}