Created
July 1, 2011 09:14
-
-
Save anpieber/1058147 to your computer and use it in GitHub Desktop.
scanbundle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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