Skip to content

Instantly share code, notes, and snippets.

@anpieber
Created July 1, 2011 09:14
Show Gist options
  • Select an option

  • Save anpieber/1058147 to your computer and use it in GitHub Desktop.

Select an option

Save anpieber/1058147 to your computer and use it in GitHub Desktop.
scanbundle
Bundle bundleToScan = bundleContext.getBundle();
Enumeration<?> findEntries = bundleToScan.findEntries("", "*.class", true);
while (findEntries.hasMoreElements()) {
URL object = (URL) findEntries.nextElement();
String className = object.getFile().substring(1, object.getFile().length() - 6).replaceAll("/", ".");
Class<?> candidateClass = bundleToScan.loadClass(className);
if (!Page.class.isAssignableFrom(candidateClass)) {
continue;
}
Class<? extends Page> pageClass = (Class<? extends Page>) candidateClass;
PaxWicketMountPoint mountPoint = pageClass.getAnnotation(PaxWicketMountPoint.class);
if (mountPoint != null) {
DefaultPageMounter mountPointRegistration = new DefaultPageMounter(applicationName, bundleContext);
mountPointRegistration.addMountPoint(mountPoint.mountPoint(), pageClass);
mountPointRegistration.register();
mountPointRegistrations.add(mountPointRegistration);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment