1 17 package org.apache.geronimo.j2ee.deployment; 18 19 import org.apache.geronimo.deployment.util.DeploymentUtil; 20 import org.apache.geronimo.kernel.Jsr77Naming; 21 import org.apache.geronimo.kernel.Naming; 22 import org.apache.geronimo.kernel.config.ConfigurationData; 23 import org.apache.geronimo.kernel.config.IOUtil; 24 import org.apache.geronimo.kernel.config.InvalidConfigException; 25 import org.apache.geronimo.kernel.config.NoSuchConfigException; 26 import org.apache.geronimo.kernel.config.NullConfigurationStore; 27 import org.apache.geronimo.kernel.repository.Artifact; 28 29 import java.io.File ; 30 import java.io.IOException ; 31 import java.net.MalformedURLException ; 32 import java.util.HashMap ; 33 import java.util.Map ; 34 import java.util.Set ; 35 36 41 public class MockConfigStore 42 extends NullConfigurationStore 43 { 44 protected static final Naming naming = new Jsr77Naming(); 45 46 protected final Map locations = new HashMap (); 47 48 public ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException , InvalidConfigException { 49 ConfigurationData configurationData = new ConfigurationData(configId, naming); 50 configurationData.setConfigurationStore(this); 51 return configurationData; 52 } 53 54 public boolean containsConfiguration(Artifact configID) { 55 return true; 56 } 57 58 public File createNewConfigurationDir(Artifact configId) { 59 try { 60 File file = DeploymentUtil.createTempDir(); 61 locations.put(configId, file); 62 return file; 63 } catch (IOException e) { 64 return null; 65 } 66 } 67 68 public Set resolve(Artifact configId, String moduleName, String pattern) throws NoSuchConfigException, MalformedURLException { 69 File file = (File ) locations.get(configId); 70 if (file == null) { 71 throw new NoSuchConfigException(configId); 72 } 73 Set matches = IOUtil.search(file, pattern); 74 return matches; 75 } 76 } 77 | Popular Tags |