jvanzyl 01/08/05 22:11:00 Modified: src/java/org/apache/turbine/util DynamicURI.java RelativeDynamicURI.java RunDataFactory.java Removed: src/java/org/apache/turbine/util ServerData.java Log: - getting rid of more object creation on each request by getting rid of ServerData. Revision Changes Path 1.20 +10 -206 jakarta-turbine/src/java/org/apache/turbine/util/DynamicURI.java Index: DynamicURI.java =================================================================== RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/DynamicURI.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- DynamicURI.java 2001/07/17 11:37:36 1.19 +++ DynamicURI.java 2001/08/06 05:11:00 1.20 @@ -83,7 +83,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a> * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> - * @version $Id: DynamicURI.java,v 1.19 2001/07/17 11:37:36 jvanzyl Exp $ + * @version $Id: DynamicURI.java,v 1.20 2001/08/06 05:11:00 jvanzyl Exp $ */ public class DynamicURI { @@ -93,24 +93,9 @@ /** HTTPS protocol. */ public static final String HTTPS = "https"; - /** The ServerData object. */ - protected ServerData sd = null; - /** The RunData object. */ protected RunData data = null; - /** ie: http or https. */ - protected String serverScheme = null; - - /** ie: www.foo.com. */ - protected String serverName = null; - - /** ie: 80 or 443. */ - protected int serverPort = 80; - - /** /foo/Turbine. */ - protected String scriptName = null; - // Used with RunData constructors to provide a way around a JServ // 1.0 bug. @@ -236,110 +221,17 @@ } /** - * Main constructor for DynamicURI. Uses ServerData. - * - * @param sd A ServerData. - */ - public DynamicURI( ServerData sd ) - { - init(sd); - } - - /** - * Main constructor for DynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param screen A String with the name of a screen. - */ - public DynamicURI( ServerData sd, String screen ) - { - this(sd); - setScreen(screen); - } - - /** - * Main constructor for DynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param screen A String with the name of a screen. - * @param action A String with the name of an action. - */ - public DynamicURI( ServerData sd, - String screen, - String action ) - { - this( sd, screen ); - setAction(action); - } - - /** - * Main constructor for DynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param screen A String with the name of a screen. - * @param action A String with the name of an action. - * @param redirect True if it should redirect. - */ - public DynamicURI( ServerData sd, - String screen, - String action, - boolean redirect ) - { - this( sd, screen, action ); - this.redirect = redirect; - } - - /** - * Main constructor for DynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param screen A String with the name of a screen. - * @param redirect True if it should redirect. - */ - public DynamicURI( ServerData sd, - String screen, - boolean redirect ) - { - this( sd, screen ); - this.redirect = redirect; - } - - /** - * Main constructor for DynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param redirect True if it should redirect. - */ - public DynamicURI( ServerData sd, - boolean redirect ) - { - this( sd ); - this.redirect = redirect; - } - - /** * Initialize with a RunData object * * @param RunData */ public void init( RunData data ) { - init(data.getServerData()); this.data = data; this.res = data.getResponse(); - } - - /** - * Initialize with a ServerData object. - * - * @param ServerData - */ - public void init ( ServerData sd ) - { - this.setServerData( sd ); init(); } - + /** * <p>If the type is P (0), then add name/value to the pathInfo * hashtable. @@ -582,11 +474,7 @@ */ public String getScriptName () { - if ( this.scriptName == null ) - { - return ""; - } - return this.scriptName; + return data.getScriptName(); } /** @@ -596,11 +484,7 @@ */ public String getServerName () { - if ( this.serverName == null ) - { - return ""; - } - return(this.serverName); + return data.getServerName(); } /** @@ -610,11 +494,7 @@ */ public int getServerPort () { - if ( this.serverPort == 0 ) - { - return 80; - } - return this.serverPort; + return data.getServerPort(); } /** @@ -622,13 +502,9 @@ * * @return A String with the server scheme. */ - public String getServerScheme () + public String getServerScheme() { - if ( this.serverScheme == null ) - { - return ""; - } - return (this.serverScheme); + return data.getServerScheme(); } /** @@ -636,10 +512,6 @@ */ protected void init() { - this.serverScheme = this.getServerData().getServerScheme(); - this.serverName = this.getServerData().getServerName(); - this.serverPort = this.getServerData().getServerPort(); - this.scriptName = this.getServerData().getScriptName(); this.pathInfo = new Vector(); this.queryData = new Vector(); } @@ -847,42 +719,6 @@ } /** - * Sets the script name (/servlets/Turbine). - * - * @param name A String with the script name. - * @return A DynamicURI (self). - */ - public DynamicURI setScriptName ( String name ) - { - this.scriptName = name; - return this; - } - - /** - * Sets the server name. - * - * @param name A String with the server name. - * @return A DynamicURI (self). - */ - public DynamicURI setServerName ( String name ) - { - this.serverName = name; - return this; - } - - /** - * Sets the server port. - * - * @param port An int with the port. - * @return A DynamicURI (self). - */ - public DynamicURI setServerPort ( int port ) - { - this.serverPort = port; - return this; - } - - /** * Method to specify that a URI should use SSL. Whether or not it * does is determined from TurbineResources.properties. Port * number is 443. @@ -906,25 +742,13 @@ boolean isSSL = Turbine.getConfiguration().getBoolean("use.ssl", true); if (isSSL) { - setServerScheme(DynamicURI.HTTPS); - setServerPort(port); + data.setServerScheme(DynamicURI.HTTPS); + data.setServerPort(port); } return this; } /** - * Sets the scheme (HTTP or HTTPS). - * - * @param scheme A String with the scheme. - * @return A DynamicURI (self). - */ - public DynamicURI setServerScheme ( String scheme ) - { - this.serverScheme = scheme; - return this; - } - - /** * Builds the URL with all of the data URL-encoded as well as * encoded using HttpServletResponse.encodeUrl(). * @@ -1011,7 +835,7 @@ output.append ( data.getServerPort() ); } - output.append ( data.getServerData().getScriptName() ); + output.append ( data.getScriptName() ); if ( request.getPathInfo() != null ) { @@ -1024,25 +848,5 @@ output.append ( request.getQueryString() ); } return output.toString(); - } - - /** - * Returns the ServerData used to initialize this DynamicURI. - * - * @return A ServerData used to initialize this DynamicURI. - */ - public ServerData getServerData() - { - return this.sd; - } - - /** - * Sets the ServerData used to initialize this DynamicURI. - * - * @param sd A ServerData used to initialize this DynamicURI. - */ - public void setServerData( ServerData sd ) - { - this.sd = sd; } } 1.6 +1 -79 jakarta-turbine/src/java/org/apache/turbine/util/RelativeDynamicURI.java Index: RelativeDynamicURI.java =================================================================== RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/RelativeDynamicURI.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RelativeDynamicURI.java 2001/07/10 01:04:49 1.5 +++ RelativeDynamicURI.java 2001/08/06 05:11:00 1.6 @@ -170,84 +170,6 @@ } /** - * Main constructor for RelativeDynamicURI. Uses ServerData. - * - * @param sd A ServerData. - */ - public RelativeDynamicURI( ServerData sd ) - { - super(sd); - } - - /** - * Main constructor for RelativeDynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param screen A String with the name of a screen. - */ - public RelativeDynamicURI( ServerData sd, - String screen ) - { - super(sd, screen); - } - - /** - * Main constructor for RelativeDynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param screen A String with the name of a screen. - * @param action A String with the name of an action. - */ - public RelativeDynamicURI( ServerData sd, - String screen, - String action ) - { - super(sd, screen, action); - } - - /** - * Main constructor for RelativeDynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param screen A String with the name of a screen. - * @param action A String with the name of an action. - * @param redirect True if it should redirect. - */ - public RelativeDynamicURI( ServerData sd, - String screen, - String action, - boolean redirect ) - { - super(sd, screen, action, redirect); - } - - /** - * Main constructor for RelativeDynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param screen A String with the name of a screen. - * @param redirect True if it should redirect. - */ - public RelativeDynamicURI( ServerData sd, - String screen, - boolean redirect ) - { - super(sd, screen, redirect); - } - - /** - * Main constructor for RelativeDynamicURI. Uses ServerData. - * - * @param sd A ServerData. - * @param redirect True if it should redirect. - */ - public RelativeDynamicURI( ServerData sd, - boolean redirect ) - { - super(sd, redirect); - } - - /** * Builds the relative URL with all of the data URL-encoded as well as * encoded using HttpServletResponse.encodeUrl(). * @@ -311,7 +233,7 @@ StringBuffer output = new StringBuffer(); HttpServletRequest request = data.getRequest(); - output.append ( data.getServerData().getScriptName() ); + output.append ( data.getScriptName() ); if ( request.getPathInfo() != null ) { 1.19 +7 -7 jakarta-turbine/src/java/org/apache/turbine/util/RunDataFactory.java Index: RunDataFactory.java =================================================================== RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/RunDataFactory.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- RunDataFactory.java 2001/08/01 15:44:24 1.18 +++ RunDataFactory.java 2001/08/06 05:11:00 1.19 @@ -76,7 +76,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Ilkka Priha</a> * @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a> * @author <a href="mailto:[EMAIL PROTECTED]">John D. McNally</a> - * @version $Id: RunDataFactory.java,v 1.18 2001/08/01 15:44:24 jvanzyl Exp $ + * @version $Id: RunDataFactory.java,v 1.19 2001/08/06 05:11:00 jvanzyl Exp $ */ public class RunDataFactory { @@ -198,12 +198,12 @@ // other servlets. data.setServletConfig(config); - // Now set the ServerData. - data.setServerData( new ServerData( data.getRequest().getServerName(), - data.getRequest().getServerPort(), - data.getRequest().getScheme(), - scriptName, - contextPath ) ); + data.setServerName(data.getRequest().getServerName()); + data.setServerPort(data.getRequest().getServerPort()); + data.setServerScheme(data.getRequest().getScheme()); + data.setScriptName(scriptName); + data.setContextPath(contextPath); + return data; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]