List of usage examples for org.apache.wicket ThreadContext getApplication
public static Application getApplication()
From source file:com.inductiveautomation.ignition.examples.hce.GatewayHook.java
@Override public void shutdown() { /* remove our bundle */ BundleUtil.get().removeBundle("HomeConnect"); if (context.getState() != ContextState.STOPPING) { WebApplication wicket = context.getWebApplication(); Application currentApplication = ThreadContext.getApplication(); ThreadContext.setApplication(wicket); try {/*from w ww . ja v a 2 s.com*/ wicket.unmount("ack/${id}"); } finally { ThreadContext.setApplication(currentApplication); } } }
From source file:org.jabylon.rest.ui.wicket.JabylonApplication.java
License:Open Source License
private void internalUmount(String path) { //workaround so wicket doesn't choke because the thread context isn't filled (wrong thread) Application application = ThreadContext.getApplication(); if (application == null) ThreadContext.setApplication(JabylonApplication.this); if (ThreadContext.getSession() == null) ThreadContext.setSession(new WebSession(createFakeRequest(null))); // unmount(path); /*/* ww w .j av a 2 s . co m*/ * umount seems to be greedy, e.g. a prefix match is enough. * That's troublesome because umount /settings/log will also umount /settings */ ICompoundRequestMapper rootRequestMapperAsCompound = getRootRequestMapperAsCompound(); if (rootRequestMapperAsCompound instanceof CompoundRequestMapper) { CompoundRequestMapper compound = (CompoundRequestMapper) rootRequestMapperAsCompound; Iterator<IRequestMapper> it = compound.iterator(); while (it.hasNext()) { IRequestMapper iRequestMapper = it.next(); if (iRequestMapper instanceof ResouceAwareMountedMapper) { ResouceAwareMountedMapper mapper = (ResouceAwareMountedMapper) iRequestMapper; if (path.equals(mapper.getMountPath())) { logger.info("Unmounting {}", path); getRootRequestMapperAsCompound().remove(mapper); } } } } }
From source file:org.ops4j.pax.wicket.internal.PageMounterTracker.java
License:Apache License
@Override public final Object addingService(ServiceReference reference) { PageMounter mounter = (PageMounter) super.addingService(reference); List<MountPointInfo> infos = mounter.getMountPoints(); for (MountPointInfo info : infos) { LOGGER.trace("Make sure that path {} is clear before trying to remount", info.getPath()); Application oldApp = ThreadContext.getApplication(); ThreadContext.setApplication(application); try {/* w w w.j a va 2 s . c o m*/ application.unmount(info.getPath()); } catch (IllegalArgumentException e) { LOGGER.trace("Unmounting not possible since nothing here by now."); // this could happen if wicket had not been started at all by now --> simply ignore } LOGGER.trace("Trying to mount {} with {}", info.getPath(), info.getPage().getName()); application.mountPage(info.getPath(), info.getPage()); ThreadContext.setApplication(oldApp); LOGGER.info("Mounted {} with {}", info.getPath(), info.getPage().getName()); } return mounter; }
From source file:org.ops4j.pax.wicket.internal.PageMounterTracker.java
License:Apache License
@Override public final void removedService(ServiceReference reference, Object mounter) { PageMounter pageMounter = (PageMounter) mounter; List<MountPointInfo> infos = pageMounter.getMountPoints(); for (MountPointInfo info : infos) { LOGGER.trace("Trying to mount {} with {}", info.getPath(), info.getPage().getName()); Application oldApp = ThreadContext.getApplication(); ThreadContext.setApplication(application); if (!Session.exists()) { Request request = new MockWebRequest(Url.parse(info.getPath())); ThreadContext.setSession(new WebSession(request)); }// w w w . j a v a 2 s .c om application.unmount(info.getPath()); ThreadContext.setApplication(oldApp); LOGGER.info("Unmounted {} with {}", info.getPath(), info.getPage().getName()); } super.removedService(reference, pageMounter); }
From source file:org.xaloon.wicket.component.inject.j2ee.bm.WeldBeanManagerLocator.java
License:Apache License
@Override public BeanManager getBeanManager() { if (beanManager == null) { Application application = ThreadContext.getApplication(); if (application == null) { // Runs in different thread. get beanManager directly from JNDI. beanManager = locateBeanManagerFromJNDI(); } else {/* w w w . j a v a 2 s. c om*/ // Get bean manager from application beanManager = getBeanManagerFromApplication(application); } } return beanManager; }