Author: ehillenius
Date: Fri Feb 16 12:30:54 2007
New Revision: 508563

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

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

Modified: 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletApplication.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletApplication.java?view=diff&rev=508563&r1=508562&r2=508563
==============================================================================
--- 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletApplication.java
 (original)
+++ 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletApplication.java
 Fri Feb 16 12:30:54 2007
@@ -19,6 +19,7 @@
 import javax.portlet.ActionRequest;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletResponse;
+import javax.servlet.http.HttpSession;
 
 import wicket.Application;
 import wicket.IRequestCycleFactory;
@@ -97,27 +98,38 @@
        private WicketPortlet portlet;
 
        /**
-        * @param portlet
+        * 
         */
-       public void setWicketPortlet(WicketPortlet portlet)
+       public void destroyPortlet()
        {
-               if (this.portlet == null)
-               {
-                       this.portlet = portlet;
-                       this.applicationKey = portlet.getPortletName();
-               }
-               else
+               internalDestroy();
+       }
+
+       /**
+        * @return the request cycle processor
+        */
+       public IRequestCycleProcessor getActionRequestCycleProcessor()
+       {
+               if (actionRequestCycleProcessor == null)
                {
-                       throw new IllegalStateException("WicketPortlet cannot 
be changed once it is set");
+                       actionRequestCycleProcessor = 
newActionRequestCycleProcessor();
                }
+               return actionRequestCycleProcessor;
        }
 
-       /**
-        * @return portlet
+       /*
+        * @see wicket.Application#getApplicationKey()
         */
-       public WicketPortlet getWicketPortlet()
+       public String getApplicationKey()
        {
-               return portlet;
+
+               if (applicationKey == null)
+               {
+                       throw new IllegalStateException("the application key 
does not seem to"
+                                       + " be set properly or this method is 
called before WicketPortlet is"
+                                       + " set, which leads to the wrong 
behavior");
+               }
+               return applicationKey;
        }
 
        /**
@@ -163,50 +175,73 @@
        }
 
        /**
-        * @param res
-        * @return new WicketPortletResponse
+        * Gets the prefix for storing variables in the actual session 
(typically
+        * [EMAIL PROTECTED] HttpSession} for this application instance.
+        * 
+        * @param request
+        *            the request
         * 
+        * @return the prefix for storing variables in the actual session
         */
-       public WicketPortletResponse newPortletResponse(final PortletResponse 
res)
+       public final String getSessionAttributePrefix(final 
WicketPortletRequest request)
        {
-               return new WicketPortletResponse(res);
+               if (sessionAttributePrefix == null)
+               {
+                       String contextPath = getApplicationKey();
+                       if (contextPath == null)
+                       {
+                               throw new WicketRuntimeException("unable to 
retrieve portlet context path");
+                       }
+
+                       // WARNING: this has to match the string which is 
returned from the
+                       // WebApplication
+                       // getServletPath is not available in portlets, so we 
have to use
+                       // empty servlet path
+                       // and a empty servlet path string here.
+                       sessionAttributePrefix = "wicket::";
+               }
+               // Namespacing for session attributes is provided by
+               // adding the portlet path
+               return sessionAttributePrefix;
        }
 
        /**
-        * @param req
-        * @return new WicketPortletRequest
+        * @return portlet
         */
-       public WicketPortletRequest newPortletRequest(PortletRequest req)
+       public WicketPortlet getWicketPortlet()
        {
-               return new WicketPortletRequest(req);
+               return portlet;
        }
 
-       /*
-        * @see wicket.Application#getApplicationKey()
+       /**
+        * 
         */
-       public String getApplicationKey()
+       public void initPortlet()
        {
-
-               if (applicationKey == null)
-               {
-                       throw new IllegalStateException("the application key 
does not seem to"
-                                       + " be set properly or this method is 
called before WicketPortlet is"
-                                       + " set, which leads to the wrong 
behavior");
-               }
-               return applicationKey;
+               internalInit();
+               init();
        }
 
-       protected ISessionFactory getSessionFactory()
+       /**
+        * @param req
+        * @return new WicketPortletRequest
+        */
+       public WicketPortletRequest newPortletRequest(PortletRequest req)
        {
-               return this.sessionFactory;
+               return new WicketPortletRequest(req);
        }
 
-       protected ISessionStore newSessionStore()
+
+       /**
+        * @param res
+        * @return new WicketPortletResponse
+        * 
+        */
+       public WicketPortletResponse newPortletResponse(final PortletResponse 
res)
        {
-               return new PortletSessionStore();
+               return new WicketPortletResponse(res);
        }
 
-
        /**
         * Create new WicketPortletSession object
         * 
@@ -218,12 +253,87 @@
        }
 
        /**
+        * @param portlet
+        */
+       public void setWicketPortlet(WicketPortlet portlet)
+       {
+               if (this.portlet == null)
+               {
+                       this.portlet = portlet;
+                       this.applicationKey = portlet.getPortletName();
+               }
+               else
+               {
+                       throw new IllegalStateException("WicketPortlet cannot 
be changed once it is set");
+               }
+       }
+
+       /**
+        * Create a request cycle factory which is used by default by 
WebSession.
+        * You may provide your own default factory by subclassing 
WebApplication
+        * and overriding this method or your may subclass WebSession to create 
a
+        * session specific request cycle factory.
         * 
+        * @see WebSession#getRequestCycleFactory()
+        * @see IRequestCycleFactory
+        * 
+        * @return Request cycle factory
         */
-       public void initPortlet()
+       protected IRequestCycleFactory getDefaultRequestCycleFactory()
        {
-               internalInit();
-               init();
+               return new IRequestCycleFactory()
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       public RequestCycle newRequestCycle(Session session, 
Request request, Response response)
+                       {
+                               if (request instanceof WicketPortletRequest)
+                               {
+
+                                       WicketPortletRequest req = 
(WicketPortletRequest)request;
+                                       WicketPortletResponse res = 
(WicketPortletResponse)response;
+                                       PortletRequest preq = 
req.getPortletRequest();
+                                       PortletResponse pres = 
res.getPortletResponse();
+                                       if (preq instanceof ActionRequest)
+                                       {
+                                               return new 
PortletActionRequestCycle((WicketPortletSession)session,
+                                                               
(WicketPortletRequest)request, (WicketPortletResponse)response);
+
+                                       }
+                                       else
+                                       {
+                                               return new 
PortletRenderRequestCycle((WicketPortletSession)session,
+                                                               
(WicketPortletRequest)request, (WicketPortletResponse)response);
+
+                                       }
+                               }
+                               return new WebRequestCycle((WebSession)session, 
(WebRequest)request,
+                                               (WebResponse)response);
+                       }
+               };
+       }
+
+       /**
+        * Gets the default request cycle processor (with lazy initialization). 
This
+        * is the [EMAIL PROTECTED] IRequestCycleProcessor} that will be used by
+        * [EMAIL PROTECTED] RequestCycle}s when custom implementations of the 
request cycle
+        * do not provide their own customized versions.
+        * 
+        * @return the default request cycle processor
+        */
+       protected final IRequestCycleProcessor getRenderRequestCycleProcessor()
+       {
+               if (requestCycleProcessor == null)
+               {
+                       requestCycleProcessor = 
newRenderRequestCycleProcessor();
+               }
+               return requestCycleProcessor;
+       }
+
+
+       protected ISessionFactory getSessionFactory()
+       {
+               return this.sessionFactory;
        }
 
        /**
@@ -298,59 +408,6 @@
                }
        }
 
-       /**
-        * 
-        */
-       public void destroyPortlet()
-       {
-               internalDestroy();
-       }
-
-       /**
-        * Create a request cycle factory which is used by default by 
WebSession.
-        * You may provide your own default factory by subclassing 
WebApplication
-        * and overriding this method or your may subclass WebSession to create 
a
-        * session specific request cycle factory.
-        * 
-        * @see WebSession#getRequestCycleFactory()
-        * @see IRequestCycleFactory
-        * 
-        * @return Request cycle factory
-        */
-       protected IRequestCycleFactory getDefaultRequestCycleFactory()
-       {
-               return new IRequestCycleFactory()
-               {
-                       private static final long serialVersionUID = 1L;
-
-                       public RequestCycle newRequestCycle(Session session, 
Request request, Response response)
-                       {
-                               if (request instanceof WicketPortletRequest)
-                               {
-
-                                       WicketPortletRequest req = 
(WicketPortletRequest)request;
-                                       WicketPortletResponse res = 
(WicketPortletResponse)response;
-                                       PortletRequest preq = 
req.getPortletRequest();
-                                       PortletResponse pres = 
res.getPortletResponse();
-                                       if (preq instanceof ActionRequest)
-                                       {
-                                               return new 
PortletActionRequestCycle((WicketPortletSession)session,
-                                                               
(WicketPortletRequest)request, (WicketPortletResponse)response);
-
-                                       }
-                                       else
-                                       {
-                                               return new 
PortletRenderRequestCycle((WicketPortletSession)session,
-                                                               
(WicketPortletRequest)request, (WicketPortletResponse)response);
-
-                                       }
-                               }
-                               return new WebRequestCycle((WebSession)session, 
(WebRequest)request,
-                                               (WebResponse)response);
-                       }
-               };
-       }
-
 
        /**
         * May be replaced by subclasses which whishes to uses there own
@@ -358,9 +415,9 @@
         * 
         * @return IRequestCycleProcessor
         */
-       protected IRequestCycleProcessor newRenderRequestCycleProcessor()
+       protected IRequestCycleProcessor newActionRequestCycleProcessor()
        {
-               return new PortletRenderRequestCycleProcessor();
+               return new PortletActionRequestCycleProcessor();
        }
 
        /**
@@ -369,42 +426,17 @@
         * 
         * @return IRequestCycleProcessor
         */
-       protected IRequestCycleProcessor newActionRequestCycleProcessor()
+       protected IRequestCycleProcessor newRenderRequestCycleProcessor()
        {
-               return new PortletActionRequestCycleProcessor();
+               return new PortletRenderRequestCycleProcessor();
        }
 
 
-       /**
-        * @return the request cycle processor
-        */
-       public IRequestCycleProcessor getActionRequestCycleProcessor()
-       {
-               if (actionRequestCycleProcessor == null)
-               {
-                       actionRequestCycleProcessor = 
newActionRequestCycleProcessor();
-               }
-               return actionRequestCycleProcessor;
-       }
-
-       /**
-        * Gets the default request cycle processor (with lazy initialization). 
This
-        * is the [EMAIL PROTECTED] IRequestCycleProcessor} that will be used by
-        * [EMAIL PROTECTED] RequestCycle}s when custom implementations of the 
request cycle
-        * do not provide their own customized versions.
-        * 
-        * @return the default request cycle processor
-        */
-       protected final IRequestCycleProcessor getRenderRequestCycleProcessor()
+       protected ISessionStore newSessionStore()
        {
-               if (requestCycleProcessor == null)
-               {
-                       requestCycleProcessor = 
newRenderRequestCycleProcessor();
-               }
-               return requestCycleProcessor;
+               return new PortletSessionStore();
        }
 
-
        /**
         * @param sessionId
         *            The session id that was destroyed
@@ -416,36 +448,5 @@
                {
                        logger.sessionDestroyed(sessionId);
                }
-       }
-
-       /**
-        * Gets the prefix for storing variables in the actual session 
(typically
-        * [EMAIL PROTECTED] HttpSession} for this application instance.
-        * 
-        * @param request
-        *            the request
-        * 
-        * @return the prefix for storing variables in the actual session
-        */
-       public final String getSessionAttributePrefix(final 
WicketPortletRequest request)
-       {
-               if (sessionAttributePrefix == null)
-               {
-                       String contextPath = getApplicationKey();
-                       if (contextPath == null)
-                       {
-                               throw new WicketRuntimeException("unable to 
retrieve portlet context path");
-                       }
-
-                       // WARNING: this has to match the string which is 
returned from the
-                       // WebApplication
-                       // getServletPath is not available in portlets, so we 
have to use
-                       // empty servlet path
-                       // and a empty servlet path string here.
-                       sessionAttributePrefix = "wicket::";
-               }
-               // Namespacing for session attributes is provided by
-               // adding the portlet path
-               return sessionAttributePrefix;
        }
 }


Reply via email to