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