1 23 24 package com.sun.enterprise.instance; 25 26 import com.sun.enterprise.util.StringUtils; 28 import com.sun.enterprise.util.diagnostics.*; 29 30 import java.util.logging.Logger ; 31 import java.util.logging.Level ; 32 import com.sun.logging.LogDomains; 33 41 42 public class ApplicationEnvironment { 43 44 private String mAppName = null; 45 private String mAppPath = null; 46 private String mAppGeneratedXMLPath = null; 47 private String mAppStubPath = null; 48 private String mAppBackupPath = null; 49 private String mAppJSPPath = null; 50 private String mJavaWebStartPath = null; 51 private InstanceEnvironment mInstance = null; 52 private static Logger _logger = LogDomains.getLogger(LogDomains.CORE_LOGGER); 53 54 55 61 62 public ApplicationEnvironment (InstanceEnvironment instance, String appName) { 63 if (instance == null || appName == null) { 64 throw new IllegalArgumentException (); 65 } 66 mInstance = instance; 67 mAppName = appName; 68 createAppPath(); 69 createAppStubPath(); 70 createAppBackupPath(); 71 createAppJSPPath(); 72 createAppGeneratedXMLPath(); 73 createJavaWebStartPath(); 74 } 75 76 private void createAppPath() { 77 String applicationRepositoryDirPath = mInstance.getApplicationRepositoryPath(); 78 String [] onlyFolderNames = new String [] { 79 applicationRepositoryDirPath, 80 mAppName 81 }; 82 mAppPath = StringUtils.makeFilePath (onlyFolderNames, false); 83 } 84 85 private void createAppBackupPath() { 86 String applicationBackupRepositoryDirPath = mInstance.getApplicationBackupRepositoryPath(); 88 String [] onlyFolderNames = new String [] { 89 applicationBackupRepositoryDirPath, 90 mAppName 91 }; 92 mAppBackupPath = StringUtils.makeFilePath (onlyFolderNames, false); 93 } 94 95 99 100 public String getAppPath() { 101 return mAppPath; 102 } 103 104 108 109 public void createAppStubPath() { 110 String [] onlyFolderNames = new String [] { 111 mInstance.getApplicationStubPath(), 112 mAppName 113 }; 114 115 mAppStubPath = StringUtils.makeFilePath (onlyFolderNames, false); 116 } 117 118 122 123 public void createAppGeneratedXMLPath() { 124 String [] onlyFolderNames = new String [] { 125 mInstance.getApplicationGeneratedXMLPath(), 126 mAppName 127 }; 128 129 mAppGeneratedXMLPath = StringUtils.makeFilePath (onlyFolderNames, false); 130 } 131 132 133 138 139 public void createAppJSPPath() { 140 String [] onlyFolderNames = new String [] { 141 mInstance.getApplicationCompileJspPath(), 142 mAppName 143 }; 144 145 mAppJSPPath = StringUtils.makeFilePath (onlyFolderNames, false); 146 } 147 148 152 153 public String getAppJSPPath() { 154 assert StringUtils.ok(mAppJSPPath); 155 return mAppJSPPath; 156 } 157 158 162 163 public String getAppStubPath() { 164 return mAppStubPath; 165 } 166 167 171 172 public String getAppGeneratedXMLPath() { 173 return mAppGeneratedXMLPath; 174 } 175 176 179 180 private void createJavaWebStartPath() { 181 String [] onlyFolderNames = new String [] { 182 mInstance.getJavaWebStartPath(), 183 mAppName 184 }; 185 186 mJavaWebStartPath = StringUtils.makeFilePath (onlyFolderNames, false); 187 } 188 189 193 194 public String getJavaWebStartPath() { 195 return mJavaWebStartPath; 196 } 197 198 public String toString() 199 { 200 return ObjectAnalyzer.toString(this); 201 } 202 203 public static void main(String [] args) 204 { 205 InstanceEnvironment env = new InstanceEnvironment("foo"); 207 ApplicationEnvironment ae = new ApplicationEnvironment(env, "myapp"); 208 209 _logger.log(Level.INFO,"core.appenv_dump"); 210 _logger.log(Level.INFO,ae.toString()); 211 } 212 } 213 | Popular Tags |