/** * Scan given a class that is a sublass of {@link Page}. * @param pageClass {@link Page} subclass to scan * @return An {@link AnnotatedMountList} containing the primary and alternate strategies created for the class. */ public AnnotatedMountList scanClass(Class<? extends Page> pageClass) { AnnotatedMountList list = new AnnotatedMountList(); scanClass(pageClass, list); return list; }
public void mountPages(WebApplication application) { new CustomAnnotatedMountScanner() .scanList(lookupPages()) .mount(application); }
/** * Magic of all this is done here. * * @param pageClass * @param list */ private void scanClass(Class<? extends Page> pageClass, AnnotatedMountList list) { MountPath mountPath = pageClass.getAnnotation(MountPath.class); if (mountPath == null) return; // alternates for (String alt : mountPath.alt()) { list.add(getRequestMapper(alt, pageClass)); } String path = mountPath.value(); // default if no explicit path is provided if ("".equals(path)) { path = getDefaultMountPath(pageClass); } list.add(getRequestMapper(path, pageClass)); }
@Override public void init(WebApplication webApplication) { List<String> packagesToScan = new ArrayList<>(); AnnotatedMountScanner annotatedMountScanner = new AnnotatedMountScanner(); String packagename = webApplication.getClass().getPackage().getName(); if (prop.getPackagename() != null) { packagename = prop.getPackagename(); } packagesToScan.add(packagename); annotatedMountScanner.scanPackage(packagename).mount(webApplication); if(candidates.getBasePackages().size() > 0){ packagesToScan.addAll(candidates.getBasePackages()); for (String basePackage : candidates.getBasePackages()) { annotatedMountScanner.scanPackage(basePackage).mount(webApplication); } } wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass()) .withDetail("properties", prop) .withDetail("packagesToScan", packagesToScan) .build()); }
@Override public void init(WebApplication webApplication) { List<String> packagesToScan = new ArrayList<>(); AnnotatedMountScanner annotatedMountScanner = new AnnotatedMountScanner(); String packagename = webApplication.getClass().getPackage().getName(); if (prop.getPackagename() != null) { packagename = prop.getPackagename(); } packagesToScan.add(packagename); annotatedMountScanner.scanPackage(packagename).mount(webApplication); if(candidates.getBasePackages().size() > 0){ packagesToScan.addAll(candidates.getBasePackages()); for (String basePackage : candidates.getBasePackages()) { annotatedMountScanner.scanPackage(basePackage).mount(webApplication); } } wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass()) .withDetail("properties", prop) .withDetail("packagesToScan", packagesToScan) .build()); }
/** * Scan given a class that is a sublass of {@link Page}. * * @param pageClass * {@link Page} subclass to scan * @return An {@link AnnotatedMountList} containing the primary and alternate strategies created * for the class. */ public AnnotatedMountList scanClass(Class<? extends Page> pageClass) { AnnotatedMountList list = new AnnotatedMountList(); scanClass(pageClass, list); return list; }
protected void initDefaultPageMounts() { mountPage("/login.html", getSignInPageClass()); mountPage("/welcome.html", getHomePage()); // Mount the other pages via @MountPath annotation on the page classes AnnotatedMountList mounts = new AnnotatedMountScanner().scanPackage("de.tudarmstadt.ukp"); for (IRequestMapper mapper : mounts) { if (mapper instanceof HomePageMapper) { System.out.println(mapper); } } mounts.mount(this); }
/** * Scan a list of classes which are annotated with MountPath * @param mounts * @return An {@link AnnotatedMountList} */ @SuppressWarnings({"unchecked"}) protected AnnotatedMountList scanList(List<Class<?>> mounts) { AnnotatedMountList list = new AnnotatedMountList(); for (Class<?> mount : mounts) { Class<? extends Page> page = (Class<? extends Page>) mount; scanClass(page, list); } return list; }
protected void initDefaultPageMounts() { mountPage("/login.html", getSignInPageClass()); mountPage("/welcome.html", getHomePage()); // Mount the other pages via @MountPath annotation on the page classes AnnotatedMountList mounts = new AnnotatedMountScanner().scanPackage("de.tudarmstadt.ukp"); for (IRequestMapper mapper : mounts) { if (mapper instanceof HomePageMapper) { System.out.println(mapper); } } mounts.mount(this); }
/** * Scan a list of classes which are annotated with MountPath * * @param mounts * @return An {@link AnnotatedMountList} */ @SuppressWarnings({ "unchecked" }) protected AnnotatedMountList scanList(List<Class<?>> mounts) { AnnotatedMountList list = new AnnotatedMountList(); for (Class<?> mount : mounts) { Class<? extends Page> page = (Class<? extends Page>)mount; scanClass(page, list); } return list; }
@Override protected void onGlobalSettings() { super.onGlobalSettings(); getApplicationSettings().setUploadProgressUpdatesEnabled(true); // deactivate ajax debug mode // getDebugSettings().setAjaxDebugModeEnabled(false); configureBootstrap(); // configureResourceBundles(); optimizeForWebPerformance(); new AnnotatedMountScanner().scanPackage(getPackageToScan()).mount(this); if (Strings.isTrue(getProperties().getProperty("cdn.useCdn"))) { final String cdn = getProperties().getProperty("cdn.baseUrl"); StaticResourceRewriteMapper.withBaseUrl(cdn).install(this); } final IPackageResourceGuard packageResourceGuard = getResourceSettings() .getPackageResourceGuard(); if (packageResourceGuard instanceof SecurePackageResourceGuard) { final SecurePackageResourceGuard securePackageResourceGuard = (SecurePackageResourceGuard)packageResourceGuard; securePackageResourceGuard.addPattern("+*.woff2"); } }
@Override public void init() { super.init(); getMarkupSettings().setStripWicketTags(true); getMarkupSettings().setStripComments(true); getApplicationSettings().setAccessDeniedPage(Page403.class); getApplicationSettings().setPageExpiredErrorPage(Page410.class); getMarkupSettings().setDefaultMarkupEncoding(StandardCharsets.UTF_8.name()); setHeaderResponseDecorator(r -> new JavaScriptFilteredIntoFooterHeaderResponse(r, SingularTemplate.JAVASCRIPT_CONTAINER)); getComponentInstantiationListeners().add(new SpringComponentInjector(this)); new AnnotatedMountScanner().scanPackage("org.opensingular.studio").mount(this); List<IStringResourceLoader> stringResourceLoaders = getResourceSettings().getStringResourceLoaders(); stringResourceLoaders.add(0, new ClassStringResourceLoader(appConfig.getClass())); getComponentOnConfigureListeners().add(component -> { boolean outputId = !component.getRenderBodyOnly(); component.setOutputMarkupId(outputId).setOutputMarkupPlaceholderTag(outputId); }); }
@Override public void init() { super.init(); getRequestCycleSettings().setTimeout(Duration.minutes(5)); getRequestCycleListeners().add(new SingularServerContextListener()); Locale.setDefault(new Locale("pt", "BR")); getApplicationSettings().setAccessDeniedPage(Error403Page.class); getApplicationSettings().setPageExpiredErrorPage(Page410.class); // Don't forget to check your Application server for this getApplicationSettings().setDefaultMaximumUploadSize(Bytes.megabytes(10)); getMarkupSettings().setStripWicketTags(true); getMarkupSettings().setStripComments(true); getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); getComponentOnConfigureListeners().add(component -> { boolean outputId = !component.getRenderBodyOnly(); component.setOutputMarkupId(outputId).setOutputMarkupPlaceholderTag(outputId); }); if (applicationContext != null) { getComponentInstantiationListeners().add(new SpringComponentInjector(this, applicationContext, true)); } else { getComponentInstantiationListeners().add(new SpringComponentInjector(this)); applicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); } new AnnotatedMountScanner().scanPackage("org.opensingular").mount(this); for (String packageName : getPackagesToScan()) { new AnnotatedMountScanner().scanPackage(packageName).mount(this); } getDebugSettings().setComponentPathAttributeName("wicketpath"); }