List of usage examples for org.apache.wicket.protocol.http WicketFilter getFilterConfig
public FilterConfig getFilterConfig()
From source file:com.caucho.wicket.ResinApplicationFactory.java
License:Open Source License
/** * Create a new instance of the <code>WebApplication</code> with * WebBeans enabled.// w w w .j a v a 2 s .com */ public WebApplication createApplication(WicketFilter filter) { String className = filter.getFilterConfig().getInitParameter(APP_NAME); if (className == null) throw new ConfigException(L.l("filter does not define '{0}'", APP_NAME)); try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class cl = Class.forName(className, false, loader); WebBeansContainer webBeans = WebBeansContainer.create(); return (WebApplication) webBeans.getObject(cl); } catch (ConfigException e) { throw e; } catch (Exception e) { throw new ConfigException(L.l("Can't load application class '{0}'\n{1}", className, e, e)); } }
From source file:com.github.javawithmarcus.wicket.cdi.CdiWebApplicationFactory.java
License:Apache License
@Override public WebApplication createApplication(WicketFilter filter) { WebApplication application;//from w ww.j av a2 s .c om if (applications == null) { application = super.createApplication(filter); } else { String appName = filter.getFilterConfig().getInitParameter(WICKET_APP_NAME); if (appName != null) { try { ApplicationQualifier qualifier = new ApplicationQualifier(appName); application = applications.select(qualifier).get(); log.info("Found WicketApp('{}') annotated WebApplication: {} ", appName, application.getClass()); } catch (IllegalArgumentException iae) { log.error("The init param {} set to {} is either has no @Named parameter or duplicates.", WICKET_APP_NAME, appName); throw iae; } catch (UnsatisfiedResolutionException ure) { log.error( "The init param {} set to {} requires a WebApplication to be annotated with @Named(\"{}\").", new Object[] { WICKET_APP_NAME, appName, appName }); throw ure; } } else { Iterator<WebApplication> possibleApps = applications.iterator(); try { application = possibleApps.next(); } catch (NoSuchElementException nsee) { log.error( "The classLoader does not contain any WebApplications. Please create a WebApplication."); throw new RuntimeException("Missing WebApplication"); } if (possibleApps.hasNext()) { log.error( "Multiple WebApplications are in the classloader. This requires using @Named parameter on WebApplication" + " and setting the init-param {} with the matching name in web.xml", WICKET_APP_NAME); throw new IllegalArgumentException("Missing init-param " + WICKET_APP_NAME + " to match against multiple WebApplications in classLoader. "); } log.info("Found Single WebApplication: {}", application.getClass()); } overrideApplicationInjection = true; // Already injected so don't let CdiConfiguration reinject it. } ConfigurationParameters parameters = buildParameters(filter.getFilterConfig()); CdiConfiguration.get().configure(filter.getFilterConfig().getFilterName(), application, parameters); return application; }
From source file:jp.comuri.wicket.PicoContainerWebApplicationFactory.java
License:Apache License
public WebApplication createApplication(WicketFilter filter) { PicoContainer container;//w ww . java 2 s . c o m String containerContextAttribute = filter.getFilterConfig().getInitParameter("containerContextAttribute"); if (containerContextAttribute != null) { ServletContext sc = filter.getFilterConfig().getServletContext(); container = (PicoContainer) sc.getAttribute(containerContextAttribute); if (container == null) { throw new RuntimeException("Could not find PicoContainer in the ServletContext under attribute: " + containerContextAttribute); } } else if (filter.getFilterConfig().getInitParameter("container") != null) { String paramValue = filter.getFilterConfig().getInitParameter("container"); String containerName = paramValue.trim(); try { Class<?> moduleClazz = Class.forName(containerName); container = (PicoContainer) moduleClazz.newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Could not create new instance of PicoContainer class " + containerName, e); } catch (ClassNotFoundException e) { throw new RuntimeException("Could not create new instance of PicoContainer class " + containerName, e); } catch (IllegalAccessException e) { throw new RuntimeException("Could not create new instance of PicoContainer class " + containerName, e); } } else { throw new RuntimeException( "To use PicoContainerWebApplicationFactory, you must specify either an 'containerContextAttribute' or a 'container' init-param."); } WebApplication app = container.getComponent(WebApplication.class); app.addComponentInstantiationListener(new PicoContainerComponentInjector(app, container)); return app; }