* @param resource
* @return
*/
private Set determineImportsForClass(String className, Resource resource) {
Assert.notNull(resource, "a not-null class is required");
DependencyVisitor visitor = new DependencyVisitor();
boolean trace = logger.isTraceEnabled();
ClassReader reader;
try {
if (trace)
logger.trace("Visiting class " + className);
reader = new ClassReader(resource.getInputStream());
}
catch (Exception ex) {
throw (RuntimeException) new IllegalArgumentException("Cannot read class " + className).initCause(ex);
}
reader.accept(visitor, false);
// convert from / to . format
Set originalPackages = visitor.getPackages();
Set pkgs = new LinkedHashSet(originalPackages.size());
for (Iterator iterator = originalPackages.iterator(); iterator.hasNext();) {
String pkg = (String) iterator.next();
pkgs.add(pkg.replace('/', '.'));