1 /**************************************************************** 2 * Licensed to the Apache Software Foundation (ASF) under one * 3 * or more contributor license agreements. See the NOTICE file * 4 * distributed with this work for additional information * 5 * regarding copyright ownership. The ASF licenses this file * 6 * to you under the Apache License, Version 2.0 (the * 7 * "License"); you may not use this file except in compliance * 8 * with the License. You may obtain a copy of the License at * 9 * * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, * 13 * software distributed under the License is distributed on an * 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * 15 * KIND, either express or implied. See the License for the * 16 * specific language governing permissions and limitations * 17 * under the License. * 18 ****************************************************************/ 19 20 21 22 package org.apache.james.core; 23 24 import org.apache.avalon.framework.configuration.Configuration; 25 26 import org.apache.james.api.vut.VirtualUserTable; 27 import org.apache.james.api.vut.VirtualUserTableStore; 28 29 import java.util.Iterator; 30 31 /** 32 * Provides a registry of VirtualUserTables 33 * 34 */ 35 public class AvalonVirtualUserTableStore 36 extends AbstractAvalonStore 37 implements VirtualUserTableStore { 38 39 40 /** 41 * Get the repository, if any, whose name corresponds to 42 * the argument parameter 43 * 44 * @param name the name of the desired repository 45 * 46 * @return the VirtualUserTable corresponding to the name parameter 47 */ 48 public VirtualUserTable getTable(String name) { 49 VirtualUserTable response = (VirtualUserTable) getObject(name); 50 if ((response == null) && (getLogger().isWarnEnabled())) { 51 getLogger().warn("No virtualUserTable called: " + name); 52 } 53 return response; 54 } 55 56 /** 57 * Yield an <code>Iterator</code> over the set of repository 58 * names managed internally by this store. 59 * 60 * @return an Iterator over the set of repository names 61 * for this store 62 */ 63 public Iterator getTableNames() { 64 return getObjectNames(); 65 } 66 67 /** 68 * @see org.apache.james.core.AbstractAvalonStore#getClassInstance(ClassLoader, String) 69 */ 70 public Object getClassInstance(ClassLoader loader, String repClass) throws Exception { 71 return (VirtualUserTable) loader.loadClass(repClass).newInstance(); 72 } 73 74 /** 75 * @see org.apache.james.core.AbstractAvalonStore#getConfigurations(org.apache.avalon.framework.configuration.Configuration) 76 */ 77 public Configuration[] getConfigurations(Configuration config) { 78 return configuration.getChildren("table"); 79 } 80 81 /** 82 * @see org.apache.james.core.AbstractAvalonStore#getStoreName() 83 */ 84 public String getStoreName() { 85 return "AvalonVirtualUserTableStore"; 86 } 87 }