1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.geronimo.plugin.car;
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.util.List;
25
26 import org.apache.geronimo.gbean.GBeanInfo;
27 import org.apache.geronimo.gbean.GBeanInfoBuilder;
28 import org.apache.geronimo.kernel.config.ConfigurationData;
29 import org.apache.geronimo.kernel.config.InvalidConfigException;
30 import org.apache.geronimo.kernel.config.NoSuchConfigException;
31 import org.apache.geronimo.kernel.repository.Artifact;
32 import org.apache.geronimo.kernel.repository.WritableListableRepository;
33 import org.apache.geronimo.kernel.Kernel;
34 import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
35 import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
36
37 /**
38 * Implementation of ConfigurationStore that loads Configurations from a repository.
39 * This implementation is read-only on the assumption that a separate maven task will
40 * handle installation of a built package into the repository.
41 *
42 * @version $Rev: 451661 $ $Date: 2006-09-30 13:45:53 -0700 (Sat, 30 Sep 2006) $
43 */
44 public class MavenConfigStore
45 extends RepositoryConfigurationStore
46 {
47 public MavenConfigStore(Kernel kernel, String objectName, WritableListableRepository repository) {
48 super(kernel, objectName, repository);
49 }
50
51 public MavenConfigStore(WritableListableRepository repository) {
52 super(repository);
53 }
54
55 public File createNewConfigurationDir(Artifact configId) {
56 try {
57 File tmpFile = File.createTempFile("package", ".tmpdir");
58 tmpFile.delete();
59 tmpFile.mkdir();
60 if (!tmpFile.isDirectory()) {
61 return null;
62 }
63
64 File metaInf = new File(tmpFile, "META-INF");
65 metaInf.mkdirs();
66 return tmpFile;
67 }
68 catch (IOException e) {
69
70 return null;
71 }
72 }
73
74 public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
75 File source = configurationData.getConfigurationDir();
76 if (!source.isDirectory()) {
77 throw new InvalidConfigException("Source must be a directory: source=" + source);
78 }
79 Artifact configId = configurationData.getId();
80 File targetFile = repository.getLocation(configId);
81 ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, null, targetFile);
82 }
83
84 public void uninstall(Artifact configID) throws NoSuchConfigException, IOException {
85 File targetFile = repository.getLocation(configID);
86 targetFile.delete();
87 }
88
89 public List listConfigurations() {
90 throw new UnsupportedOperationException();
91 }
92
93 public static final GBeanInfo GBEAN_INFO;
94
95 public static GBeanInfo getGBeanInfo() {
96 return GBEAN_INFO;
97 }
98
99 static {
100 GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(MavenConfigStore.class, "ConfigurationStore");
101 builder.addAttribute("kernel", Kernel.class, false);
102 builder.addAttribute("objectName", String.class, false);
103 builder.addReference("Repository", WritableListableRepository.class, "Repository");
104 builder.setConstructor(new String[]{"kernel", "objectName", "Repository"});
105 GBEAN_INFO = builder.getBeanInfo();
106 }
107 }