From: Max M. <max...@us...> - 2002-04-30 21:53:59
|
Update of /cvsroot/wonder/ProjectWonder/Frameworks/ERExtensionsJava In directory usw-pr-cvs1:/tmp/cvs-serv23564 Modified Files: ERXApplication.java Log Message: JavaDoc Index: ERXApplication.java =================================================================== RCS file: /cvsroot/wonder/ProjectWonder/Frameworks/ERExtensionsJava/ERXApplication.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ERXApplication.java 27 Apr 2002 21:45:42 -0000 1.8 --- ERXApplication.java 30 Apr 2002 21:53:56 -0000 1.9 *************** *** 15,35 **** import org.apache.log4j.Category; public abstract class ERXApplication extends WOApplication { ! ! ////////////////////////////////////////////// log4j category //////////////////////////////////////////// public static final ERXLogger cat = ERXLogger.getLogger(ERXApplication.class); ! ////////////////////////////////////////////// Notification Hooks ////////////////////////////////////////// ! // A few undocumented notifications that are nice ;) public static final String WORequestHandlerDidHandleRequestNotification = "WORequestHandlerDidHandleRequestNotification"; - public static final String ApplicationWillDispatchRequestNotification = "WOApplicationWillDispatchRequestNotification"; - public static final String ApplicationDidDispatchRequestNotification = "WOApplicationDidDispatchRequestNotification"; - ! //------------------------------------------------------ ! // Application Cycling public void run() { int timeToLive=ERXProperties.intForKey("ERTimeToLive"); ! if (timeToLive!=0) { cat.info("Instance will live "+timeToLive+" seconds."); NSLog.out.appendln("Instance will live "+timeToLive+" seconds."); --- 15,57 ---- import org.apache.log4j.Category; + /** + * ERXApplication is the abstract superclass of WebObjects applications + * built with the ER frameworks.<br/> + * <br/> + * Useful enhancements include the ability to change the deployed name of + * the application, support for automatic application restarting at given intervals + * and more context information when handling exceptions. + */ + public abstract class ERXApplication extends WOApplication { ! ! /** logging support */ public static final ERXLogger cat = ERXLogger.getLogger(ERXApplication.class); ! // FIXME: Should correct all references to WORequestHandler.DidHandleRequestNotification and then delete this ivar. public static final String WORequestHandlerDidHandleRequestNotification = "WORequestHandlerDidHandleRequestNotification"; ! /** ! * The ERXApplication singleton. ! * @return returns the <code>WOApplication.application()</code> cast as an ERXApplication ! */ ! public static ERXApplication erxApplication() { return (ERXApplication)WOApplication.application(); } ! ! /** ! * Adds support for automatic application cycling. Applications can be configured ! * to cycle in two ways:<br/> ! * <br/> ! * The first way is by setting the System property <b>ERTimeToLive</b> to the number ! * of seconds that the application should be up before terminating. Note that when ! * the application's time to live is up it will quit calling the method <code>killInstance</code>.<br/> ! * <br/> ! * The second way is by setting the System property <b>ERTimeToDie</b> to the number ! * of seconds that the application should be up before starting to refuse new sessions. ! * In this case when the application starts to refuse new sessions it will also register ! * a kill timer that will terminate the application between 30 minutes and 1:30 minutes.<br/> ! */ public void run() { int timeToLive=ERXProperties.intForKey("ERTimeToLive"); ! if (timeToLive > 0) { cat.info("Instance will live "+timeToLive+" seconds."); NSLog.out.appendln("Instance will live "+timeToLive+" seconds."); *************** *** 40,45 **** } int timeToDie=ERXProperties.intForKey("ERTimeToDie"); ! if (timeToDie!=0) { ! // FIXME we could randomize this (30mn?) to help with restart related downtime problems? cat.info("Instance will not live past "+timeToDie+":00."); NSLog.out.appendln("Instance will not live past "+timeToDie+":00."); --- 62,66 ---- } int timeToDie=ERXProperties.intForKey("ERTimeToDie"); ! if (timeToDie > 0) { cat.info("Instance will not live past "+timeToDie+":00."); NSLog.out.appendln("Instance will not live past "+timeToDie+":00."); *************** *** 58,61 **** --- 79,88 ---- } + /** + * Stops the application from handling any new requests. Will still handle + * requests from existing sessions. Also registers a kill timer that will + * terminate the application thirty minutes from the time this method is + * called + */ public void startRefusingSessions() { cat.info("Refusing new sessions"); *************** *** 69,72 **** --- 96,102 ---- } + /** + * Killing the instance will log a 'Forcing exit' message and then call <code>System.exit(1)</code> + */ public void killInstance() { cat.info("Forcing exit"); *************** *** 74,83 **** System.exit(1); } ! ! //------------------------------------------------------------------------------------------------- ! // ability to change your name -- useful for training instances ! // this may not even be needed if you don't use Monitor private String _nameSuffix; private boolean _nameSuffixLookedUp=false; public String nameSuffix() { if (!_nameSuffixLookedUp) { --- 104,122 ---- System.exit(1); } ! /** cached name suffix */ private String _nameSuffix; + /** has the name suffix been cached? */ private boolean _nameSuffixLookedUp=false; + /** + * The name suffix is appended to the current name of the application. This adds the ability to + * add a useful suffix to differentuate between different sets of applications on the same machine.<br/> + * <br/> + * The name suffix is set via the System property <b>ERApplicationNameSuffix</b>.<br/> + * <br/> + * For example if the name of an application is Buyer and you want to have a training instance + * appear with the name BuyerTraining then you would set the ERApplicationNameSuffix to Training.<br/> + * <br/> + * @return the System property <b>ERApplicationNameSuffix</b> or <code>null</code> + */ public String nameSuffix() { if (!_nameSuffixLookedUp) { *************** *** 88,93 **** return _nameSuffix; } ! private String _userDefaultName; public String name() { if (_userDefaultName==null) { --- 127,138 ---- return _nameSuffix; } ! /** cached computed name */ private String _userDefaultName; + /** + * Adds the ability to completely change the applications name by setting the System property + * <b>ERApplicationName</b>. Will also append the <code>nameSuffix</code> if one is set.<br/> + * <br/> + * @return the computed name of the application. + */ public String name() { if (_userDefaultName==null) { *************** *** 103,110 **** } public String rawName() { return super.name(); } ! public static ERXApplication erxApplication() { return (ERXApplication)WOApplication.application(); } ! public WOResponse handleException(Exception exception, WOContext context) { NSMutableDictionary extraInfo=new NSMutableDictionary(); --- 148,171 ---- } + /** + * This method returns {@link WOApplication}'s <code>name</code> method.<br/> + * @return the name of the application executable. + */ public String rawName() { return super.name(); } ! /** ! * Adds a bunch of useful information relative to the current state when the exception ! * occurried. Potentially added information:<br/> ! * <ol> ! * <li>the current page name</li> ! * <li>the current component</li> ! * <li>the complete hierarchy of nested components</li> ! * <li>the requested uri</li> ! * <li>the D2W page configuration</li> ! * <li>the previous page list (from the WOStatisticsStore)</li> ! * </ol> ! * <br/> ! * @return the WOResponse of the generated exception page. ! */ public WOResponse handleException(Exception exception, WOContext context) { NSMutableDictionary extraInfo=new NSMutableDictionary(); *************** *** 137,146 **** return super.handleException(exception, context); } - - // backstop wrapper for notifications - public String mailWrapperName() { return "PageWrapper"; } ! // FIXME: Need to get rid of these now. protected D2WContext _d2wContext; public D2WContext d2wContext() { if (_d2wContext == null) --- 198,208 ---- return super.handleException(exception, context); } ! // DELETE ME ! public String mailWrapperName() { return "PageWrapper"; } ! ! // DELETE ME protected D2WContext _d2wContext; + // DELETE ME public D2WContext d2wContext() { if (_d2wContext == null) *************** *** 149,154 **** } ! // for subclasses to override public void resetSignificantKeys() {} public void warmUpRuleCache() { // Moved to ERDirectToWeb --- 211,217 ---- } ! // DELETE ME public void resetSignificantKeys() {} + // DELETE ME public void warmUpRuleCache() { // Moved to ERDirectToWeb *************** *** 156,165 **** } public ERXSimpleHTMLFormatter formatter() { return ERXSimpleHTMLFormatter.formatter(); } public WOComponent pageWithName(String name) { // Was: pageWithName(name, new WOContext()); return pageWithName(name, null); } - } --- 219,229 ---- } + // DELETE ME public ERXSimpleHTMLFormatter formatter() { return ERXSimpleHTMLFormatter.formatter(); } + // DELETE ME public WOComponent pageWithName(String name) { // Was: pageWithName(name, new WOContext()); return pageWithName(name, null); } } |