1 19 20 package org.apache.geronimo.mavenplugins.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 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 File metaInf = new File (tmpFile, "META-INF"); 65 metaInf.mkdirs(); 66 return tmpFile; 67 } 68 catch (IOException e) { 69 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); 78 } 79 80 Artifact configId = configurationData.getId(); 81 File targetFile = repository.getLocation(configId); 82 ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, null, targetFile); 83 } 84 85 public void uninstall(Artifact configID) throws NoSuchConfigException, IOException { 86 File targetFile = repository.getLocation(configID); 87 targetFile.delete(); 88 } 89 90 public List listConfigurations() { 91 throw new UnsupportedOperationException (); 92 } 93 94 public static final GBeanInfo GBEAN_INFO; 95 96 public static GBeanInfo getGBeanInfo() { 97 return GBEAN_INFO; 98 } 99 100 static { 101 GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(MavenConfigStore.class, "ConfigurationStore"); 102 builder.addAttribute("kernel", Kernel.class, false); 103 builder.addAttribute("objectName", String .class, false); 104 builder.addReference("Repository", WritableListableRepository.class, "Repository"); 105 builder.setConstructor(new String []{"kernel", "objectName", "Repository"}); 106 GBEAN_INFO = builder.getBeanInfo(); 107 } 108 } 109 | Popular Tags |