Author: ehillenius
Date: Wed Feb  7 21:12:20 2007
New Revision: 504784

URL: http://svn.apache.org/viewvc?view=rev&rev=504784
Log:
formatted and reordered

Modified:
    
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java

Modified: 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java?view=diff&rev=504784&r1=504783&r2=504784
==============================================================================
--- 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java
 (original)
+++ 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java
 Wed Feb  7 21:12:20 2007
@@ -41,73 +41,51 @@
 public class HttpSessionStore extends AbstractHttpSessionStore
 {
        /**
-        * @see 
wicket.session.ISessionStore#setAttribute(Request,java.lang.String,
-        *      java.lang.Object)
+        * @see wicket.session.ISessionStore#createPageMap(java.lang.String,
+        *      wicket.Session)
         */
-       public void setAttribute(Request request, String name, Object value)
+       public IPageMap createPageMap(String name, Session session)
        {
-               // Do some extra profiling/ debugging. This can be a great help
-               // just for testing whether your webbapp will behave when using
-               // session replication
-               if 
(Application.get().getDebugSettings().getSerializeSessionAttributes())
-               {
-                       // TODO this shouldn't be needed anymore, because this 
method
-                       // should only be called with already detached pages 
(See session.touch)
-//                     if (value instanceof Page)
-//                     {
-//                             ((Page)value).internalDetach();
-//                     }
-                       String valueTypeName = (value != null ? 
value.getClass().getName() : "null");
-                       try
-                       {
-                               final ByteArrayOutputStream out = new 
ByteArrayOutputStream();
-                               new ObjectOutputStream(out).writeObject(value);
-                               log.debug("Stored attribute " + name + "{ " + 
valueTypeName + "} with size: "
-                                               + Bytes.bytes(out.size()));
-                       }
-                       catch (Exception e)
-                       {
-                               throw new WicketRuntimeException(
-                                               "Internal error cloning object. 
Make sure all dependent objects implement Serializable. Class="
-                                                               + valueTypeName 
+ ",attribute=" + name + ", value=" + value, e);
-                       }
-               }
+               return new AccessStackPageMap(name, session);
+       }
 
+       /**
+        * @see wicket.session.ISessionStore#getAttribute(wicket.Request,
+        *      java.lang.String)
+        */
+       public Object getAttribute(Request request, String name)
+       {
                WebRequest webRequest = toWebRequest(request);
                HttpSession httpSession = getHttpSession(webRequest);
                if (httpSession != null)
                {
-                       IRequestLogger logger = application.getRequestLogger();
-                       String attributeName = 
getSessionAttributePrefix(webRequest) + name;
-                       if (logger != null)
-                       {
-                               if (httpSession.getAttribute(attributeName) == 
null)
-                               {
-                                       logger.objectCreated(value);
-                               }
-                               else
-                               {
-                                       logger.objectUpdated(value);
-                               }
-                       }
-
-                       httpSession.setAttribute(attributeName, value);
+                       return 
httpSession.getAttribute(getSessionAttributePrefix(webRequest) + name);
                }
+               return null;
        }
 
        /**
-        * @see wicket.session.ISessionStore#getAttribute(wicket.Request,
-        *      java.lang.String)
+        * @see wicket.session.ISessionStore#getAttributeNames(Request)
         */
-       public Object getAttribute(Request request, String name)
+       public List getAttributeNames(Request request)
        {
+               List list = new ArrayList();
                WebRequest webRequest = toWebRequest(request);
                HttpSession httpSession = getHttpSession(webRequest);
                if (httpSession != null)
                {
-                       return 
httpSession.getAttribute(getSessionAttributePrefix(webRequest) + name);
+                       final Enumeration names = 
httpSession.getAttributeNames();
+                       final String prefix = 
getSessionAttributePrefix(webRequest);
+                       while (names.hasMoreElements())
+                       {
+                               final String name = (String)names.nextElement();
+                               if (name.startsWith(prefix))
+                               {
+                                       
list.add(name.substring(prefix.length()));
+                               }
+                       }
                }
-               return null;
+               return list;
        }
 
        /**
@@ -134,27 +112,59 @@
        }
 
        /**
-        * @see wicket.session.ISessionStore#getAttributeNames(Request)
+        * @see 
wicket.session.ISessionStore#setAttribute(Request,java.lang.String,
+        *      java.lang.Object)
         */
-       public List getAttributeNames(Request request)
+       public void setAttribute(Request request, String name, Object value)
        {
-               List list = new ArrayList();
+               // Do some extra profiling/ debugging. This can be a great help
+               // just for testing whether your webbapp will behave when using
+               // session replication
+               if 
(Application.get().getDebugSettings().getSerializeSessionAttributes())
+               {
+                       // TODO this shouldn't be needed anymore, because this 
method
+                       // should only be called with already detached pages 
(See
+                       // session.touch)
+                       // if (value instanceof Page)
+                       // {
+                       // ((Page)value).internalDetach();
+                       // }
+                       String valueTypeName = (value != null ? 
value.getClass().getName() : "null");
+                       try
+                       {
+                               final ByteArrayOutputStream out = new 
ByteArrayOutputStream();
+                               new ObjectOutputStream(out).writeObject(value);
+                               log.debug("Stored attribute " + name + "{ " + 
valueTypeName + "} with size: "
+                                               + Bytes.bytes(out.size()));
+                       }
+                       catch (Exception e)
+                       {
+                               throw new WicketRuntimeException(
+                                               "Internal error cloning object. 
Make sure all dependent objects implement Serializable. Class="
+                                                               + valueTypeName 
+ ",attribute=" + name + ", value=" + value, e);
+                       }
+               }
+
                WebRequest webRequest = toWebRequest(request);
                HttpSession httpSession = getHttpSession(webRequest);
                if (httpSession != null)
                {
-                       final Enumeration names = 
httpSession.getAttributeNames();
-                       final String prefix = 
getSessionAttributePrefix(webRequest);
-                       while (names.hasMoreElements())
+                       IRequestLogger logger = application.getRequestLogger();
+                       String attributeName = 
getSessionAttributePrefix(webRequest) + name;
+                       if (logger != null)
                        {
-                               final String name = (String)names.nextElement();
-                               if (name.startsWith(prefix))
+                               if (httpSession.getAttribute(attributeName) == 
null)
                                {
-                                       
list.add(name.substring(prefix.length()));
+                                       logger.objectCreated(value);
+                               }
+                               else
+                               {
+                                       logger.objectUpdated(value);
                                }
                        }
+
+                       httpSession.setAttribute(attributeName, value);
                }
-               return list;
        }
 
        /**
@@ -169,14 +179,5 @@
        private String getSessionAttributePrefix(final WebRequest request)
        {
                return application.getSessionAttributePrefix(request);
-       }
-
-       /**
-        * @see wicket.session.ISessionStore#createPageMap(java.lang.String,
-        *      wicket.Session)
-        */
-       public IPageMap createPageMap(String name, Session session)
-       {
-               return new AccessStackPageMap(name, session);
        }
 }


Reply via email to