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.hivemind.service.impl;
016
017 import java.util.HashMap;
018 import java.util.List;
019 import java.util.Map;
020
021 import org.apache.hivemind.SymbolSource;
022 import org.apache.hivemind.impl.BaseLocatable;
023
024 /**
025 * Implementation of {@link org.apache.hivemind.SymbolSource} driven off of an extension point.
026 *
027 * @author Howard Lewis Ship
028 */
029 public class DefaultsSymbolSource extends BaseLocatable implements SymbolSource
030 {
031 private List _defaults;
032
033 private Map _symbols = new HashMap();
034
035 public String valueForSymbol(String name)
036 {
037 return (String) _symbols.get(name);
038 }
039
040 public void initializeService()
041 {
042 int count = _defaults.size();
043 for (int i = 0; i < count; i++)
044 {
045 FactoryDefault fd = (FactoryDefault) _defaults.get(i);
046
047 String symbol = fd.getSymbol();
048 String value = fd.getValue();
049
050 _symbols.put(symbol, value);
051 }
052 }
053
054 public void setDefaults(List list)
055 {
056 _defaults = list;
057 }
058 }