/** * Checks if the <code>Application</code> threadlocal is set in this thread * * @return true if {@link Application#get()} can return the instance of application, false * otherwise */ public static boolean exists() { return ThreadContext.getApplication() != null; }
/** * Checks if the <code>Application</code> threadlocal is set in this thread * * @return true if {@link Application#get()} can return the instance of application, false * otherwise */ public static boolean exists() { return ThreadContext.getApplication() != null; }
/** * Get Application for current thread. * * @return The current thread's Application */ public static Application get() { Application application = ThreadContext.getApplication(); if (application == null) { throw new WicketRuntimeException("There is no application attached to current thread " + Thread.currentThread().getName()); } return application; }
/** * Get Application for current thread. * * @return The current thread's Application */ public static Application get() { Application application = ThreadContext.getApplication(); if (application == null) { throw new WicketRuntimeException("There is no application attached to current thread " + Thread.currentThread().getName()); } return application; }
public static ServletContext getServletContext() { Application application = ThreadContext.getApplication(); return (application != null) ? ((WebApplication) application).getServletContext() : null; }
try Application oldApplication = ThreadContext.getApplication(); try
try Application oldApplication = ThreadContext.getApplication(); try
/** {@inheritDoc} */ @Override public final PageMounter addingService(ServiceReference<PageMounter> reference) { PageMounter mounter = super.addingService(reference); List<? extends 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 { 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; }
/** {@inheritDoc} */ @Override public final PageMounter addingService(ServiceReference<PageMounter> reference) { PageMounter mounter = super.addingService(reference); List<? extends 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 { 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; }
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); /* * 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); } } } } }
/** {@inheritDoc} */ @Override public final void removedService(ServiceReference<PageMounter> reference, PageMounter mounter) { PageMounter pageMounter = mounter; List<? extends 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)); } application.unmount(info.getPath()); ThreadContext.setApplication(oldApp); LOGGER.info("Unmounted {} with {}", info.getPath(), info.getPage().getName()); } super.removedService(reference, pageMounter); } }
@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 { wicket.unmount("ack/${id}"); } finally { ThreadContext.setApplication(currentApplication); } } }
/** {@inheritDoc} */ @Override public final void removedService(ServiceReference<PageMounter> reference, PageMounter mounter) { PageMounter pageMounter = mounter; List<? extends 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)); } application.unmount(info.getPath()); ThreadContext.setApplication(oldApp); LOGGER.info("Unmounted {} with {}", info.getPath(), info.getPage().getName()); } super.removedService(reference, pageMounter); } }
Application oldApplication = ThreadContext.getApplication(); Session oldSession = ThreadContext.getSession(); RequestCycle oldRequestCycle = ThreadContext.getRequestCycle();
Application oldApplication = ThreadContext.getApplication(); Session oldSession = ThreadContext.getSession(); RequestCycle oldRequestCycle = ThreadContext.getRequestCycle();
Application oldApplication = ThreadContext.getApplication(); Session oldSession = ThreadContext.getSession(); RequestCycle oldRequestCycle = ThreadContext.getRequestCycle();