org.apache.wicket.request.resource.SharedResourceReference Java Examples
The following examples show how to use
org.apache.wicket.request.resource.SharedResourceReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WicketApplicationBase.java From webanno with Apache License 2.0 | 5 votes |
protected void initLogoReference() { Properties settings = SettingsUtil.getSettings(); String logoValue = settings.getProperty(SettingsUtil.CFG_STYLE_LOGO); if (StringUtils.isNotBlank(logoValue) && new File(logoValue).canRead()) { getSharedResources().add("logo", new FileSystemResource(new File(logoValue))); mountResource("/assets/logo.png", new SharedResourceReference("logo")); } else { mountResource("/assets/logo.png", new PackageResourceReference(getLogoLocation())); } }
Example #2
Source File: OrientDBHttpAPIResource.java From wicket-orientdb with Apache License 2.0 | 5 votes |
/** * Mounts OrientDB REST API Bridge to an app * @param resource {@link OrientDBHttpAPIResource} to mount * @param app {@link WebApplication} to mount to * @param mountPaths array of paths to mount to */ public static void mountOrientDbRestApi(OrientDBHttpAPIResource resource, WebApplication app, String... mountPaths) { app.getSharedResources().add(ORIENT_DB_KEY, resource); Authenticator.setDefault(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { String username; String password; OrientDbWebSession session = OrientDbWebSession.get(); if(session.isSignedIn()) { username = session.getUsername(); password = session.getPassword(); } else { IOrientDbSettings settings = OrientDbWebApplication.get().getOrientDbSettings(); username = settings.getGuestUserName(); password = settings.getGuestPassword(); } return new PasswordAuthentication (username, password.toCharArray()); } }); CookieHandler.setDefault(new PersonalCookieManager()); sun.net.www.protocol.http.AuthCacheValue.setAuthCache(new MultiUserCache()); for (String mountPath : mountPaths) { app.mountResource(mountPath, new SharedResourceReference(ORIENT_DB_KEY)); } }
Example #3
Source File: RestorePasswordResource.java From Orienteer with Apache License 2.0 | 5 votes |
public static String getLinkForUser(ODocument doc) { String id = doc.field(OrienteerUser.PROP_RESTORE_ID); PageParameters params = new PageParameters(); params.add(PARAMETER_ID, id); CharSequence url = RequestCycle.get().urlFor(new SharedResourceReference(RES_KEY), params); return RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(url)); }
Example #4
Source File: OrienteerWebApplication.java From Orienteer with Apache License 2.0 | 5 votes |
private void mountOrUnmountPackage(String packageName, ClassLoader classLoader, boolean mount) { ClassPath classPath; try { classPath = ClassPath.from(classLoader); } catch (IOException e) { throw new WicketRuntimeException("Can't scan classpath", e); } for(ClassInfo classInfo : classPath.getTopLevelClassesRecursive(packageName)) { Class<?> clazz = classInfo.load(); MountPath mountPath = clazz.getAnnotation(MountPath.class); if(mountPath!=null) { if(IRequestablePage.class.isAssignableFrom(clazz)) { Class<? extends IRequestablePage> pageClass = (Class<? extends IRequestablePage>) clazz; forEachOnMountPath(mountPath, path -> { if(mount) { if ("/".equals(path)) { mount(new HomePageMapper(pageClass)); } mount(new MountedMapper(path, pageClass)); } else { unmount(path); } }); } else if(IResource.class.isAssignableFrom(clazz)) { if(mount) { String resourceKey = clazz.getName(); getSharedResources().add(resourceKey, (IResource) getServiceInstance(clazz)); SharedResourceReference reference = new SharedResourceReference(resourceKey); forEachOnMountPath(mountPath, path -> mountResource(path, reference)); } else { forEachOnMountPath(mountPath, this::unmount); } } else { throw new WicketRuntimeException("@"+MountPath.class.getSimpleName()+" should be only on pages or resources"); } } } }
Example #5
Source File: OLoggerReceiverResource.java From Orienteer with Apache License 2.0 | 4 votes |
public static void mount(WebApplication app) { OLoggerReceiverResource resource = ((OrienteerWebApplication) app).getServiceInstance(OLoggerReceiverResource.class); app.getSharedResources().add(REGISTRATION_RES_KEY, resource); app.mountResource(MOUNT_PATH, new SharedResourceReference(REGISTRATION_RES_KEY)); }
Example #6
Source File: RestorePasswordResource.java From Orienteer with Apache License 2.0 | 4 votes |
public static void mount(OrienteerWebApplication app) { app.getSharedResources().add(RES_KEY, app.getServiceInstance(RestorePasswordResource.class)); app.mountResource(MOUNT_PATH, new SharedResourceReference(RES_KEY)); }
Example #7
Source File: RegistrationResource.java From Orienteer with Apache License 2.0 | 4 votes |
public static String createRegistrationLink(OrienteerUser user) { PageParameters params = new PageParameters(); params.add(PARAMETER_ID, user.getId()); CharSequence url = RequestCycle.get().urlFor(new SharedResourceReference(RES_KEY), params); return RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(url)); }
Example #8
Source File: RegistrationResource.java From Orienteer with Apache License 2.0 | 4 votes |
public static void mount(OrienteerWebApplication app) { RegistrationResource resource = app.getServiceInstance(RegistrationResource.class); app.getSharedResources().add(RES_KEY, resource); app.mountResource(MOUNT_PATH, new SharedResourceReference(RES_KEY)); }
Example #9
Source File: OContentShareResource.java From Orienteer with Apache License 2.0 | 4 votes |
public static SharedResourceReference getSharedResourceReference() { return new SharedResourceReference(OContentShareResource.class.getName()); }