001/*
002 * (C) Copyright 2006-2007 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 *     Nuxeo - initial API and implementation
018 *
019 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
020 */
021
022package org.nuxeo.ecm.webapp.helpers;
023
024import java.util.HashMap;
025import java.util.Map;
026
027import org.apache.commons.logging.Log;
028import org.apache.commons.logging.LogFactory;
029import org.jboss.seam.ScopeType;
030import org.jboss.seam.annotations.In;
031import org.jboss.seam.annotations.Name;
032import org.jboss.seam.annotations.Scope;
033
034/**
035 * Global resources can be injected by Seam into a application scoped component that doesn't need to be serialized.
036 * <p>
037 * This circumvents possible Seam bugs in Seam post-activation injection problems regarding resource bundles.
038 *
039 * @author DM
040 * @deprecated since 5.6: this is useless and does not play well with hot reload enabled because component has scope
041 *             "Application". Just inject the component named "messages" in components needing translation features,
042 *             instead of making them extend this class.
043 */
044@Name("resourcesAccessor")
045@Scope(ScopeType.APPLICATION)
046@Deprecated
047public class ResourcesAccessorBean implements ResourcesAccessor {
048
049    private static final Log log = LogFactory.getLog(ResourcesAccessorBean.class);
050
051    /**
052     * Seam built-in component.
053     * <p>
054     * A map containing internationalized messages rendered from message templates defined in the Seam resource bundle.
055     */
056    @In(create = true)
057    private Map<String, String> messages;
058
059    public Map<String, String> getMessages() {
060        if (messages == null) {
061            log.warn("Unable to get message map");
062            return new HashMap<String, String>();
063        } else {
064            return messages;
065        }
066    }
067
068}