public void start() throws Exception { Bundle bundleToScan = bundleContext.getBundle(); Enumeration<?> findEntries = bundleToScan.findEntries("", "*.class", true); if (findEntries == null) { LOGGER.error( new StringBuilder() .append( "We've found an error which you should really give a shot but which does not ") .append( "interrupt your runtime. Nevertheless we assume that this one is definitely an ") .append( "error so give it a shot! OK, the problem is that you entered the bundle with the ") .append( "symbolic name {} the blueprint/spring entry to scan for automount annotations. ") .append( "Nevertheless this bundle you would like to have scanned has NO classes! Either ") .append( "the anotation is wrong or you messed up something during the build of your bundle!") .toString(), bundleToScan.getSymbolicName()); return; } while (findEntries.hasMoreElements()) { String className = calculateClassName((URL) findEntries.nextElement()); Class<?> candidateClass = bundleToScan.loadClass(className); if (!Page.class.isAssignableFrom(candidateClass)) { continue; } @SuppressWarnings("unchecked") 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); } } }
public void stop() throws Exception { for (DefaultPageMounter pageMounter : mountPointRegistrations) { pageMounter.dispose(); } mountPointRegistrations.clear(); }