001 // Copyright 2004, 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.services.impl; 016 017 import java.util.Locale; 018 import java.util.Properties; 019 020 import org.apache.hivemind.impl.AbstractMessages; 021 import org.apache.hivemind.util.Defense; 022 023 /** 024 * Implementation of {@link org.apache.hivemind.Messages}. This is basically a wrapper around an 025 * instance of {@link Properties}. This ensures that the properties are, in fact, read-only (which 026 * ensures that they don't have to be synchronized). 027 * 028 * @author Howard Lewis Ship 029 * @since 2.0.4 030 */ 031 032 public class ComponentMessages extends AbstractMessages 033 { 034 private final Properties _properties; 035 036 private final Locale _locale; 037 038 public ComponentMessages(Locale locale, Properties properties) 039 { 040 Defense.notNull(locale, "locale"); 041 Defense.notNull(properties, "properties"); 042 043 _locale = locale; 044 _properties = properties; 045 } 046 047 protected String findMessage(String key) 048 { 049 return _properties.getProperty(key); 050 } 051 052 protected Locale getLocale() 053 { 054 return _locale; 055 } 056 }