List of usage examples for org.apache.wicket RuntimeConfigurationType DEVELOPMENT
RuntimeConfigurationType DEVELOPMENT
To view the source code for org.apache.wicket RuntimeConfigurationType DEVELOPMENT.
Click Source Link
From source file:org.hippoecm.frontend.plugin.impl.PluginContext.java
License:Apache License
private void writeObject(ObjectOutputStream output) throws IOException { if (stopping && Application.exists()) { if (Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT)) { throw new WicketRuntimeException("Stopped plugin is still being referenced: " + (plugin != null ? plugin.getClass().getName() : "unknown")); }/*from www. j ava 2s .com*/ } output.defaultWriteObject(); }
From source file:org.hippoecm.frontend.plugins.ckeditor.CKEditorPanel.java
License:Apache License
public static ResourceReference getCKEditorJsReference() { if (Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT) && CKEditorConstants.existsOnClassPath(CKEditorConstants.CKEDITOR_SRC_JS)) { log.info("Using non-optimized CKEditor sources."); return CKEditorConstants.CKEDITOR_SRC_JS; }/* w w w. j a v a2 s . c o m*/ log.info("Using optimized CKEditor sources"); return CKEditorConstants.CKEDITOR_OPTIMIZED_JS; }
From source file:org.hippoecm.frontend.plugins.standards.ClassResourceModel.java
License:Apache License
@Override protected String load() { Iterator<IStringResourceLoader> iter = Application.get().getResourceSettings().getStringResourceLoaders() .iterator();//from ww w .java 2 s .c o m String value = null; while (iter.hasNext()) { IStringResourceLoader loader = iter.next(); value = loader.loadStringResource(clazz, key, locale, style, null); if (value != null) { break; } } if (value != null) { if (parameters != null) { final MessageFormat format = new MessageFormat(value, locale); value = format.format(parameters); } return value; } if (RuntimeConfigurationType.DEVELOPMENT.equals(Application.get().getConfigurationType())) { throw new RuntimeException("No translation found for " + this); } else { return key; } }
From source file:org.hippoecm.frontend.plugins.yui.header.YuiHeaderCache.java
License:Apache License
private static boolean isDebugEnabled() { return Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT); }
From source file:org.hippoecm.frontend.util.WebApplicationHelper.java
License:Apache License
public static boolean isDevelopmentMode() { return Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT); }
From source file:org.jaulp.wicket.base.util.application.ApplicationUtils.java
License:Apache License
/** * Sets the RootRequestMapper for the given application from the given httpPort and httpsPort. * Note: if the configuration type is RuntimeConfigurationType.DEVELOPMENT then only HTTP scheme * will be returned.//from w w w . j a v a 2s . c o m * * @param application * the application * @param httpPort * the http port * @param httpsPort * the https port */ public static void setRootRequestMapperForDevelopment(final Application application, final int httpPort, final int httpsPort) { application.setRootRequestMapper( new HttpsMapper(application.getRootRequestMapper(), new HttpsConfig(httpPort, httpsPort)) { @Override protected Scheme getDesiredSchemeFor(Class<? extends IRequestablePage> pageClass) { if (application.getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT)) { // is in development mode, returning Scheme.HTTP... return Scheme.HTTP; } else { // not in development mode, letting the mapper decide return super.getDesiredSchemeFor(pageClass); } } }); }
From source file:org.lbogdanov.poker.web.AppInitializer.java
License:Apache License
/** * {@inheritDoc}//from ww w . j av a 2 s .co m */ @Override protected Injector getInjector() { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); try { InputStream settings = Resources.newInputStreamSupplier(Resources.getResource("settings.properties")) .getInput(); Properties props = new Properties(); try { props.load(settings); } finally { settings.close(); } Settings.init(Maps.fromProperties(props)); } catch (IOException ioe) { throw Throwables.propagate(ioe); } final boolean isDevel = DEVELOPMENT_MODE.asBool().or(false); Module shiroModule = new ShiroWebModule(servletContext) { @Override @SuppressWarnings("unchecked") protected void configureShiroWeb() { bind(String.class).annotatedWith(Names.named(InjectableOAuthFilter.FAILURE_URL_PARAM)) .toInstance("/"); // TODO simple ini-based realm for development bindRealm().toInstance(new IniRealm(IniFactorySupport.loadDefaultClassPathIni())); bindRealm().to(InjectableOAuthRealm.class).in(Singleton.class); addFilterChain("/" + Constants.OAUTH_CLBK_FILTER_URL, Key.get(InjectableOAuthFilter.class)); addFilterChain("/" + Constants.OAUTH_FILTER_URL, config(CallbackUrlSetterFilter.class, Constants.OAUTH_CLBK_FILTER_URL), Key.get(InjectableOAuthUserFilter.class)); } @Provides @Singleton private OAuthProvider getOAuthProvider() { Google2Provider provider = new Google2Provider(); provider.setKey(GOOGLE_OAUTH_KEY.asString().get()); provider.setSecret(GOOGLE_OAUTH_SECRET.asString().get()); provider.setCallbackUrl("example.com"); // fake URL, will be replaced by CallbackUrlSetterFilter provider.setScope(Google2Scope.EMAIL_AND_PROFILE); return provider; } }; Module appModule = new ServletModule() { @Override protected void configureServlets() { ServerConfig dbConfig = new ServerConfig(); String jndiDataSource = DB_DATA_SOURCE.asString().orNull(); if (Strings.isNullOrEmpty(jndiDataSource)) { // use direct JDBC connection DataSourceConfig dsConfig = new DataSourceConfig(); dsConfig.setDriver(DB_DRIVER.asString().get()); dsConfig.setUrl(DB_URL.asString().get()); dsConfig.setUsername(DB_USER.asString().orNull()); dsConfig.setPassword(DB_PASSWORD.asString().orNull()); dbConfig.setDataSourceConfig(dsConfig); } else { dbConfig.setDataSourceJndiName(jndiDataSource); } dbConfig.setName("PlanningPoker"); dbConfig.setDefaultServer(true); dbConfig.addClass(Session.class); dbConfig.addClass(User.class); bind(EbeanServer.class).toInstance(EbeanServerFactory.create(dbConfig)); bind(SessionService.class).to(SessionServiceImpl.class); bind(UserService.class).to(UserServiceImpl.class); bind(WebApplication.class).to(PokerWebApplication.class); bind(MeteorServlet.class).in(Singleton.class); bind(ObjectMapper.class).toProvider(new Provider<ObjectMapper>() { @Override public ObjectMapper get() { SimpleModule module = new SimpleModule().addSerializer(UserSerializer.get()); return new ObjectMapper().registerModule(module); } }).in(Singleton.class); String wicketConfig = (isDevel ? RuntimeConfigurationType.DEVELOPMENT : RuntimeConfigurationType.DEPLOYMENT).toString(); ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); params.put(ApplicationConfig.FILTER_CLASS, WicketFilter.class.getName()) .put(ApplicationConfig.PROPERTY_SESSION_SUPPORT, Boolean.TRUE.toString()) .put(ApplicationConfig.BROADCAST_FILTER_CLASSES, TrackMessageSizeFilter.class.getName()) .put(ApplicationConfig.BROADCASTER_CACHE, UUIDBroadcasterCache.class.getName()) .put(ApplicationConfig.SHOW_SUPPORT_MESSAGE, Boolean.FALSE.toString()) .put(WicketFilter.FILTER_MAPPING_PARAM, "/*") .put(WebApplication.CONFIGURATION, wicketConfig) .put(WicketFilter.APP_FACT_PARAM, GuiceWebApplicationFactory.class.getName()) .put("injectorContextAttribute", Injector.class.getName()).build(); serve("/*").with(MeteorServlet.class, params.build()); } }; Stage stage = isDevel ? Stage.DEVELOPMENT : Stage.PRODUCTION; return Guice.createInjector(stage, ShiroWebModule.guiceFilterModule(), shiroModule, appModule); }
From source file:org.projectforge.web.wicket.WicketApplication.java
License:Open Source License
/** * Own solution: uses development parameter of servlet context init parameter (see context.xml or server.xml). * @return DEVELOPMENT, if development variable of servlet context is set to "true" otherwise DEPLOYMENT. * @see org.apache.wicket.protocol.http.WebApplication#getConfigurationType() *///ww w . j a v a 2 s .c o m @Override public RuntimeConfigurationType getConfigurationType() { if (isDevelopmentSystem() == true) { return RuntimeConfigurationType.DEVELOPMENT; } return RuntimeConfigurationType.DEPLOYMENT; }
From source file:org.seasar.wicket.S2WicketFilter.java
License:Apache License
private void initInternal(final boolean isServlet, FilterConfig filterConfig) throws ServletException { // ???????????? destroy();//from ww w.ja va 2 s . c o m // ??? configuration = getInitParameter(filterConfig, "configuration", "development").toUpperCase(); configPath = getInitParameter(filterConfig, "configPath", "app.dicon"); debug = getInitParameter(filterConfig, "debug", null); reloadingClassPattern = getInitParameter(filterConfig, "reloadingClassPattern", null); useReloadingClassLoader = RuntimeConfigurationType.DEVELOPMENT.name().equalsIgnoreCase(configuration) && reloadingClassPattern != null; if (logger.isInfoEnabled()) { logger.info("[config] configuration='{}'", configuration); logger.info("[config] configPath='{}'", configPath); logger.info("[config] debug='{}'", debug); logger.info("[config] reloadingClassPattern='{}'", reloadingClassPattern); } if (RuntimeConfigurationType.DEVELOPMENT == RuntimeConfigurationType.valueOf(configuration) && reloadingClassPattern != null) { ReloadingClassLoader.getPatterns().clear(); // ?????????? // ??????????? for (String classPattern : reloadingClassPattern.split(",")) { if (!classPattern.startsWith("-")) { ReloadingClassLoader.includePattern(classPattern); } else { ReloadingClassLoader.excludePattern(classPattern.substring(1)); } } for (URL str : ReloadingClassLoader.getLocations()) { logger.info("[classpath] {}", str); } for (String str : ReloadingClassLoader.getPatterns()) { logger.info("[pattern] {}", str); } } ComponentDeployerFactory.setProvider(new ExternalComponentDeployerProvider()); S2Container s2container = S2ContainerFactory.create(configPath, getClassLoader()); s2container.setExternalContext(new HttpServletExternalContext()); s2container.setExternalContextComponentDefRegister(new HttpServletExternalContextComponentDefRegister()); s2container.getExternalContext().setApplication(filterConfig.getServletContext()); s2container.init(); SingletonS2ContainerFactory.setContainer(s2container); if (SmartDeployUtil.isHotdeployMode(SingletonS2ContainerFactory.getContainer())) { throw new ServletException("S2Wicket does not support HOT deploy mode."); } // Application???getHomePage()?????? // ???????????? super.init(isServlet, filterConfig); // ???WebApplication????????? WebApplication webApplication = (WebApplication) Application.get(filterConfig.getFilterName()); webApplication.getComponentInstantiationListeners().add(new ComponentInjectionListener()); applicationConfigType = webApplication.getConfigurationType(); applicationEncoding = webApplication.getRequestCycleSettings().getResponseRequestEncoding(); if (RuntimeConfigurationType.DEVELOPMENT == RuntimeConfigurationType.valueOf(configuration)) { webApplication.getFrameworkSettings() .setSerializer(new ReloadingJavaSerializer(webApplication.getApplicationKey())); if (debug != null) { webApplication.mountPage(debug, S2DebugPage.class); } } }
From source file:org.seasar.wicket.S2WicketFilter.java
License:Apache License
@SuppressWarnings("unchecked") @Override/*from w w w . j a va 2 s. c om*/ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (RuntimeConfigurationType.DEVELOPMENT == applicationConfigType) { if (request instanceof HttpServletRequest) { // ??????? HttpSession session = ((HttpServletRequest) request).getSession(); ClassLoader previousLoader = (ClassLoader) session.getAttribute(SESSION_LOADER); if (previousLoader != getClassLoader()) { logger.info("[reload] invalidate old session attributes ..."); Enumeration<String> names = session.getAttributeNames(); while (names.hasMoreElements()) { String name = names.nextElement(); Object obj = session.getAttribute(name); ClassLoader objectLoader = obj != null ? obj.getClass().getClassLoader() : null; if (previousLoader == null || objectLoader == previousLoader) { session.removeAttribute(name); } } } session.setAttribute(SESSION_LOADER, getClassLoader()); } } if (request.getCharacterEncoding() == null) { request.setCharacterEncoding(applicationEncoding); } // S2ContainerFilter????? S2Container container = SingletonS2ContainerFactory.getContainer(); ExternalContext externalContext = container.getExternalContext(); if (externalContext == null) { throw new EmptyRuntimeException("externalContext"); } final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); final Object originalRequest = externalContext.getRequest(); final Object originalResponse = externalContext.getResponse(); try { Thread.currentThread().setContextClassLoader(getClassLoader()); externalContext.setRequest(request); externalContext.setResponse(response); super.doFilter(request, response, chain); } finally { externalContext.setRequest(originalRequest); externalContext.setResponse(originalResponse); Thread.currentThread().setContextClassLoader(originalClassLoader); invalidateSession(request); } }