KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > j2ee > deployment > MockConfigStore


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

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 JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.net.MalformedURLException JavaDoc;
32 import java.util.HashMap JavaDoc;
33 import java.util.Map JavaDoc;
34 import java.util.Set JavaDoc;
35
36 /**
37  * ???
38  *
39  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
40  */

41 public class MockConfigStore
42     extends NullConfigurationStore
43 {
44     protected static final Naming naming = new Jsr77Naming();
45     
46     protected final Map JavaDoc locations = new HashMap JavaDoc();
47
48     public ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException JavaDoc, 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 JavaDoc createNewConfigurationDir(Artifact configId) {
59         try {
60             File JavaDoc file = DeploymentUtil.createTempDir();
61             locations.put(configId, file);
62             return file;
63         } catch (IOException JavaDoc e) {
64             return null;
65         }
66     }
67
68     public Set JavaDoc resolve(Artifact configId, String JavaDoc moduleName, String JavaDoc pattern) throws NoSuchConfigException, MalformedURLException JavaDoc {
69         File JavaDoc file = (File JavaDoc) locations.get(configId);
70         if (file == null) {
71             throw new NoSuchConfigException(configId);
72         }
73         Set JavaDoc matches = IOUtil.search(file, pattern);
74         return matches;
75     }
76 }
77
Popular Tags