001/*
002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Anahide Tchertchian
016 */
017package org.nuxeo.ecm.webapp.helpers;
018
019import static org.jboss.seam.annotations.Install.FRAMEWORK;
020
021import org.jboss.seam.ScopeType;
022import org.jboss.seam.annotations.Install;
023import org.jboss.seam.annotations.Name;
024import org.jboss.seam.annotations.Scope;
025import org.nuxeo.runtime.api.Framework;
026
027/**
028 * Seam component that exposes getters for properties managed by the runtime {@link Framework}.
029 *
030 * @since 5.5
031 */
032@Name("frameworkPropertyActions")
033@Scope(ScopeType.STATELESS)
034@Install(precedence = FRAMEWORK)
035public class FrameworkPropertyActions {
036
037    /**
038     * Returns the given property value from the {@link Framework} if any, otherwise null.
039     */
040    public String getProperty(String propertyName) {
041        return Framework.getProperty(propertyName);
042    }
043
044    /**
045     * Returns the given property value from the {@link Framework} if any, otherwise the given default value.
046     */
047    public String getProperty(String propertyName, String defaultValue) {
048        return Framework.getProperty(propertyName, defaultValue);
049    }
050
051    /**
052     * Returns true if given property has been setup to true (defaults to false if not set).
053     *
054     * @since 5.8
055     * @see {@link Framework#isBooleanPropertyTrue(String)}
056     */
057    public boolean isBooleanPropertyTrue(String propertyName) {
058        return Framework.isBooleanPropertyTrue(propertyName);
059    }
060}