1 23 24 25 package com.sun.enterprise.instance; 26 27 import java.io.File ; 29 import java.io.IOException ; 30 import com.sun.enterprise.util.StringUtils; 32 import com.sun.enterprise.util.OS; 33 import com.sun.enterprise.util.io.FileUtils; 34 import com.sun.enterprise.util.diagnostics.*; 35 import com.sun.enterprise.server.Constants; 36 import com.sun.enterprise.deployment.backend.DeployableObjectType; 37 import com.sun.enterprise.config.ConfigException; 38 import com.sun.enterprise.config.ConfigContext; 39 import com.sun.enterprise.config.ConfigFactory; 40 import com.sun.enterprise.config.serverbeans.Server; 41 import com.sun.enterprise.config.serverbeans.Domain; 42 import com.sun.enterprise.config.serverbeans.EjbContainer; 43 import com.sun.enterprise.config.serverbeans.HttpService; 44 import com.sun.enterprise.config.serverbeans.VirtualServer; 47 48 import com.sun.enterprise.admin.common.exception.AFRuntimeStoreException; 49 50 import com.sun.enterprise.admin.server.core.channel.AdminChannel; 51 import com.sun.enterprise.admin.server.core.channel.RMIClient; 52 53 import java.io.FileReader ; 54 import java.io.FileWriter ; 55 import java.util.logging.Logger ; 56 import java.util.logging.Level ; 57 import com.sun.logging.LogDomains; 58 59 import com.sun.enterprise.admin.server.core.ManualChangeManager; 60 61 63 import com.sun.enterprise.config.serverbeans.Config; 65 import com.sun.enterprise.config.serverbeans.ServerBeansFactory; 66 import com.sun.enterprise.config.serverbeans.PropertyResolver; 67 68 import com.sun.enterprise.server.ApplicationServer; 70 import com.sun.enterprise.server.pluggable.PluggableFeatureFactory; 71 import com.sun.enterprise.server.ServerContext; 72 73 91 92 public final class InstanceEnvironment { 93 94 private static Object lock = new Object (); 95 96 97 private static final boolean TIMESTAMP_MECHANISM_ENABLED = true; 98 99 102 private static final boolean MIMETYPE_TIMESTAMP_MECHANISM_ENABLED = true; 103 104 private static final boolean VIRTUAL_SERVER_TIMESTAMP_MECHANISM_ENABLED 105 = true; 106 107 private static final long INVALID_TIME_STAMP = 0; 108 109 private static final long UNINITIALIZED_TIME_STAMP = 0; 110 111 private static Logger _logger = LogDomains.getLogger(LogDomains.CORE_LOGGER); 112 113 114 115 public static final String kConfigDirName = "config"; 116 117 118 119 public static final String kBackupDirName = "."; 120 121 127 private static final String kRepositoryBackupDirName = "backup"; 128 129 130 131 public static final String kGeneratedDirName = "generated"; 132 133 134 public static final String kRepositoryDirName = "applications"; 135 136 public static final String kApplicationDirName = "j2ee-apps"; 137 138 139 140 public static final String kModuleDirName = "j2ee-modules"; 141 142 143 144 public static final String kLifecycleModuleDirName = "lifecycle-modules"; 145 146 147 148 public static final String kEJBStubDirName = "ejb"; 149 150 151 152 153 public static final String kConfigXMLFileName = "domain.xml"; 154 155 156 157 public static final String kServerXMLFileName = "server.xml"; 158 159 160 161 public static final String kLibDirName = "lib"; 162 163 164 public static final String kAutoDeployDirName = "autodeploy"; 165 166 167 168 public static final String kLibClassesDirName = "classes"; 169 170 171 172 public static final String kCompileJspDirName = "jsp"; 173 174 175 176 public static final String kGeneratedXMLDirName = "xml"; 177 178 180 181 public static final String kSessionStoreDirName = "session-store"; 182 183 184 185 public static final String kHttpSessionDirName = "http"; 186 187 188 public static final String kDocRootDirName = "docroot"; 189 190 191 public static final String kObjectFileName = "obj.conf"; 192 193 194 public static final String kInitFileName = "init.conf"; 195 196 197 198 public static final String kSecurityPasswordsFileName = "password.conf"; 199 200 201 202 public static final String kRealmsKeyFileName = "keyfile"; 203 204 205 206 public static final String kInstallDirName = "install"; 207 208 209 210 public static final String kTemplatesDirName = "templates"; 211 212 213 public static final String kAclTemplate = "template.acl"; 214 215 216 public static final int kOrbListenerPort = 3700; 217 218 219 public static final int kJmsProviderPort = 7676; 220 221 222 public static final String kJavaWebStartDirName = "java-web-start"; 223 224 225 private String instanceRoot = null; 226 227 private String mLogicalName = null; 228 private String mConfigFilePath = null; 229 private String mBackupConfigFilePath = null; 230 235 private String mApplicationRootPath = null; 236 237 244 private String mApplicationRepositoryPath = null; 245 private String mApplicationBackupRepositoryPath = null; 246 private String mModuleRepositoryPath = null; 247 private String mModuleBackupRepositoryPath = null; 248 249 private String mApplicationStubRepositoryPath = null; 250 private String mModuleStubRepositoryPath = null; 251 private String mApplicationGeneratedXMLPath = null; 252 private String mModuleGeneratedXMLPath = null; 253 private String mLibPath = null; 254 private String mAutoDeployDirPath = null; 255 private String mLibClassesPath = null; 256 private String mApplicationPassivatedEjbPath = null; 257 private String mModulePassivatedEjbPath = null; 258 private String mApplicationCompiledJspPath = null; 259 private String mWebModuleCompiledJspPath = null; 260 private String mApplicationHttpSessionStorePath = null; 261 private String mModuleHttpSessionStorePath = null; 262 private String mDocRootPath = null; 263 private String mStopCommandPath = null; 264 private String mDefaultAccessLogPath = null; 265 private String mObjectFilePath = null; 266 private String mInitFilePath = null; 267 private String mBackupObjectFilePath = null; 268 private String mBackupInitFilePath = null; 269 private String mSecurityPasswordsFilePath = null; 270 private String mRealmsKeyFilePath = null; 271 private String mBackupRealmsKeyFilePath = null; 272 273 private String mAclFilePath = null; 275 private String mBackupAclFilePath = null; 276 private String kAclFilePrefix = "generated"; 277 private String kBackupAclFilePrefix = "genwork"; 278 private String kAclFileSuffix = "acl"; 279 280 private String mJavaWebStartDirPath = null; 281 282 private boolean mInited = false; 284 285 private String mInstancesRoot = null; 286 287 302 303 public InstanceEnvironment(String instanceName) { 304 this(System.getProperty(Constants.IAS_ROOT), 305 instanceName); 306 } 307 308 public InstanceEnvironment(String instancesRoot, String instanceName) { 309 if (! StringUtils.ok(instanceName)) { 310 throw new IllegalArgumentException (Localizer.getValue(ExceptionType.NULL_ARG)); 311 } 312 mLogicalName = instanceName; 313 mInstancesRoot = instancesRoot; 314 createConfigFilePath(); 315 } 317 318 private PropertyResolver mPathResolver; 319 320 private void init() { 321 if (mInited) { 322 return; 323 } 324 createPathResolver(); 325 createApplicationRootPath(); 326 createApplicationRepositoryPath(); 327 createApplicationBackupRepositoryPath(); 328 createModuleRepositoryPath(); 329 createModuleBackupRepositoryPath(); 330 createApplicationStubPath(); 331 createModuleStubPath(); 332 createApplicationGeneratedXMLPath(); 333 createModuleGeneratedXMLPath(); 334 createLibPath(); 335 createLibClassesPath(); 336 createAutoDeployDirPath(); 337 createPassivatedEjbPaths(); 338 createApplicationCompiledJspPath(); 339 createWebModuleCompiledJspPath(); 340 createHttpSessionStorePaths(); 341 createDocRootPath(); 342 createStopCommandPath(); 343 createDefaultAccessLogPath(); 344 createObjectFilePath(); 345 createInitFilePath(); 346 createSecurityPasswordsFilePath(); 347 createRealmsKeyFilePath(); 348 createAclFilePath(); 349 createJavaWebStartPath(); 350 mInited = true; 351 } 352 364 public void applyChangesFromBackup() throws ConfigException { 365 } 366 367 public void applyChangesFromBackup(boolean overwrite) throws ConfigException { 368 } 369 370 public boolean hasHotChanged() { 371 return false; 372 } 373 374 379 public boolean hasInitOrObjConfFileChanged() { 380 return false; 381 } 382 383 388 public boolean hasRealmsKeyConfFileChanged() { 389 return false; 390 } 391 392 393 399 public boolean hasMimeConfFileChanged() { 400 return false; 401 } 402 403 public boolean hasVirtualServerConfFileChanged() { 404 return false; 405 } 406 407 411 public boolean hasCGIConfigFilesChanged() { 412 return false; 413 } 414 415 public boolean hasHotInitChanged() { 416 return false; 417 } 418 419 public boolean hasHotRealmsKeyChanged() { 420 return false; 421 } 422 423 public boolean hasHotObjectChanged() { 424 return false; 425 } 426 427 public boolean hasHotXmlChanged() { 428 return false; 429 } 430 431 439 public boolean canReloadManualXmlChanges() { 440 return false; 441 } 442 443 private boolean hasOnlyHotXmlChanged() { 444 return false; 445 } 446 447 public boolean hasHotMimeChanged() { 448 return false; 449 } 450 451 public boolean hasHotVirtualServerConfChanged() { 452 return false; 453 } 454 455 public boolean hasBakupVirtualServerConfChanged() { 456 return false; 457 } 458 459 private boolean hasVirtualServerConfChanged(ConfigContext context, 460 boolean isHot) 461 throws ConfigException { 462 return false; 463 } 464 465 private long getConfigFileTimeStamp(String configFile) { 466 long ts = UNINITIALIZED_TIME_STAMP; 468 try { 469 File f = new File (configFile); 470 ts = f.lastModified(); 471 } catch(Throwable t) { 472 } 474 return ts; 475 } 476 477 private long getLastModifiedFromTSFile(String tsFileName) { 478 long ts = INVALID_TIME_STAMP; 480 FileReader fr = null; 481 try { 482 File f = new File (tsFileName); 483 485 486 fr = new FileReader (f); 487 488 char[] cbuf = new char[13]; fr.read(cbuf); 490 String s = new String (cbuf); 491 ts = (new Long (s)).longValue(); 493 } catch(Throwable t) { 494 } finally { 497 try { 498 fr.close(); 499 fr = null; 500 } catch(Exception ex){} 501 } 502 return ts; 503 } 504 505 private String getTimeStampFileName(String fullName) { 506 return fullName + ".timestamp"; 507 } 508 509 public void useManualConfigChanges() throws ConfigException { 510 } 511 512 public void useManualServerXmlChanges() throws ConfigException { 513 } 514 515 private void useManualInitFileChanges() throws ConfigException { 516 } 517 518 private void useManualRealmsKeyFileChanges() throws ConfigException { 519 } 520 521 private void useManualObjectFileChanges() throws ConfigException { 522 } 523 524 private void useManualAllMimeFileChanges() throws ConfigException { 525 } 526 527 private void useManualVirtualServerConfFileChanges(ConfigContext bakXmlCtx) 528 throws ConfigException { 529 569 573 576 } 577 578 589 private void deleteVirtualServerConfigFiles(ConfigContext ctx, 590 ConfigContext ctx2, 591 boolean isHot) 592 throws ConfigException 593 { 594 651 652 } 653 654 657 public void createTimeStampFiles() { 658 init(); 659 if(!TIMESTAMP_MECHANISM_ENABLED) return; 660 synchronized(lock) { 661 662 createTSFile(getTimeStampFileName(mConfigFilePath), 663 mConfigFilePath, mConfigFilePath); 664 createTSFile(getTimeStampFileName(mBackupRealmsKeyFilePath), 665 mRealmsKeyFilePath, mBackupRealmsKeyFilePath); 666 667 } 668 } 669 670 private void createTSFile(String tsFileName, String actualFile, String backupFile) { 671 File f = new File (tsFileName); 674 if(!f.exists()) { 675 saveTimeStamp(tsFileName, actualFile, backupFile); 676 } 677 } 678 679 private void createMimeTSFiles() { 680 } 681 682 private void createVirtualServersConfTSFiles() { 683 726 } 727 728 731 private void saveTimeStamp(String tsFileName, String actualFile, String backupFile) { 732 if(!TIMESTAMP_MECHANISM_ENABLED) return; 733 long ts = saveTimeStamp(tsFileName, actualFile); 734 new File (backupFile).setLastModified(ts); 735 } 736 737 742 private long saveTimeStamp(String tsFileName, String actualFile) { 743 if(!TIMESTAMP_MECHANISM_ENABLED) return INVALID_TIME_STAMP; 744 745 long timestamp = getConfigFileTimeStamp(actualFile); 746 File f = null; 748 FileWriter fw = null; 749 try { 750 f = new File (tsFileName); 751 fw = new FileWriter (f); 752 fw.write("" + timestamp); 753 } catch(Throwable t) { 754 _logger.log(Level.WARNING,"core.file_io_exception",t); 755 } finally { 757 try { 758 fw.close(); 759 } catch(Throwable ex){} 760 } 761 return timestamp; 762 } 763 764 767 772 773 public void applyServerXmlChanges(boolean overwrite) throws ConfigException { 774 } 775 776 779 780 public void applyInitFileChanges() throws ConfigException { 781 } 782 783 786 787 public void applyRealmsKeyFileChanges() throws ConfigException { 788 } 789 790 793 794 public void applyObjectFileChanges() throws ConfigException { 795 } 796 797 803 public void applyAllMimeFileChanges() throws ConfigException { 804 } 805 806 810 811 public void applyAclFileChanges() throws ConfigException { 812 } 813 815 public void applyVirtualServersConfFileChanges(ConfigContext hotXmlCtx) 816 throws ConfigException { 817 864 868 872 } 873 874 880 private void copyFile(File fromFile, File toFile) throws ConfigException 881 { 882 if(!fromFile.exists()) 883 throw new ConfigException(Localizer.getValue(ExceptionType.FROM_NOT_EXIST, fromFile.getPath())); 884 885 if(fromFile.isDirectory()) 886 throw new ConfigException(Localizer.getValue(ExceptionType.FROM_IS_DIR, fromFile.getPath())); 887 888 898 899 if(toFile.isDirectory()) 900 throw new ConfigException(Localizer.getValue(ExceptionType.TO_IS_DIR, toFile.getPath())); 901 902 if(toFile.exists() && !toFile.canWrite()) 903 throw new ConfigException(Localizer.getValue(ExceptionType.TO_READ_ONLY, toFile.getPath())); 904 905 try 906 { 907 FileUtils.copy(fromFile, toFile); 908 } 909 catch(Exception e) 910 { 911 Object [] objs = new Object [] { fromFile.getPath(), toFile.getPath(), e.toString() }; 912 throw new ConfigException(Localizer.getValue(ExceptionType.FAILED_COPY, objs), e); 913 } 914 } 915 916 919 920 private void createConfigFilePath() { 921 String [] onlyFolderNames = new String [] {mInstancesRoot, 922 kConfigDirName, 923 kConfigXMLFileName}; 924 mConfigFilePath = StringUtils.makeFilePath(onlyFolderNames, false); 925 } 926 927 930 931 private void createBackupConfigFilePath() { 932 String [] onlyFolderNames = new String [] {mInstancesRoot, 933 kConfigDirName, 934 kBackupDirName, 935 kConfigXMLFileName}; 936 mBackupConfigFilePath = StringUtils.makeFilePath(onlyFolderNames, false); 937 } 938 939 945 private void createApplicationRootPath() { 946 try { 947 ConfigContext context = ConfigFactory. 948 createConfigContext(mConfigFilePath); 949 Domain domain = ServerBeansFactory.getDomainBean(context); 950 mApplicationRootPath = domain.getApplicationRoot(); 951 if (mApplicationRootPath == null || mApplicationRootPath.length() <=0){ 952 createDefaultApplicationRootPath(); 953 } 954 mApplicationRootPath = resolvePath(mApplicationRootPath); 955 } 956 catch (Exception e) { 957 _logger.log(Level.WARNING, "InstanceEnv.createApplicationRootPath()", e); 958 } 959 } 960 961 963 private void createDefaultApplicationRootPath() { 964 String [] onlyFolderNames = new String [] { 965 mInstancesRoot, 966 kRepositoryDirName}; 967 mApplicationRootPath = StringUtils.makeFilePath(onlyFolderNames, false); 968 } 969 973 974 private void createApplicationRepositoryPath() { 975 String [] onlyFolderNames = new String [] { 976 mApplicationRootPath, 977 kApplicationDirName}; 978 mApplicationRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false); 979 } 980 981 985 986 private void createModuleRepositoryPath() { 987 String [] onlyFolderNames = new String [] { 988 mApplicationRootPath, 989 kModuleDirName}; 990 mModuleRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false); 991 } 992 993 997 998 private void createApplicationBackupRepositoryPath() { 999 String [] onlyFolderNames = new String [] { 1000 mApplicationRootPath, 1001 kRepositoryBackupDirName, 1002 kApplicationDirName}; 1003 mApplicationBackupRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false); 1004 } 1005 1006 1010 1011 private void createModuleBackupRepositoryPath() { 1012 String [] onlyFolderNames = new String [] { 1013 mApplicationRootPath, 1014 kRepositoryBackupDirName, 1015 kModuleDirName}; 1016 mModuleBackupRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false); 1017 } 1018 1019 1022 private void createAutoDeployDirPath() { 1023 String [] onlyFolderNames = 1024 new String [] {mInstancesRoot, kAutoDeployDirName}; 1025 mAutoDeployDirPath = StringUtils.makeFilePath(onlyFolderNames, false); 1026 } 1027 1028 1029 1033 private void createLibPath() { 1034 String [] onlyFolderNames = new String [] {mInstancesRoot, kLibDirName}; 1035 mLibPath = StringUtils.makeFilePath(onlyFolderNames, false); 1036 1037 } 1038 1039 1043 private void createLibClassesPath() { 1044 String [] onlyFolderNames = new String [] {mInstancesRoot, kLibDirName, 1045 kLibClassesDirName}; 1046 mLibClassesPath = StringUtils.makeFilePath(onlyFolderNames, false); 1047 } 1048 1049 1053 1054 private void createApplicationStubPath() { 1055 String [] onlyFolderNames = new String [] {mInstancesRoot, kGeneratedDirName, 1056 kEJBStubDirName, kApplicationDirName}; 1057 mApplicationStubRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false); 1058 } 1059 1060 1064 1065 private void createModuleStubPath() { 1066 String [] onlyFolderNames = new String [] {mInstancesRoot, kGeneratedDirName, 1067 kEJBStubDirName, kModuleDirName}; 1068 mModuleStubRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false); 1069 } 1070 1071 1075 1076 private void createApplicationGeneratedXMLPath() { 1077 String [] onlyFolderNames = new String [] {mInstancesRoot, kGeneratedDirName, 1078 kGeneratedXMLDirName, kApplicationDirName}; 1079 mApplicationGeneratedXMLPath = StringUtils.makeFilePath(onlyFolderNames, false); 1080 } 1081 1082 1086 1087 private void createModuleGeneratedXMLPath() { 1088 String [] onlyFolderNames = new String [] {mInstancesRoot, kGeneratedDirName, 1089 kGeneratedXMLDirName, kModuleDirName}; 1090 mModuleGeneratedXMLPath = StringUtils.makeFilePath(onlyFolderNames, false); 1091 } 1092 1093 1094 1095 1096 private String getDefaultSessionStorePath() { 1097 String [] onlyFolderNames = new String [] { 1098 mInstancesRoot, 1099 kSessionStoreDirName 1100 }; 1101 return ( StringUtils.makeFilePath(onlyFolderNames, false) ); 1102 } 1103 1104 1109 private void createPassivatedEjbPaths() { 1110 try { 1111 ConfigContext context = ConfigFactory.createConfigContext( 1112 mConfigFilePath); 1113 EjbContainer ejbContainer = ServerBeansFactory.getConfigBean(context).getEjbContainer(); 1114 String sessionStore = ejbContainer.getSessionStore(); 1115 if (sessionStore == null || sessionStore.length() <= 0) { 1116 sessionStore = getDefaultSessionStorePath(); 1117 } 1118 sessionStore = resolvePath(sessionStore); 1119 String [] onlyFolderNames = new String [] { 1120 sessionStore, 1121 kEJBStubDirName, 1122 kApplicationDirName 1123 }; 1124 mApplicationPassivatedEjbPath = StringUtils.makeFilePath(onlyFolderNames, false); 1125 onlyFolderNames[2] = kModuleDirName; 1126 mModulePassivatedEjbPath = StringUtils.makeFilePath(onlyFolderNames, false); 1127 } 1128 catch (Exception e) { 1129 _logger.log(Level.WARNING, "InstanceEnv.createApplicationRootPath()", e); 1130 } 1131 } 1132 1133 1138 1139 private void createHttpSessionStorePaths() { 1140 try { 1141 ConfigContext context = ConfigFactory.createConfigContext( 1142 mConfigFilePath); 1143 EjbContainer ejbContainer = ServerBeansFactory.getConfigBean(context).getEjbContainer(); 1144 String sessionStore = ejbContainer.getSessionStore(); 1145 if (sessionStore == null || sessionStore.length() <= 0) { 1146 sessionStore = getDefaultSessionStorePath(); 1147 } 1148 sessionStore = resolvePath(sessionStore); 1149 String [] onlyFolderNames = new String [] { 1150 sessionStore, 1151 kHttpSessionDirName, 1152 kApplicationDirName 1153 }; 1154 mApplicationHttpSessionStorePath = StringUtils.makeFilePath(onlyFolderNames, false); 1155 onlyFolderNames[2] = kModuleDirName; 1156 mModuleHttpSessionStorePath = StringUtils.makeFilePath(onlyFolderNames, false); 1157 } 1158 catch (Exception e) { 1159 _logger.log(Level.WARNING, "InstanceEnv.createApplicationRootPath()", e); 1160 } 1161 } 1162 1163 1164 1165 private void createApplicationCompiledJspPath() { 1166 String [] onlyFolderNames = new String [] {mInstancesRoot, 1167 kGeneratedDirName, kCompileJspDirName, kApplicationDirName}; 1168 1169 mApplicationCompiledJspPath = StringUtils.makeFilePath(onlyFolderNames, false); 1170 } 1171 1172 1175 1176 private void createWebModuleCompiledJspPath() { 1177 String [] onlyFolderNames = new String [] {mInstancesRoot, 1178 kGeneratedDirName, kCompileJspDirName, kModuleDirName}; 1179 1180 mWebModuleCompiledJspPath = StringUtils.makeFilePath(onlyFolderNames, false); 1181 } 1182 1183 1188 private void createDocRootPath() { 1189 String [] onlyFolderNames = new String [] {mInstancesRoot, 1190 kDocRootDirName}; 1191 1192 mDocRootPath = StringUtils.makeFilePath(onlyFolderNames, false); 1193 } 1194 1197 private void createStopCommandPath() { 1198 String [] onlyFolderNames = new String [] {mInstancesRoot}; 1199 String execName = null; 1200 if(OS.isWindows()) { 1201 execName = InstanceDefinition.WIN_STOP_COMMAND_NAME; 1202 } 1203 else { 1204 execName = InstanceDefinition.UNIX_STOP_COMMAND_NAME; 1205 } 1206 mStopCommandPath = StringUtils.makeFilePath(onlyFolderNames, true) 1207 + execName; 1208 } 1209 1210 1211 private void createDefaultAccessLogPath() { 1212 final String logDirName = "logs"; 1213 final String accessLogFileName = "access"; 1214 String [] fileNames = new String [] {mInstancesRoot, 1215 logDirName, accessLogFileName}; 1216 mDefaultAccessLogPath = StringUtils.makeFilePath(fileNames, false); 1217 } 1218 1219 1220 private void createObjectFilePath() { 1221 String [] fileNames = new String [] {mInstancesRoot, 1222 kConfigDirName, kObjectFileName}; 1223 mObjectFilePath = StringUtils.makeFilePath(fileNames, false); 1224 } 1225 1226 1227 private void createInitFilePath() { 1228 String [] fileNames = new String [] {mInstancesRoot, 1229 kConfigDirName, kInitFileName}; 1230 mInitFilePath = StringUtils.makeFilePath(fileNames, false); 1231 } 1232 1233 1234 private void createSecurityPasswordsFilePath() { 1235 String [] fileNames = new String [] {mInstancesRoot, 1236 kConfigDirName, kSecurityPasswordsFileName}; 1237 mSecurityPasswordsFilePath = StringUtils.makeFilePath(fileNames, false); 1238 } 1239 1240 1241 private void createRealmsKeyFilePath() { 1242 String [] fileNames = new String [] {mInstancesRoot, 1243 kConfigDirName, kRealmsKeyFileName}; 1244 mRealmsKeyFilePath = StringUtils.makeFilePath(fileNames, false); 1245 } 1246 1247 1248 private void createBackupObjectFilePath() { 1249 String [] fileNames = new String [] {mInstancesRoot, 1250 kConfigDirName, kBackupDirName, kObjectFileName}; 1251 mBackupObjectFilePath = StringUtils.makeFilePath(fileNames, false); 1252 } 1253 1254 1255 private void createBackupInitFilePath() { 1256 String [] fileNames = new String [] {mInstancesRoot, 1257 kConfigDirName, kBackupDirName, kInitFileName}; 1258 mBackupInitFilePath = StringUtils.makeFilePath(fileNames, false); 1259 } 1260 1262 private void createAclFilePath() { 1263 String aclFileName = kAclFilePrefix + "." + getName() + "." + kAclFileSuffix; 1265 String [] fileNames = new String [] {mInstancesRoot, 1266 kConfigDirName, aclFileName}; 1267 mAclFilePath = StringUtils.makeFilePath(fileNames, false); 1268 } 1269 1270 1271 private void createBackupAclFilePath() { 1272 String backupAclFileName = kBackupAclFilePrefix + "." + getName() + "." + kAclFileSuffix; 1274 String [] fileNames = new String [] {mInstancesRoot, 1275 kConfigDirName, backupAclFileName}; 1276 mBackupAclFilePath = StringUtils.makeFilePath(fileNames, false); 1277 } 1278 1280 1281 private void createBackupRealmsKeyFilePath() { 1282 String [] fileNames = new String [] {mInstancesRoot, 1283 kConfigDirName, kBackupDirName, kRealmsKeyFileName}; 1284 mBackupRealmsKeyFilePath = StringUtils.makeFilePath(fileNames, false); 1285 } 1286 1287 1288 private void createJavaWebStartPath() { 1289 String [] fileNames = new String [] {mInstancesRoot, 1290 kJavaWebStartDirName}; 1291 mJavaWebStartDirPath = StringUtils.makeFilePath(fileNames, false); 1292 } 1293 1296 public String getName() { 1297 return ( mLogicalName ); 1298 } 1299 1300 1306 1307 public String getInstancesRoot() { 1308 return (mInstancesRoot); 1309 } 1310 1311 public String getConfigDirPath() { 1312 String [] folderNames = new String [] {mInstancesRoot, 1313 kConfigDirName}; 1314 String configDirPath = 1315 StringUtils.makeFilePath(folderNames, false); 1316 return ( configDirPath ); 1317 } 1318 1319 public String getBackupConfigDirPath() { 1320 1327 return getConfigDirPath(); 1328 } 1329 1330 1334 1335 public String getConfigFilePath() { 1336 return ( mConfigFilePath ); 1337 } 1338 1339 1343 1344 public String getBackupConfigFilePath() { 1345 return ( mConfigFilePath ); 1346 } 1347 1348 1352 1353 public String getApplicationRepositoryPath() { 1354 init(); 1355 return ( mApplicationRepositoryPath ); 1356 } 1357 1358 1362 1363 public String getApplicationBackupRepositoryPath() { 1364 init(); 1365 return ( mApplicationBackupRepositoryPath ); 1366 } 1367 1368 1372 1373 public String getModuleRepositoryPath() { 1374 init(); 1375 return ( mModuleRepositoryPath ); 1376 1377 } 1378 1382 1383 public String getModuleBackupRepositoryPath() { 1384 init(); 1385 return ( mModuleBackupRepositoryPath ); 1386 1387 } 1388 1389 1393 1394 public String getApplicationStubPath() { 1395 init(); 1396 return ( mApplicationStubRepositoryPath ); 1397 } 1398 1399 1403 1404 public String getModuleStubPath() { 1405 init(); 1406 return ( mModuleStubRepositoryPath ); 1407 } 1408 1409 1413 1414 public String getApplicationGeneratedXMLPath() { 1415 init(); 1416 return ( mApplicationGeneratedXMLPath ); 1417 } 1418 1419 1423 1424 public String getModuleGeneratedXMLPath() { 1425 init(); 1426 return ( mModuleGeneratedXMLPath ); 1427 } 1428 1429 1430 1431 1435 public String getLibPath() { 1436 init(); 1437 return ( mLibPath ); 1438 } 1439 1440 1443 public static String getTemplatesDirPath() { 1444 final String installRoot = System.getProperty(Constants.INSTALL_ROOT); 1445 String [] dirs = new String [] {installRoot, kLibDirName, 1446 kInstallDirName, kTemplatesDirName}; 1447 return StringUtils.makeFilePath(dirs, false); 1448 } 1449 1450 1455 public String getAutoDeployDirPath() { 1456 init(); 1457 return ( mAutoDeployDirPath ); 1458 } 1459 1460 1464 public String getLibClassesPath() { 1465 init(); 1466 return ( mLibClassesPath ); 1467 } 1468 1469 1474 public String getApplicationCompileJspPath() { 1475 init(); 1476 return ( mApplicationCompiledJspPath ); 1477 } 1478 1479 1484 public String getWebModuleCompileJspPath() { 1485 init(); 1486 return ( mWebModuleCompiledJspPath ); 1487 } 1488 1489 1493 public String getApplicationPassivatedEjbPath() { 1494 init(); 1495 return ( mApplicationPassivatedEjbPath ); 1496 } 1497 public String getModulePassivatedEjbPath() { 1498 init(); 1499 return ( mModulePassivatedEjbPath ); 1500 } 1501 public String getApplicationHttpSessionStorePath() { 1502 init(); 1503 return ( mApplicationHttpSessionStorePath ); 1504 } 1505 public String getModuleHttpSessionStorePath() { 1506 init(); 1507 return ( mModuleHttpSessionStorePath ); 1508 } 1509 1510 1513 public String getDocRootPath() { 1514 init(); 1515 return ( mDocRootPath ); 1516 } 1517 1518 public String getStopCommandPath() { 1519 init(); 1520 return ( mStopCommandPath ); 1521 } 1522 1523 1532 public String getDefaultAccessLogPath() { 1533 init(); 1534 return ( mDefaultAccessLogPath ); 1535 } 1536 1537 1539 public String getInitFilePath() { 1540 init(); 1541 return ( mInitFilePath ); 1542 } 1543 1545 public String getBackupInitFilePath() { 1546 init(); 1547 return ( mBackupInitFilePath ); 1548 } 1549 1550 1552 public String getSecurityPasswordsFilePath() { 1553 init(); 1554 return ( mSecurityPasswordsFilePath ); 1555 } 1556 1558 public String getRealmsKeyFilePath() { 1559 init(); 1560 return ( mRealmsKeyFilePath ); 1561 } 1562 1563 1565 public String getBackupRealmsKeyFilePath() { 1566 init(); 1567 return ( mRealmsKeyFilePath ); 1568 } 1569 1570 1572 public String getObjectFilePath() { 1573 init(); 1574 return ( mObjectFilePath ); 1575 } 1576 1578 public String getBackupObjectFilePath() { 1579 init(); 1580 return ( mBackupObjectFilePath ); 1581 } 1582 1583 public ApplicationEnvironment getApplicationEnvironment(String appName) { 1584 1585 init(); 1586 if (appName == null) { 1587 throw new IllegalArgumentException (); 1588 } 1589 return ( new ApplicationEnvironment(this, appName) ); 1590 } 1591 1592 public ModuleEnvironment getModuleEnvironment(String moduleName, DeployableObjectType type) { 1593 init(); 1594 if (moduleName == null) { 1595 throw new IllegalArgumentException (); 1596 } 1597 1598 return ( new ModuleEnvironment(this, moduleName, type) ); 1599 } 1600 1601 public String getJavaWebStartPath() { 1602 init(); 1603 return mJavaWebStartDirPath; 1604 } 1605 1606 public String verify() 1607 { 1608 return null; 1612 } 1613 1614 public String toString() 1615 { 1616 init(); 1617 return ObjectAnalyzer.toString(this); 1618 } 1619 1620 1621 1623 1624 public final boolean isIASOwned(String filename) 1625 { 1626 return isIASOwned(new File (filename)); 1627 } 1628 1629 1631 1632 public final boolean isIASOwned(File file) 1633 { 1634 init(); 1635 try 1636 { 1637 String iasPath = getInstancesRoot(); 1639 assert StringUtils.ok(iasPath); 1640 1641 iasPath = FileUtils.safeGetCanonicalPath(new File (iasPath)); 1642 String filename = FileUtils.safeGetCanonicalPath(file); 1643 1644 if(!StringUtils.ok(iasPath)) 1645 return false; 1646 1647 if(!StringUtils.ok(filename)) 1648 return false; 1649 1650 if(filename.startsWith(iasPath)) 1651 return true; 1652 1653 return false; 1654 } 1655 catch(Exception e) 1656 { 1657 return false; 1658 } 1659 } 1660 1661 public boolean restartRequired() { 1662 init(); 1663 synchronized(lock) { 1667 try { 1668 RMIClient rc = AdminChannel.getRMIClient(this.mLogicalName); 1669 if(!rc.isAlive()) return false; 1670 if(rc.hasRestartedSince(getManualChangeTime())) return false; 1671 1672 return true; 1673 } catch (Exception e) { 1674 } 1676 } 1677 return false; 1678 } 1679 1680 1681 private long getManualChangeTime() { 1682 long ts = UNINITIALIZED_TIME_STAMP; 1683 long tsTmp = UNINITIALIZED_TIME_STAMP; 1684 1685 try { 1686 ts = getConfigFileTimeStamp(mInitFilePath); 1687 tsTmp = getConfigFileTimeStamp(mObjectFilePath); 1688 1689 if(ts < tsTmp) ts = tsTmp; 1690 1691 tsTmp = getConfigFileTimeStamp(mConfigFilePath); 1692 1693 if(ts < tsTmp) ts = tsTmp; 1694 1695 1722 } catch (Throwable t) { 1723 } 1725 return ts; 1726 } 1727 1728 1729 private boolean hasBakMimeChanged() { 1730 return false; 1731 } 1732 1733 1744 1745 public String getInstanceUser() throws IOException { 1746 init(); 1747 return ServerManager.instance().getInstanceUser(this); 1748 } 1749 1750 1752 public boolean isChownNeeded(File f) { 1753 init(); 1754 1771 return false; 1772 } 1773 1774 private void chownFile(String filePath) throws ConfigException { 1775 1776 1787 } 1788 1789 private void createPathResolver() { 1790 try { 1791 mPathResolver = new PropertyResolver( 1792 ConfigFactory.createConfigContext(mConfigFilePath), 1793 mLogicalName); 1794 } catch (Exception e) { 1795 } 1797 } 1798 1799 private String resolvePath(String unresolved) { 1800 if (mPathResolver != null) { 1801 return mPathResolver.resolve(unresolved); 1802 } 1803 return unresolved; 1804 } 1805} 1806 | Popular Tags |