001 package org.apache.myfaces.tobago.bean; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with 006 * this work for additional information regarding copyright ownership. 007 * The ASF licenses this file to You under the Apache License, Version 2.0 008 * (the "License"); you may not use this file except in compliance with 009 * the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020 /* 021 * Created 26.10.2004 11:51:00. 022 * $Id: ResourceMap.java 923623 2010-03-16 08:23:23Z lofwyr $ 023 */ 024 025 import org.apache.commons.logging.Log; 026 import org.apache.commons.logging.LogFactory; 027 028 import java.io.IOException; 029 import java.io.InputStream; 030 import java.util.Properties; 031 032 /** 033 * @deprecated 034 */ 035 @Deprecated 036 public class ResourceMap extends Properties { 037 038 private static final Log LOG = LogFactory.getLog(ResourceMap.class); 039 private static final long serialVersionUID = -6696019120255349519L; 040 041 public ResourceMap() { 042 if (LOG.isDebugEnabled()) { 043 LOG.debug("creating ResourceMap"); 044 } 045 } 046 047 public void setFilename(String filename) { 048 if (LOG.isDebugEnabled()) { 049 LOG.debug("filename = '" + filename + "'"); 050 } 051 try { 052 InputStream is = getClass().getClassLoader().getResourceAsStream(filename); 053 if (is == null) { 054 LOG.error("Cannot load resource map from file: " + filename); 055 } 056 load(is); 057 } catch (IOException e) { 058 LOG.error("Cannot load resource map from file: " + filename, e); 059 } 060 if (LOG.isDebugEnabled()) { 061 LOG.debug("size() = \"" + size() + "\""); 062 for (Object x : keySet()) { 063 LOG.debug(x); 064 } 065 } 066 } 067 068 // setFilename() is never called with myfaces implementation, 069 // because we implement Map. This hotfix enables filename setting via put(). 070 public Object put(Object key, Object value) { 071 if ("filename".equals(key)) { 072 if (LOG.isDebugEnabled()) { 073 LOG.debug("put(\"filename\", \"" + value + "\")"); 074 } 075 setFilename(value.toString()); 076 } 077 return super.put(key, value); 078 } 079 080 public Object get(Object key) { 081 Object value = super.get(key); 082 if (LOG.isDebugEnabled()) { 083 LOG.debug("Query value for key='" + key + "' -> '" + value + "'"); 084 } 085 if (value == null) { 086 LOG.warn("Unknown value for key='" + key + "'"); 087 } 088 return value; 089 } 090 }