List of usage examples for org.apache.wicket.util IProvider IProvider
IProvider
From source file:fiftyfive.wicket.resource.MergedResourceBuilder.java
License:Apache License
/** * Constructs and returns a special merged resource request mapper using the path and resources * options specified in this builder.//from w w w .j a v a 2s . c om * <p> * This method may only be called after all of the options have been set. * <p> * Use this method if your application has a complex configuration that requires you to deal * with request mappers directly (e.g. you need to wrap or combine them in clever ways). * Most applications will be better served by {@link #install install()}, which * handles creating the mapper and mounting it in one easy step. * * @throws IllegalStateException if a path or resources have not been * specified prior to calling this method. * * @since 3.0 */ public IRequestMapper buildRequestMapper(final WebApplication app) { if (!this.frozen) assertRequiredOptionsAndFreeze(); return new MergedResourceMapper(this.path, this.references, new PageParametersEncoder(), new IProvider<IResourceCachingStrategy>() { public IResourceCachingStrategy get() { return app.getResourceSettings().getCachingStrategy(); } }); }
From source file:gr.abiss.calipso.wicket.CalipsoApplication.java
License:Open Source License
/** * Maps exceptions to pages./* w w w. j av a2s . c o m*/ */ @Override public IProvider<IExceptionMapper> getExceptionMapperProvider() { return new IProvider<IExceptionMapper>() { @Override public IExceptionMapper get() { return new IExceptionMapper() { final DefaultExceptionMapper def = new DefaultExceptionMapper(); @Override public IRequestHandler map(Exception ex) { PageParameters par = new PageParameters().add("ex", ex); boolean couldNotLock = false; if (ex.getClass().equals(CouldNotLockPageException.class)) { couldNotLock = true; } else if (ex.getCause() != null && (ex.getCause().getClass().equals(CouldNotLockPageException.class) || (ex.getCause().getCause() != null && ex.getCause().getCause().getClass() .equals(CouldNotLockPageException.class)))) { couldNotLock = true; } if (couldNotLock) { Request request = RequestCycle.get().getRequest(); HttpServletRequest httpRequest = ((ServletWebRequest) request).getContainerRequest(); logger.error("Page lock timed out, invalidating session"); if (httpRequest.getSession(false) != null) { httpRequest.getSession().invalidate(); } return new RenderPageRequestHandler(new PageProvider(LoginPage.class, par)); } return def.map(ex); } }; } }; }
From source file:name.martingeisse.trading_game.platform.wicket.MyWicketApplication.java
License:Open Source License
@Override public IProvider<IExceptionMapper> getExceptionMapperProvider() { return new IProvider<IExceptionMapper>() { @Override//from ww w .j a va2s.c o m public IExceptionMapper get() { return new MyExceptionMapper(); } }; }
From source file:name.martingeisse.wicket.demo_app.wicket.WmcDemoWicketApplication.java
License:Open Source License
@Override public IProvider<IExceptionMapper> getExceptionMapperProvider() { return new IProvider<IExceptionMapper>() { @Override//from w ww . j a v a 2 s . c om public IExceptionMapper get() { return new WmcDemoExceptionMapper(); } }; }
From source file:org.wicketstuff.lazymodel.PropertyModelComparison.java
License:Apache License
@Test public void time() { Duration propertyModelDuration = measureTime(new IProvider<IModel<?>>() { @Override/*from w ww.j a v a 2 s. com*/ public IModel<?> get() { return new PropertyModel<C>(a, "b.cs[0].string"); } }); Duration lazyModelDuration = measureTime(new IProvider<IModel<?>>() { @Override public IModel<?> get() { return model(from(a).getB().getCs().get(0).getString()); } }); assertTrue("LazyModel is 2 times slower", lazyModelDuration.getMilliseconds() < propertyModelDuration.getMilliseconds() * 2.1); }
From source file:org.wicketstuff.lazymodel.PropertyModelComparison.java
License:Apache License
@Test public void cachedTime() { Duration propertyModelDuration = measureTime(new IProvider<IModel<?>>() { @Override//from ww w.j a v a2s .co m public IModel<?> get() { return new PropertyModel<C>(a, "b.cs[0].string"); } }); final LazyModel<String> C = model(from(a).getB().getCs().get(0).getString()); Duration lazyModelDuration = measureTime(new IProvider<IModel<?>>() { @Override public IModel<?> get() { return C.bind(a); } }); assertTrue("Cached LazyModel is slower", lazyModelDuration.getMilliseconds() < propertyModelDuration.getMilliseconds() * 1.1); }