1 2 24 package org.enhydra.tool.archive; 25 26 import org.enhydra.tool.archive.wizard.ArchiveWizard; 28 import org.enhydra.tool.common.PathHandle; 29 30 import java.io.File ; 32 import java.util.Properties ; 33 34 public class ArchiveTool { 36 37 private final String NULL_PLAN = "Archive plan is null"; 40 public ArchiveTool() {} 41 42 public File buildArchive(EarPlan plan) throws ArchiveException { 43 EarBuilder builder = null; 44 File file = null; 45 46 if (plan == null) { 47 throw new ArchiveException(NULL_PLAN); 48 } 49 builder = new EarBuilder(); 50 builder.setPlan(plan); 51 file = builder.buildArchive(); 52 return file; 53 } 54 55 public File buildArchive(EjbPlan plan) throws ArchiveException { 56 EjbBuilder builder = null; 57 File file = null; 58 59 if (plan == null) { 60 throw new ArchiveException(NULL_PLAN); 61 } 62 builder = new EjbBuilder(); 63 builder.setPlan(plan); 64 file = builder.buildArchive(); 65 return file; 66 } 67 68 public File buildArchive(WarPlan plan) throws ArchiveException { 69 WarBuilder builder = null; 70 File file = null; 71 72 if (plan == null) { 73 throw new ArchiveException(NULL_PLAN); 74 } 75 builder = new WarBuilder(); 76 builder.setPlan(plan); 77 file = builder.buildArchive(); 78 return file; 79 } 80 81 public File buildArchive(JarPlan plan) throws ArchiveException { 82 JarBuilder builder = null; 83 File file = null; 84 85 if (plan instanceof EjbPlan) { 86 file = buildArchive((EjbPlan) plan); 87 } else if (plan instanceof EarPlan) { 88 file = buildArchive((EarPlan) plan); 89 } else if (plan instanceof WarPlan) { 90 file = buildArchive((WarPlan) plan); 91 } else { 92 if (plan == null) { 93 throw new ArchiveException(NULL_PLAN); 94 } 95 builder = new JarBuilder(); 96 builder.setPlan(plan); 97 file = builder.buildArchive(); 98 } 99 return file; 100 } 101 102 public static JarPlan runWizard(int i) { 103 ArchiveWizard handler = null; 104 JarPlan plan = null; 105 106 handler = new ArchiveWizard(); 107 handler.showDialog(null); 108 plan = handler.getPlan(); 109 handler = null; 110 return plan; 111 112 } 113 public static String runWizard() { 114 JarPlan plan = null; 115 String newArchive = null; 116 plan = ArchiveTool.runWizard(0); 117 if (plan != null) { 118 newArchive = 119 PathHandle.createPathString(plan.getArchivePath()); 120 } 121 return newArchive; 122 } 123 124 } 125 | Popular Tags |