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.apache.openmeetings.web.app.Application.java
License:Apache License
public static String getString(String key, final Locale loc, boolean noReplace) { if (!exists()) { ThreadContext.setApplication(Application.get(appName)); }//w w w . j ava 2s . c om Localizer l = get().getResourceSettings().getLocalizer(); String value = l.getStringIgnoreSettings(key, null, null, loc, null, "[Missing]"); if (!noReplace && STRINGS_WITH_APP.contains(key)) { final MessageFormat format = new MessageFormat(value, loc); value = format.format(new Object[] { getBean(ConfigurationDao.class).getAppName() }); } if (!noReplace && RuntimeConfigurationType.DEVELOPMENT == get().getConfigurationType()) { value += String.format(" [%s]", key); } return value; }
From source file:org.apache.openmeetings.web.pages.BasePage.java
License:Apache License
@Override public void renderHead(IHeaderResponse response) { response.render(new PriorityHeaderItem(JavaScriptHeaderItem .forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference()))); super.renderHead(response); response.render(CssReferenceHeaderItem.forUrl(String.format("css/theme_om/jquery-ui.%scss", RuntimeConfigurationType.DEVELOPMENT == getApplication().getConfigurationType() ? "" : "min."))); if (isRtl()) { response.render(CssHeaderItem.forUrl("css/theme-rtl.css")); response.render(CssHeaderItem.forUrl("css/admin-rtl.css")); }//from w w w. ja v a2 s . com if (!Strings.isEmpty(getGaCode())) { response.render(new PriorityHeaderItem(JavaScriptHeaderItem .forReference(new JavaScriptResourceReference(BasePage.class, "om-ga.js")))); StringBuilder script = new StringBuilder("initGA('"); script.append(getGaCode()).append("');").append(isMainPage() ? "initHash()" : "init()").append(';'); response.render(OnDomReadyHeaderItem.forScript(script)); } }
From source file:org.apache.openmeetings.web.user.rooms.RoomPanel.java
License:Apache License
private String getFlashFile() { return RuntimeConfigurationType.DEVELOPMENT == getApplication().getConfigurationType() ? "maindebug.as3.swf11.swf" : "main.as3.swf11.swf"; }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryApplication.java
License:Open Source License
@Override public RuntimeConfigurationType getConfigurationType() { //Init the modes from the constants if needed if (modes.isEmpty()) { // use configuration from the servlet context since properties are not bound to the thread when this method is called ArtifactoryHome artifactoryHome = getArtifactoryContext().getArtifactoryHome(); ArtifactorySystemProperties artifactorySystemProperties = artifactoryHome.getArtifactoryProperties(); /*if (Boolean.parseBoolean(artifactorySystemProperties.getProperty(ConstantValues.dev))) { modes.add(ConstantValues.dev);// w w w. java 2 s.co m }*/ if (Boolean.parseBoolean(artifactorySystemProperties.getProperty(ConstantValues.test))) { modes.add(ConstantValues.test); } if (Boolean.parseBoolean(artifactorySystemProperties.getProperty(ConstantValues.qa))) { modes.add(ConstantValues.qa); } } if (modes.contains(ConstantValues.dev)) { return RuntimeConfigurationType.DEVELOPMENT; } else { return super.getConfigurationType(); } }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryApplication.java
License:Open Source License
boolean isDevelopmentMode() { return RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType()); }
From source file:org.cast.cwm.components.DeployJava.java
License:Open Source License
/** * Constructor that will load a certain jar and class as an applet. Will do its best * to search for a jar file beginning with "jarName" in the /WEB-INF/lib folder * and add it as a shared resource for this application, if necessary. * //from ww w .j av a 2s . co m * Usage Example: new DeployJava("appletId", "awesome-applet", "org.example.Applet") * * The above example will find /WEB-INF/lib/awesome-applet-1.0-SNAPSHOT.jar and add it * as a shared resource under the DeployJava.class. * * @param id * @param jarName * @param className */ public DeployJava(String id, String jarName, String className) { super(id); if (Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT)) setArchive(getSharedArchiveURL(jarName) + "?" + System.currentTimeMillis()); else setArchive(getSharedArchiveURL(jarName)); setCode(className); }
From source file:org.cast.isi.ISIApplication.java
License:Open Source License
protected void init() { log.debug("Starting ISI Application Init"); // TODO heikki find out which component requires this, and replace it with something empty in case this is not enabled getDebugSettings().setDevelopmentUtilitiesEnabled(true); // Set xml content Section and Page based on property file - these have to be set before // the super.init is called sectionElement = configuration.getProperty("isi.sectionElement"); pageElement = configuration.getProperty("isi.pageElement"); super.init(); ISIEmailService.useAsServiceInstance(); responseMetadata = new ResponseMetadata(); getMarkupSettings().setDefaultBeforeDisabledLink(""); getMarkupSettings().setDefaultAfterDisabledLink(""); // Strip tags so that jQuery traversal doesn't break getMarkupSettings().setStripWicketTags(true); // Tells ResourceFinder to look in skin directory before looking in context dir. if (getCustomSkinDir() != null) getResourceSettings().addResourceFolder(getCustomSkinDir()); getResourceSettings().addResourceFolder(getSkinDir()); // Content elements are taggable TagService.get().configureTaggableClass('P', ContentElement.class); String requestedTags = configuration.getProperty("isi.defaultTags"); if (StringUtils.isEmpty(requestedTags)) { requestedTags = ""; }/*from www . j av a2s .c o m*/ if (!Strings.isEmpty(requestedTags)) TagService.get().setDefaultTags(Arrays.asList(requestedTags.split("\\s*,\\s*"))); configureResponseTypes(); configureResponseSort(); // load the xml documents and xsl transformers loadXmlFiles(); loadXslFiles(); // Tell dialog border to not use it's css List<ResourceReference> noStylesheets = Collections.emptyList(); DialogBorder.setStyleReferences(noStylesheets); // TODO heikki: SecurePackageResourceGuard subclasses cause errors for some resources. For the moment, use PackageResourceGuard. //getResourceSettings().setPackageResourceGuard(new ISIPackageResourceGuard()); //getResourceSettings().setPackageResourceGuard(new CwmPackageResourceGuard()); getResourceSettings().setPackageResourceGuard(new PackageResourceGuard()); this.getRequestCycleListeners().add(new AbstractRequestCycleListener() { @Override public IRequestHandler onException(RequestCycle cycle, Exception x) { if (x instanceof StalePageException) return null; // use normal exception processing for these PageParameters pageParameters = requestParameters2PageParameters( cycle.getRequest().getQueryParameters()); return new RenderPageRequestHandler( new PageProvider(new ExceptionPage(pageParameters, new RuntimeException(x)))); } }); if (highlightsPanelOn) registerHighlighters(); // Generally helpful log statement. if (!RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) { log.warn("********************** Wicket is running in Deployment Mode **********************"); } log.debug("Finished ISI Application Init"); }
From source file:org.devgateway.eudevfin.ui.common.pages.HeaderFooter.java
License:Open Source License
protected void initialize() { add(new HtmlTag("html")); add(new OptimizedMobileViewportMetaTag("viewport")); add(new ChromeFrameMetaTag("chrome-frame")); // add the navigation bar add(createNavBar());//from www. j ava 2 s . co m add(new HeaderResponseContainer("footer-container", "footer-container")); add(new BootstrapBaseBehavior()); add(new Label("eudevfin-version", Model.of(commonProperties.getProperty("eudevfin.version")))); try { // check if the key is missing in the resource file getString(getClassName() + ".page.title"); pageTitle = new Label("pageTitle", new StringResourceModel(getClassName() + ".page.title", this, null, null)); } catch (MissingResourceException mre) { pageTitle = new Label("pageTitle", new StringResourceModel("page.title", this, null, null)); } add(pageTitle); if (RuntimeConfigurationType.DEVELOPMENT.equals(this.getApplication().getConfigurationType())) { DebugBar debugBar = new DebugBar("dev"); add(debugBar); } else { add(new EmptyPanel("dev").setVisible(false)); } // add footer image add(new Image("eclogo", new ContextRelativeResource("/images/ec-logo-english.gif"))); }
From source file:org.geoserver.backuprestore.web.BackupRestoreWebUtils.java
License:Open Source License
static boolean isDevMode() { return RuntimeConfigurationType.DEVELOPMENT == GeoServerApplication.get().getConfigurationType(); }
From source file:org.hippoecm.frontend.Main.java
License:Apache License
@Override protected void init() { super.init(); addRequestCycleListeners();//from w w w .jav a 2 s. co m registerSessionListeners(); getPageSettings().setVersionPagesByDefault(false); // getPageSettings().setAutomaticMultiWindowSupport(false); // getSessionSettings().setPageMapEvictionStrategy(new LeastRecentlyAccessedEvictionStrategy(1)); getApplicationSettings().setPageExpiredErrorPage(PageExpiredErrorPage.class); try { String cfgParam = getConfigurationParameter(MAXUPLOAD_PARAM, null); if (cfgParam != null && cfgParam.trim().length() > 0) { getApplicationSettings().setDefaultMaximumUploadSize(Bytes.valueOf(cfgParam)); } } catch (StringValueConversionException ex) { log.warn("Unable to parse number as specified by " + MAXUPLOAD_PARAM, ex); } final IClassResolver originalResolver = getApplicationSettings().getClassResolver(); getApplicationSettings().setClassResolver(new IClassResolver() { @Override public Class resolveClass(String name) throws ClassNotFoundException { if (Session.exists()) { UserSession session = UserSession.get(); ClassLoader loader = session.getClassLoader(); if (loader != null) { return session.getClassLoader().loadClass(name); } } return originalResolver.resolveClass(name); } @Override public Iterator<URL> getResources(String name) { List<URL> resources = new LinkedList<>(); for (Iterator<URL> iter = originalResolver.getResources(name); iter.hasNext();) { resources.add(iter.next()); } if (Session.exists()) { UserSession session = UserSession.get(); ClassLoader loader = session.getClassLoader(); if (loader != null) { try { for (Enumeration<URL> resourceEnum = session.getClassLoader() .getResources(name); resourceEnum.hasMoreElements();) { resources.add(resourceEnum.nextElement()); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return resources.iterator(); } @Override public ClassLoader getClassLoader() { return Main.class.getClassLoader(); } }); final IResourceSettings resourceSettings = getResourceSettings(); // replace current loaders with own list, starting with component-specific List<IStringResourceLoader> loaders = resourceSettings.getStringResourceLoaders(); loaders.add(new ClassFromKeyStringResourceLoader()); loaders.add(new IStringResourceLoader() { @Override public String loadStringResource(final Class<?> clazz, final String key, final Locale locale, final String style, final String variation) { return null; } @Override public String loadStringResource(final Component component, String key, final Locale locale, final String style, final String variation) { if (key.contains(",")) { key = key.substring(0, key.lastIndexOf(',')); return resourceSettings.getLocalizer().getStringIgnoreSettings(key, component, null, locale, style, variation); } return null; } }); if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) { resourceSettings.setCachingStrategy(new NoOpResourceCachingStrategy()); } else { resourceSettings.setCachingStrategy( new FilenameWithVersionResourceCachingStrategy(new LastModifiedResourceVersion())); } mount(new MountMapper("binaries", new IMountedRequestMapper() { @Override public IRequestHandler mapRequest(final Request request, final MountParameters mountParams) { String path = Strings.join("/", request.getUrl().getSegments()); try { javax.jcr.Session subSession = UserSession.get().getJcrSession(); Node node = ((HippoWorkspace) subSession.getWorkspace()).getHierarchyResolver() .getNode(subSession.getRootNode(), path); // YUCK: no exception! if (node == null) { log.info("no binary found at " + path); } else { if (node.isNodeType(HippoNodeType.NT_DOCUMENT)) { node = (Node) JcrHelper.getPrimaryItem(node); } return new JcrResourceRequestHandler(node); } } catch (PathNotFoundException e) { log.info("binary not found " + e.getMessage()); } catch (javax.jcr.LoginException ex) { log.warn(ex.getMessage()); } catch (RepositoryException ex) { log.error(ex.getMessage()); } return null; } @Override public int getCompatibilityScore(final Request request) { return 1; } @Override public Mount mapHandler(final IRequestHandler requestHandler) { return null; } })); String applicationName = getPluginApplicationName(); if (PLUGIN_APPLICATION_VALUE_CMS.equals(applicationName)) { // the following is only applicable and needed for the CMS application, not the Console /* * HST SAML kind of authentication handler needed for Template Composer integration * */ cmsContextService = (CmsInternalCmsContextService) HippoServiceRegistry .getService(CmsContextService.class); if (cmsContextService == null) { cmsContextServiceImpl = new CmsContextServiceImpl(); cmsContextService = cmsContextServiceImpl; HippoServiceRegistry.registerService(cmsContextServiceImpl, new Class[] { CmsContextService.class, CmsInternalCmsContextService.class }); } mount(new MountMapper("auth", new IMountedRequestMapper() { @Override public IRequestHandler mapRequest(final Request request, final MountParameters mountParams) { IRequestHandler requestTarget = new RenderPageRequestHandler( new PageProvider(getHomePage(), null), RedirectPolicy.AUTO_REDIRECT); IRequestParameters requestParameters = request.getRequestParameters(); final List<StringValue> cmsCSIDParams = requestParameters.getParameterValues("cmsCSID"); final List<StringValue> destinationPathParams = requestParameters .getParameterValues("destinationPath"); final String destinationPath = destinationPathParams != null && !destinationPathParams.isEmpty() ? destinationPathParams.get(0).toString() : null; PluginUserSession userSession = (PluginUserSession) Session.get(); final UserCredentials userCredentials = userSession.getUserCredentials(); HttpSession httpSession = ((ServletWebRequest) request).getContainerRequest().getSession(); final CmsSessionContext cmsSessionContext = CmsSessionContext.getContext(httpSession); if (destinationPath != null && destinationPath.startsWith("/") && (cmsSessionContext != null || userCredentials != null)) { requestTarget = new IRequestHandler() { @Override public void respond(IRequestCycle requestCycle) { String destinationUrl = RequestUtils.getFarthestUrlPrefix(request) + destinationPath; WebResponse response = (WebResponse) RequestCycle.get().getResponse(); String cmsCSID = cmsCSIDParams == null ? null : cmsCSIDParams.get(0) == null ? null : cmsCSIDParams.get(0).toString(); if (!cmsContextService.getId().equals(cmsCSID)) { // redirect to destinationURL and include marker that it is a retry. This way // the destination can choose to not redirect for SSO handshake again if it still does not // have a key if (destinationUrl.contains("?")) { response.sendRedirect(destinationUrl + "&retry"); } else { response.sendRedirect(destinationUrl + "?retry"); } return; } String cmsSessionContextId = cmsSessionContext != null ? cmsSessionContext.getId() : null; if (cmsSessionContextId == null) { CmsSessionContext newCmsSessionContext = cmsContextService.create(httpSession); CmsSessionUtil.populateCmsSessionContext(cmsContextService, newCmsSessionContext, userSession); cmsSessionContextId = newCmsSessionContext.getId(); } if (destinationUrl.contains("?")) { response.sendRedirect(destinationUrl + "&cmsCSID=" + cmsContextService.getId() + "&cmsSCID=" + cmsSessionContextId); } else { response.sendRedirect(destinationUrl + "?cmsCSID=" + cmsContextService.getId() + "&cmsSCID=" + cmsSessionContextId); } } @Override public void detach(IRequestCycle requestCycle) { //Nothing to detach. } }; } return requestTarget; } @Override public int getCompatibilityScore(final Request request) { return 0; } @Override public Mount mapHandler(final IRequestHandler requestHandler) { return null; } })); } // caching resource stream locator implementation that allows the class argument to be null. final IResourceStreamLocator resourceStreamLocator = resourceSettings.getResourceStreamLocator(); resourceSettings.setResourceStreamLocator(new IResourceStreamLocator() { @Override public IResourceStream locate(Class<?> clazz, final String path) { if (clazz == null) { clazz = CACHING_RESOURCE_STREAM_LOCATOR_CLASS; } return resourceStreamLocator.locate(clazz, path); } @Override public IResourceStream locate(Class<?> clazz, final String path, final String style, final String variation, final Locale locale, final String extension, final boolean strict) { if (clazz == null) { clazz = CACHING_RESOURCE_STREAM_LOCATOR_CLASS; } return resourceStreamLocator.locate(clazz, path, style, variation, locale, extension, strict); } @Override public IResourceNameIterator newResourceNameIterator(final String path, final Locale locale, final String style, final String variation, final String extension, final boolean strict) { return resourceStreamLocator.newResourceNameIterator(path, locale, style, variation, extension, strict); } }); if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) { // disable cache resourceSettings.getLocalizer().setEnableCache(false); final long timeout = NumberUtils.toLong( getConfigurationParameter(DEVELOPMENT_REQUEST_TIMEOUT_PARAM, null), DEFAULT_DEVELOPMENT_REQUEST_TIMEOUT_MS); if (timeout > 0L) { log.info("Setting wicket request timeout to {} ms.", timeout); getRequestCycleSettings().setTimeout(Duration.milliseconds(timeout)); } // render comments with component class names getDebugSettings().setOutputMarkupContainerClassName(true); // do not render Wicket-specific markup since it can break CSS getMarkupSettings().setStripWicketTags(true); } else { // don't serialize pages for performance setPageManagerProvider(new DefaultPageManagerProvider(this) { @Override protected IPageStore newPageStore(final IDataStore dataStore) { return new AmnesicPageStore(); } }); // don't throw on missing resource resourceSettings.setThrowExceptionOnMissingResource(false); // don't show exception page getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_NO_EXCEPTION_PAGE); final long timeout = NumberUtils .toLong(getConfigurationParameter(DEPLOYMENT_REQUEST_TIMEOUT_PARAM, null)); if (timeout > 0L) { log.info("Setting wicket request timeout to {} ms.", timeout); getRequestCycleSettings().setTimeout(Duration.milliseconds(timeout)); } } String outputWicketpaths = obtainOutputWicketPathsParameter(); if (outputWicketpaths != null && "true".equalsIgnoreCase(outputWicketpaths)) { getDebugSettings().setOutputComponentPath(true); } final IContextProvider<AjaxRequestTarget, Page> ajaxRequestTargetProvider = getAjaxRequestTargetProvider(); setAjaxRequestTargetProvider(context -> new PluginRequestTarget(ajaxRequestTargetProvider.get(context))); setPageRendererProvider(new IPageRendererProvider() { @Override public PageRenderer get(final RenderPageRequestHandler context) { return new WebPageRenderer(context) { @Override protected BufferedWebResponse renderPage(final Url targetUrl, final RequestCycle requestCycle) { IRequestHandler scheduled = requestCycle.getRequestHandlerScheduledAfterCurrent(); if (scheduled == null) { IRequestablePage page = getPage(); if (page instanceof Home) { Home home = (Home) page; home.processEvents(); home.render(null); } } return super.renderPage(targetUrl, requestCycle); } }; } }); // don't allow public access to any package resource (empty whitelist) by default resourceSettings.setPackageResourceGuard(new WhitelistedClassesResourceGuard()); if (log.isInfoEnabled()) { log.info("Hippo CMS application " + applicationName + " has started"); } }