1 26 27 package org.objectweb.openccm.packaging; 28 29 import org.objectweb.util.browser.api.MenuItem; 31 import org.objectweb.util.browser.api.MenuItemTreeView; 32 import org.objectweb.openccm.descriptor.componentassembly.gui.ComponentassemblyZipper; 33 34 38 public class AssemblyPackager 39 implements MenuItem 40 { 41 47 53 59 60 66 71 public int 72 getStatus(org.objectweb.util.browser.api.TreeView treeView) 73 { 74 return org.objectweb.util.browser.api.MenuItem.ENABLED_STATUS; 75 } 76 77 80 public void 81 actionPerformed(MenuItemTreeView e) 82 throws Exception 83 { 84 String action = e.getActionEvent().getActionCommand(); 85 86 org.objectweb.apollon.framework.Bean zeus_instance 88 = (org.objectweb.apollon.framework.Bean) 89 e.getSelectedObject(); 90 91 org.objectweb.util.browser.api.Entry entry 93 = e.getSelectedEntry(); 94 95 String descriptor_filename 98 = CCMSplitPane.get_file_by_id( 99 (String ) entry.getName() 100 ); 101 102 make_zip (zeus_instance, descriptor_filename); 104 } 105 106 113 public void 114 make_zip ( 115 org.objectweb.apollon.framework.Bean zeus_instance, 116 String descriptor_filename 117 ) 118 throws Exception 119 { 120 if (zeus_instance.idBean().equals("[Componentassembly] (id?)")) 121 { 122 throw new Exception ( 123 "Undefined Assembly ID for " 124 +descriptor_filename); 125 } 126 else 127 { 128 java.io.File zipfile 129 = new java.io.File ( 130 zeus_instance.idBean() 131 +".aar" 132 ); 133 134 System.err.println("Starting Assembly ARchive creation..."); 135 136 ZipFactory zip_factory 138 = new ZipFactory(); 139 140 zip_factory.setZipName(zipfile.getAbsolutePath()); 141 142 java.io.File original_descriptor_file 144 = new java.io.File ( 145 descriptor_filename 146 ); 147 java.io.File temp_descriptor_file 149 = new java.io.File ( 150 "META-INF" 151 +System.getProperty("file.separator") 152 +original_descriptor_file.getName() 153 ); 154 155 try 156 { 157 zeus_instance.marshalBean(temp_descriptor_file); 159 } catch (Exception except) { 160 except.printStackTrace(); 161 } 162 163 zip_factory 165 .addFileToZip( 166 temp_descriptor_file.getPath() 167 ); 168 169 ComponentassemblyZipper zipper 171 = (ComponentassemblyZipper) zeus_instance 172 .getExtensionManager() 173 .getExtensionByName("gui.Zipper") 174 .getInstance(); 175 zipper.zipCall( 176 (org.objectweb.openccm.descriptor 177 .componentassembly.beans.ComponentassemblyBean) 178 zeus_instance 179 , zip_factory); 180 181 try 183 { 184 zip_factory.buildZip(); 185 System.err.println("End of the AAR creation, writing file:"); 186 System.err.println(zipfile.getAbsolutePath()); 187 } catch (Exception exc) { 188 System.err.println("Assembly archive could not be built. See following stacktrace"); 189 exc.printStackTrace(); 190 } 191 } 192 } 193 } 194 | Popular Tags |