1 package org.enhydra.kelp.forte.services; 2 3 import java.io.File ; 4 import java.io.IOException ; 5 import java.util.Map ; 6 7 import org.enhydra.kelp.forte.node.ForteProject; 8 import org.enhydra.kelp.common.deployer.RunParameters; 9 import org.enhydra.tool.ToolBoxInfo; 10 11 import org.openide.execution.*; 12 import org.openide.util.HelpCtx; 13 import org.openide.util.NbBundle; 14 15 19 public class KelpExecutor extends ProcessExecutor { 20 21 private static final NbProcessDescriptor DEFAULT = new NbProcessDescriptor ( 22 "{" + Format.TAG_JAVAHOME + "}{" + Format.TAG_SEPARATOR + "}bin{" + Format.TAG_SEPARATOR + "}java", 25 "{" + MyFormat.TAG_MYOPTIONVAL + "} " ); 28 29 private String valueOfMyOption = ""; 31 32 public KelpExecutor () { 33 setExternalExecutor (DEFAULT); 35 } 36 37 public String getRunOption () { 38 if (valueOfMyOption.equals("")) 39 { 40 StringBuffer buf = new StringBuffer (); 41 ForteProject proj = new ForteProject(); 42 43 String easRoot = ToolBoxInfo.getEnhydraRoot(); 44 char sep = File.separatorChar; 45 char psep = File.pathSeparatorChar; 46 RunParameters rp = new RunParameters(proj); 47 48 buf.append("-cp \""); 49 buf.append(proj.getSourcePath()); 50 buf.append(psep); 51 buf.append(easRoot); 52 buf.append(sep); 53 buf.append("lib"); 54 buf.append(sep); 55 buf.append("build"); 56 buf.append(sep); 57 buf.append("toolbox.jar"); 58 59 buf.append(psep); 61 buf.append(easRoot); 62 buf.append(sep); 63 buf.append("lib"); 64 buf.append(sep); 65 buf.append("enhydra.jar"); 66 67 buf.append(psep); 69 buf.append(easRoot); 70 buf.append(sep); 71 buf.append("lib"); 72 buf.append(sep); 73 buf.append("servlet.jar"); 74 75 buf.append(psep); 77 buf.append(easRoot); 78 buf.append(sep); 79 buf.append("lib"); 80 buf.append(sep); 81 buf.append("tomcat.jar"); 82 83 buf.append(psep); 85 buf.append(easRoot); 86 buf.append(sep); 87 buf.append("lib"); 88 buf.append(sep); 89 buf.append("util.jar"); 90 91 buf.append(psep); 93 buf.append(easRoot); 94 buf.append(sep); 95 buf.append("lib"); 96 buf.append(sep); 97 buf.append("log4j.jar"); 98 99 buf.append(psep); 101 buf.append(easRoot); 102 buf.append(sep); 103 buf.append("dods"); 104 buf.append(sep); 105 buf.append("lib"); 106 buf.append(sep); 107 buf.append("dbmanager.jar"); 108 109 buf.append(psep); 110 buf.append(easRoot); 111 buf.append(sep); 112 buf.append("dods"); 113 buf.append(sep); 114 buf.append("lib"); 115 buf.append(sep); 116 buf.append("dbmanager-api.jar"); 117 118 buf.append(psep); 119 buf.append(easRoot); 120 buf.append(sep); 121 buf.append("dods"); 122 buf.append(sep); 123 buf.append("lib"); 124 buf.append(sep); 125 buf.append("dsconnection.jar"); 126 127 buf.append(psep); 128 buf.append(easRoot); 129 buf.append(sep); 130 buf.append("dods"); 131 buf.append(sep); 132 buf.append("lib"); 133 buf.append(sep); 134 buf.append("stdcaches.jar"); 135 136 buf.append(psep); 137 buf.append(easRoot); 138 buf.append(sep); 139 buf.append("dods"); 140 buf.append(sep); 141 buf.append("lib"); 142 buf.append(sep); 143 buf.append("stdconnection.jar"); 144 145 buf.append(psep); 146 buf.append(easRoot); 147 buf.append(sep); 148 buf.append("dods"); 149 buf.append(sep); 150 buf.append("lib"); 151 buf.append(sep); 152 buf.append("stdtransaction.jar"); 153 154 String s = System.getProperty("java.home"); 155 s = s.substring(0, s.lastIndexOf("jre")-1); 156 buf.append(psep); 157 buf.append(s); 158 buf.append(sep); 159 buf.append("lib"); 160 buf.append(sep); 161 buf.append("tools.jar"); 162 163 buf.append('\"'); 164 buf.append(' '); 165 buf.append(rp.getTCcpArg()); 166 buf.append(' '); 167 buf.append(rp.getPolicyArg()); 168 buf.append(' '); 169 buf.append(rp.getBootArg()); 170 buf.append(" StartServer "); 171 buf.append(rp.getAppParameters()); 172 setRunOption(buf.toString()); 173 } 174 return valueOfMyOption; 175 } 176 177 public synchronized void setRunOption (String nue) { 178 String old = valueOfMyOption; 179 valueOfMyOption = nue; 180 firePropertyChange ("valueOfMyOption", old, nue); 181 } 182 183 protected Process createProcess (ExecInfo info) throws IOException { 184 return getExternalExecutor ().exec (new MyFormat (info, 185 getClassPath (), 186 getBootClassPath (), 187 getRepositoryPath (), 188 getLibraryPath (), 189 getRunOption ())); 190 } 191 192 197 198 static class MyFormat extends Format { 199 200 static final String TAG_MYOPTIONVAL = "myOptionVal"; 203 MyFormat (ExecInfo info, NbClassPath classPath, NbClassPath bootClassPath, 204 NbClassPath repositoryPath, NbClassPath libraryPath, 205 String valueOfMyOption) { 207 super (info, classPath, bootClassPath, repositoryPath, libraryPath); 209 Map map = getMap (); 211 map.put (TAG_MYOPTIONVAL, valueOfMyOption); 212 } 213 214 } 215 216 } 217 | Popular Tags |