You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2006/11/10 23:35:27 UTC
svn commit: r473543 - in
/incubator/wicket/trunk/wicket/src/main/java/wicket: Application.java
Session.java jmx/RequestLogger.java settings/IRequestLoggerSettings.java
Author: jcompagner
Date: Fri Nov 10 14:35:26 2006
New Revision: 473543
URL: http://svn.apache.org/viewvc?view=rev&rev=473543
Log:
request logger and improved doc
Added:
incubator/wicket/trunk/wicket/src/main/java/wicket/settings/IRequestLoggerSettings.java
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/Application.java
incubator/wicket/trunk/wicket/src/main/java/wicket/Session.java
incubator/wicket/trunk/wicket/src/main/java/wicket/jmx/RequestLogger.java
Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/Application.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/Application.java?view=diff&rev=473543&r1=473542&r2=473543
==============================================================================
--- incubator/wicket/trunk/wicket/src/main/java/wicket/Application.java (original)
+++ incubator/wicket/trunk/wicket/src/main/java/wicket/Application.java Fri Nov 10 14:35:26 2006
@@ -51,6 +51,7 @@
import wicket.settings.IMarkupSettings;
import wicket.settings.IPageSettings;
import wicket.settings.IRequestCycleSettings;
+import wicket.settings.IRequestLoggerSettings;
import wicket.settings.IResourceSettings;
import wicket.settings.ISecuritySettings;
import wicket.settings.ISessionSettings;
@@ -503,8 +504,27 @@
*/
public final IRequestLogger getRequestLogger()
{
+ if(getRequestLoggerSettings().isRequestLoggerEnabled())
+ {
+ if(requestLogger == null) requestLogger = newRequestLogger();
+ }
+ else
+ {
+ requestLogger = null;
+ }
return requestLogger;
}
+
+ /**
+ * creates a new request logger when requests logging is enabled.
+ *
+ * @return The new request logger
+ *
+ */
+ protected IRequestLogger newRequestLogger()
+ {
+ return new RequestLogger();
+ }
/**
* @return Application's resources related settings
@@ -517,6 +537,16 @@
}
/**
+ * @return Application's resources related settings
+ * @see IResourceSettings
+ * @since 1.3
+ */
+ public final IRequestLoggerSettings getRequestLoggerSettings()
+ {
+ return getSettings();
+ }
+
+ /**
* @return Application's security related settings
* @see ISecuritySettings
* @since 1.2
@@ -665,16 +695,6 @@
metaData = key.set(metaData, object);
}
- /**
- * Sets the {@link RequestLogger}.
- *
- * @param logger
- * The request logger
- */
- public final void setRequestLogger(IRequestLogger logger)
- {
- requestLogger = logger;
- }
/**
* Called when wicket servlet is destroyed. Overrides do not have to call
Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/Session.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/Session.java?view=diff&rev=473543&r1=473542&r2=473543
==============================================================================
--- incubator/wicket/trunk/wicket/src/main/java/wicket/Session.java (original)
+++ incubator/wicket/trunk/wicket/src/main/java/wicket/Session.java Fri Nov 10 14:35:26 2006
@@ -238,46 +238,6 @@
}
/**
- * Force binding this session to the application's
- * {@link ISessionStore session store}. A Wicket application can operate in
- * a session-less mode as long as stateless pages are used. Session objects
- * will be then created for each request, but they will only live for that
- * request. You can recognize temporary sessions by calling
- * {@link #isTemporary()} which basically checks whether the session's id is
- * null. Hence, temporary sessions have no session id.
- * <p>
- * By calling this method, the session will be bound (made not-temporary) if
- * it was not bound yet. It is useful for cases where you want to be
- * absolutely sure this session object will be available in next requests.
- * </p>
- */
- public final void bind()
- {
- ISessionStore store = getSessionStore();
- Request request = RequestCycle.get().getRequest();
- if (store.getSessionId(request, false) == null)
- {
- // explicitly create a session
- this.id = store.getSessionId(request, true);
- // bind it
- store.bind(request, this);
- }
- }
-
- /**
- * Whether this session is temporary. A Wicket application can operate in a
- * session-less mode as long as stateless pages are used. If this session
- * object is temporary, it will not be available on a next request.
- *
- * @return Whether this session is temporary (which is the same as it's id
- * being null)
- */
- public final boolean isTemporary()
- {
- return getId() == null;
- }
-
- /**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
* <p>
* Sets session for calling thread.
@@ -317,6 +277,45 @@
setLocale(application.getApplicationSettings().getDefaultLocale());
}
+ /**
+ * Force binding this session to the application's
+ * {@link ISessionStore session store}. A Wicket application can operate in
+ * a session-less mode as long as stateless pages are used. Session objects
+ * will be then created for each request, but they will only live for that
+ * request. You can recognize temporary sessions by calling
+ * {@link #isTemporary()} which basically checks whether the session's id is
+ * null. Hence, temporary sessions have no session id.
+ * <p>
+ * By calling this method, the session will be bound (made not-temporary) if
+ * it was not bound yet. It is useful for cases where you want to be
+ * absolutely sure this session object will be available in next requests.
+ * </p>
+ */
+ public final void bind()
+ {
+ ISessionStore store = getSessionStore();
+ Request request = RequestCycle.get().getRequest();
+ if (store.getSessionId(request, false) == null)
+ {
+ // explicitly create a session
+ this.id = store.getSessionId(request, true);
+ // bind it
+ store.bind(request, this);
+ }
+ }
+
+ /**
+ * Whether this session is temporary. A Wicket application can operate in a
+ * session-less mode as long as stateless pages are used. If this session
+ * object is temporary, it will not be available on a next request.
+ *
+ * @return Whether this session is temporary (which is the same as it's id
+ * being null)
+ */
+ public final boolean isTemporary()
+ {
+ return getId() == null;
+ }
/**
* Removes all pages from the session. Although this method should rarely be
* needed, it is available (possibly for security reasons).
Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/jmx/RequestLogger.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/jmx/RequestLogger.java?view=diff&rev=473543&r1=473542&r2=473543
==============================================================================
--- incubator/wicket/trunk/wicket/src/main/java/wicket/jmx/RequestLogger.java (original)
+++ incubator/wicket/trunk/wicket/src/main/java/wicket/jmx/RequestLogger.java Fri Nov 10 14:35:26 2006
@@ -85,7 +85,9 @@
*/
public void restart() throws IOException
{
- application.setRequestLogger(new wicket.protocol.http.RequestLogger());
+ application.getRequestLoggerSettings().setRequestLoggerEnabled(false);
+ application.getRequestLogger();
+ application.getRequestLoggerSettings().setRequestLoggerEnabled(true);
}
/**
@@ -93,7 +95,7 @@
*/
public void stop() throws IOException
{
- application.setRequestLogger(null);
+ application.getRequestLoggerSettings().setRequestLoggerEnabled(false);
}
/**
Added: incubator/wicket/trunk/wicket/src/main/java/wicket/settings/IRequestLoggerSettings.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/settings/IRequestLoggerSettings.java?view=auto&rev=473543
==============================================================================
--- incubator/wicket/trunk/wicket/src/main/java/wicket/settings/IRequestLoggerSettings.java (added)
+++ incubator/wicket/trunk/wicket/src/main/java/wicket/settings/IRequestLoggerSettings.java Fri Nov 10 14:35:26 2006
@@ -0,0 +1,65 @@
+/*
+ * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) eelco12 $
+ * $Revision: 5004 $
+ * $Date: 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) $
+ *
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package wicket.settings;
+
+/**
+ * @author jcompagner
+ */
+public interface IRequestLoggerSettings
+{
+ /**
+ * Enable/Disable the request logger.
+ *
+ * @param enable boolean.
+ */
+ void setRequestLoggerEnabled(boolean enable);
+
+
+ /**
+ * @return true if the request Logger is enabled. (default false)
+ */
+ boolean isRequestLoggerEnabled();
+
+ /**
+ * Enable/Disable the recording of the session size
+ * for every request.
+ *
+ * @param record
+ */
+ void setRecordSessionSize(boolean record);
+
+ /**
+ * @return true if the session size is recorded. (default true)
+ */
+ boolean getRecordSessionSize();
+
+ /**
+ * Set the window of all the requests that is kept in memory
+ * for viewing. Default is 2000, You can set this to 0 then
+ * only Sessions data is recorded (number of request, total time, latest size)
+ *
+ * @param size
+ */
+ void setRequestsWindowSize(int size);
+
+ /**
+ * @return The window size of the recorded requests. (default 2000)
+ */
+ int getRequestsWindowSize();
+}