001/*
002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Anahide Tchertchian
018 */
019package org.nuxeo.ecm.webapp.helpers;
020
021import static org.jboss.seam.annotations.Install.FRAMEWORK;
022
023import org.jboss.seam.ScopeType;
024import org.jboss.seam.annotations.Install;
025import org.jboss.seam.annotations.Name;
026import org.jboss.seam.annotations.Scope;
027import org.nuxeo.runtime.api.Framework;
028
029/**
030 * Seam component that exposes getters for properties managed by the runtime {@link Framework}.
031 *
032 * @since 5.5
033 */
034@Name("frameworkPropertyActions")
035@Scope(ScopeType.STATELESS)
036@Install(precedence = FRAMEWORK)
037public class FrameworkPropertyActions {
038
039    /**
040     * Returns the given property value from the {@link Framework} if any, otherwise null.
041     */
042    public String getProperty(String propertyName) {
043        return Framework.getProperty(propertyName);
044    }
045
046    /**
047     * Returns the given property value from the {@link Framework} if any, otherwise the given default value.
048     */
049    public String getProperty(String propertyName, String defaultValue) {
050        return Framework.getProperty(propertyName, defaultValue);
051    }
052
053    /**
054     * Returns true if given property has been setup to true (defaults to false if not set).
055     *
056     * @since 5.8
057     * @see {@link Framework#isBooleanPropertyTrue(String)}
058     */
059    public boolean isBooleanPropertyTrue(String propertyName) {
060        return Framework.isBooleanPropertyTrue(propertyName);
061    }
062}