class BundleClassesFinder {

	public Collection<Class<?>> getClasses(final Bundle bundle) {
		Collection<Class<?>> classes = new ArrayList<Class<?>>();

		@SuppressWarnings("unchecked")
		Enumeration<URL> classEntries = bundle.findEntries(this.basePackage, RESOURCE_PATTERN, true);
		while ((classEntries != null) && classEntries.hasMoreElements()) {
			try {
				URL classURL = classEntries.nextElement();
				ClassReader classReader = new ClassReader(classURL.openStream());
				if (accepts(classReader)) {
					String className = classReader.getClassName().replace('/', '.');
					if (LOG.isDebugEnabled()) {
						LOG.debug("Class: " + className + " has been found.");
					}
					Class<?> clazz = bundle.loadClass(className);
					classes.add(clazz);
				}
			} catch (ClassNotFoundException e) {
				LOG.error("Error loading class!", e);
			} catch (IOException e) {
				LOG.error("Error reading the class!", e);
			}
		}

		return classes;
	}

	public  BundleClassesFinder(String basePackage);

}