Author: ehillenius
Date: Sun Jun 24 16:46:17 2007
New Revision: 550301

URL: http://svn.apache.org/viewvc?view=rev&rev=550301
Log:
WICKET-689

Removed:
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/IRequestCycleFactory.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ISessionFactory.java
Modified:
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/authorization/RolesApplication.java

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java?view=diff&rev=550301&r1=550300&r2=550301
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
 Sun Jun 24 16:46:17 2007
@@ -636,6 +636,60 @@
        }
 
        /**
+        * Creates a new RequestCycle object. Override this method if you want 
to
+        * provide a custom request cycle.
+        * 
+        * @param application
+        *            The application
+        * @param request
+        *            The request
+        * @param response
+        *            The response
+        * @return The request cycle
+        * 
+        * @since 1.3
+        */
+       public abstract RequestCycle newRequestCycle(final Request request, 
final Response response);
+
+       /**
+        * FOR DEPRECATION ONLY.
+        * 
+        * @param application
+        * @param request
+        * @param response
+        * @return nothing
+        * @throws UnsupportedOperationException
+        *             always
+        * @deprecated interface [EMAIL PROTECTED] IRequestCycleFactory} will 
be removed in the
+        *             next release. applications wishing to provide custom 
request
+        *             cycles should override method
+        *             [EMAIL PROTECTED] #newRequestCycle(Request, Response)}
+        */
+       public final RequestCycle newRequestCycle(Application application, 
Request request,
+                       Response response)
+       {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * Creates a new session. Override this method if you want to provide a
+        * custom session.
+        * 
+        * @param request
+        *            The request that will create this session.
+        * @param response
+        *            The response to initialize, for example with cookies. 
This is
+        *            important to use cases involving unit testing because 
those
+        *            use cases might want to be able to sign a user in
+        *            automatically when the session is created.
+        * 
+        * @return The session
+        * 
+        * @since 1.3
+        */
+       public abstract Session newSession(Request request, Response response);
+
+       /**
         * Removes a component instantiation listener. This method should 
typicaly
         * only be called during application startup; it is not thread safe.
         * 
@@ -782,9 +836,9 @@
         * 
         * @deprecated use [EMAIL PROTECTED] #onDestroy()} instead
         */
+       // TODO remove after deprecation release
        protected final void destroy()
        {
-
        }
 
        /**
@@ -795,18 +849,27 @@
        {
        }
 
-
        /**
         * @return Request cycle factory for this kind of session.
+        * @deprecated replaced by [EMAIL PROTECTED] #newRequestCycle(Request, 
Response)}
         */
-       protected abstract IRequestCycleFactory getRequestCycleFactory();
+       // TODO remove after deprecation release
+       protected final Object getRequestCycleFactory()
+       {
+               throw new UnsupportedOperationException();
+       }
 
        /**
         * Gets the factory for creating session instances.
         * 
         * @return Factory for creating session instances
+        * @deprecated replaced by [EMAIL PROTECTED] #newSession(Request, 
Response)}
         */
-       protected abstract ISessionFactory getSessionFactory();
+       // TODO remove after deprecation release
+       protected final Object getSessionFactory()
+       {
+               throw new UnsupportedOperationException();
+       }
 
        /**
         * Allows for initialization of the application by a subclass. 
<strong>Use
@@ -825,7 +888,7 @@
                // collected (WICKET-625)
                PropertyResolver.destroy(this);
                getMarkupSettings().getMarkupCache().clear();
-               
+
                onDestroy();
                callDestroyers();
                applicationKeyToApplication.remove(getApplicationKey());

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java?view=diff&rev=550301&r1=550300&r2=550301
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
 Sun Jun 24 16:46:17 2007
@@ -257,8 +257,7 @@
                if (session == null)
                {
                        // Create session using session factory
-                       session = 
application.getSessionFactory().newSession(requestCycle.getRequest(),
-                                       requestCycle.getResponse());
+                       session = 
application.newSession(requestCycle.getRequest(), requestCycle.getResponse());
                }
 
                // set thread local

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java?view=diff&rev=550301&r1=550300&r2=550301
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java
 Sun Jun 24 16:46:17 2007
@@ -27,7 +27,6 @@
 
 import org.apache.wicket.Application;
 import org.apache.wicket.Component;
-import org.apache.wicket.IRequestCycleFactory;
 import org.apache.wicket.IRequestTarget;
 import org.apache.wicket.Page;
 import org.apache.wicket.PageParameters;
@@ -113,9 +112,6 @@
        /** Session. */
        private WebSession wicketSession;
 
-       /** Request cycle factory. */
-       private IRequestCycleFactory requestCycleFactory;
-
        /** The homepage */
        private Class homePage;
 
@@ -201,9 +197,6 @@
                                this.context);
                this.servletResponse = new MockHttpServletResponse();
 
-               // Get request cycle factory
-               this.requestCycleFactory = 
this.application.getRequestCycleFactory();
-
                // Construct request and response using factories
                this.wicketRequest = 
this.application.newWebRequest(this.servletRequest);
                this.wicketResponse = 
this.application.newWebResponse(this.servletResponse);
@@ -488,8 +481,9 @@
        public WebRequestCycle createRequestCycle()
        {
                // Create a web request cycle using factory
-               final WebRequestCycle cycle = 
(WebRequestCycle)requestCycleFactory.newRequestCycle(
-                               application, wicketRequest, wicketResponse);
+
+               final WebRequestCycle cycle = 
(WebRequestCycle)application.newRequestCycle(wicketRequest,
+                               wicketResponse);
 
                // Construct session
                this.wicketSession = (WebSession)Session.findOrCreate();

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java?view=diff&rev=550301&r1=550300&r2=550301
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
 Sun Jun 24 16:46:17 2007
@@ -25,9 +25,7 @@
 import javax.servlet.http.HttpSession;
 
 import org.apache.wicket.Application;
-import org.apache.wicket.IRequestCycleFactory;
 import org.apache.wicket.IRequestTarget;
-import org.apache.wicket.ISessionFactory;
 import org.apache.wicket.Request;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.Response;
@@ -73,11 +71,10 @@
  * override the init() method. For example:
  * 
  * <pre>
- *               public void init()
- *               {
- *                   String webXMLParameter = 
getInitParameter(&quot;myWebXMLParameter&quot;);
- *                   URL schedulersConfig = 
getServletContext().getResource(&quot;/WEB-INF/schedulers.xml&quot;);
- *                   ...
+ *  public void init() {
+ *  String webXMLParameter = getInitParameter(&quot;myWebXMLParameter&quot;);
+ *  URL schedulersConfig = 
getServletContext().getResource(&quot;/WEB-INF/schedulers.xml&quot;);
+ *  ...
  * </pre>
  * 
  * @see WicketFilter
@@ -100,7 +97,7 @@
  * @author Eelco Hillenius
  * @author Juergen Donnerstag
  */
-public abstract class WebApplication extends Application implements 
ISessionFactory
+public abstract class WebApplication extends Application
 {
        /** Log. */
        private static final Logger log = 
LoggerFactory.getLogger(WebApplication.class);
@@ -126,9 +123,6 @@
         */
        private String sessionAttributePrefix;
 
-       /** Session factory for this web application */
-       private ISessionFactory sessionFactory = this;
-
        /** The WicketFilter that this application is attached to */
        private WicketFilter wicketFilter;
 
@@ -343,6 +337,15 @@
        }
 
        /**
+        * @see 
org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request,
+        *      org.apache.wicket.Response)
+        */
+       public RequestCycle newRequestCycle(final Request request, final 
Response response)
+       {
+               return new WebRequestCycle(this, (WebRequest)request, 
(WebResponse)response);
+       }
+
+       /**
         * Create new Wicket Session object. Note, this method is not called if 
you
         * registered your own ISessionFactory with the Application.
         * 
@@ -370,7 +373,7 @@
        }
 
        /**
-        * @see 
org.apache.wicket.ISessionFactory#newSession(org.apache.wicket.Request,
+        * @see 
org.apache.wicket.Application#newSession(org.apache.wicket.Request,
         *      org.apache.wicket.Response)
         */
        public Session newSession(Request request, Response response)
@@ -394,15 +397,6 @@
        }
 
        /**
-        * @param sessionFactory
-        *            The session factory to use
-        */
-       public final void setSessionFactory(final ISessionFactory 
sessionFactory)
-       {
-               this.sessionFactory = sessionFactory;
-       }
-
-       /**
         * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
         * 
         * @param wicketFilter
@@ -427,48 +421,15 @@
 
        /**
         * @return nada
-        * @deprecated Replaced by [EMAIL PROTECTED] #getRequestCycleFactory()}
+        * @deprecated Replaced by [EMAIL PROTECTED] #newRequestCycle(Request, 
Response)}
         */
        // TODO remove after compatibility release.
-       protected final IRequestCycleFactory getDefaultRequestCycleFactory()
+       protected final Object getDefaultRequestCycleFactory()
        {
                throw new UnsupportedOperationException("obsolete method. see 
getRequestCycleFactory");
        }
 
        /**
-        * Create a request cycle factory that will be used for creating request
-        * cycle objects.
-        * 
-        * @see WebSession#getRequestCycleFactory()
-        * @see IRequestCycleFactory
-        * 
-        * @return Request cycle factory
-        */
-       protected IRequestCycleFactory getRequestCycleFactory()
-       {
-               return new IRequestCycleFactory()
-               {
-                       private static final long serialVersionUID = 1L;
-
-                       public RequestCycle newRequestCycle(final Application 
application,
-                                       final Request request, final Response 
response)
-                       {
-                               // Respond to request
-                               return new 
WebRequestCycle((WebApplication)application, (WebRequest)request,
-                                               (WebResponse)response);
-                       }
-               };
-       }
-
-       /**
-        * @see org.apache.wicket.Application#getSessionFactory()
-        */
-       protected ISessionFactory getSessionFactory()
-       {
-               return this.sessionFactory;
-       }
-
-       /**
         * Initialize; if you need the wicket servlet for initialization, e.g.
         * because you want to read an initParameter from web.xml or you want to
         * read a resource from the servlet's context path, you can override 
this
@@ -698,23 +659,6 @@
                                + "*** Do NOT deploy to your live server(s) 
without changing this.  ***\n"
                                + "*** See Application#getConfigurationType() 
for more information. ***\n"
                                + 
"********************************************************************\n");
-       }
-
-       /**
-        * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
-        * 
-        * Creates a new RequestCycle for the given request and response using 
the
-        * application's request cycle factory.
-        * 
-        * @param request
-        *            The request
-        * @param response
-        *            The response
-        * @return The new request cycle.
-        */
-       final RequestCycle newRequestCycle(final Request request, final 
Response response)
-       {
-               return getRequestCycleFactory().newRequestCycle(this, request, 
response);
        }
 
        // TODO remove after deprecation release

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java?view=diff&rev=550301&r1=550300&r2=550301
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/CheckGroupTest.java
 Sun Jun 24 16:46:17 2007
@@ -103,6 +103,10 @@
        /**
         * test component form processing
         */
+       // TODO (Eelco) This is an aweful test. Why is 'mock page' (which isn't 
a
+       // real mock, but just some arbitrary page) used rather than a page with
+       // markup that corresponds to the component structure that is build up?
+       // Components and markup go together in Wicket, period.
        public void testFormProcessing()
        {
                // setup some values we will use for testing as well as a test 
model
@@ -127,11 +131,21 @@
 
                RequestCycle cycle = tester.createRequestCycle();
 
+               // this could have been any page it seems. see comment at method
                MockPage page = new MockPage();
 
                // create component hierarchy
 
-               final Form form = new Form("form", new 
CompoundPropertyModel(modelObject));
+               final Form form = new Form("form", new 
CompoundPropertyModel(modelObject))
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       public String getMarkupId()
+                       {
+                               // hack for the fact that this test doesn't 
relate to any markup
+                               return "foo";
+                       }
+               };
 
                final CheckGroup group = new CheckGroup("prop1");
 

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java?view=diff&rev=550301&r1=550300&r2=550301
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java
 Sun Jun 24 16:46:17 2007
@@ -21,7 +21,6 @@
 import junit.framework.TestCase;
 
 import org.apache.wicket.Component;
-import org.apache.wicket.ISessionFactory;
 import org.apache.wicket.Request;
 import org.apache.wicket.Response;
 import org.apache.wicket.RestartResponseAtInterceptPageException;
@@ -78,7 +77,8 @@
                application.setupRequestAndResponse();
                application.processRequestCycle();
                MockLoginPage loginPage = 
(MockLoginPage)application.getLastRenderedPage();
-               
assertEquals(((MyMockWebApplication)application.getApplication()).getLoginPage(),
 loginPage.getClass());
+               
assertEquals(((MyMockWebApplication)application.getApplication()).getLoginPage(),
 loginPage
+                               .getClass());
 
                application.setupRequestAndResponse();
                
application.getServletRequest().setRequestToComponent(loginPage.getForm());
@@ -88,7 +88,8 @@
 
                // continueToInterceptPage seems to return the same call, 
causing it to
                // login twice as a result the lastrendered page is null
-               assertEquals(application.getApplication().getHomePage(), 
application.getLastRenderedPage().getClass());
+               assertEquals(application.getApplication().getHomePage(), 
application.getLastRenderedPage()
+                               .getClass());
 
                application.setupRequestAndResponse();
                application.getServletRequest().setRequestToComponent(
@@ -106,14 +107,16 @@
                application.setupRequestAndResponse();
                application.processRequestCycle();
                MockLoginPage loginPage = 
(MockLoginPage)application.getLastRenderedPage();
-               
assertEquals(((MyMockWebApplication)application.getApplication()).getLoginPage(),
 loginPage.getClass());
+               
assertEquals(((MyMockWebApplication)application.getApplication()).getLoginPage(),
 loginPage
+                               .getClass());
 
                // bypass form completely to login but continue to intercept 
page
                application.setupRequestAndResponse();
                WebRequestCycle requestCycle = application.createRequestCycle();
                
assertTrue(((MockLoginPage)application.getLastRenderedPage()).login("admin"));
                application.processRequestCycle(requestCycle);
-               assertEquals(application.getApplication().getHomePage(), 
application.getLastRenderedPage().getClass());
+               assertEquals(application.getApplication().getHomePage(), 
application.getLastRenderedPage()
+                               .getClass());
 
                application.setupRequestAndResponse();
                application.getServletRequest().setRequestToComponent(
@@ -126,9 +129,10 @@
         * 
         * @author
         */
-       private static class MyMockWebApplication extends WebApplication 
implements ISessionFactory
+       private static class MyMockWebApplication extends WebApplication
        {
                private static final long serialVersionUID = 1L;
+
                public Class getHomePage()
                {
                        return MockHomePage.class;
@@ -156,12 +160,12 @@
                {
                        return new MySession(this, request);
                }
-               
+
                protected WebResponse newWebResponse(HttpServletResponse 
servletResponse)
                {
                        return new WebResponse(servletResponse);
                }
-               
+
                protected void outputDevelopmentModeWarning()
                {
                        // Do nothing.

Modified: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/authorization/RolesApplication.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/authorization/RolesApplication.java?view=diff&rev=550301&r1=550300&r2=550301
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/authorization/RolesApplication.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/authorization/RolesApplication.java
 Sun Jun 24 16:46:17 2007
@@ -19,7 +19,6 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.wicket.ISessionFactory;
 import org.apache.wicket.Request;
 import org.apache.wicket.Response;
 import org.apache.wicket.Session;
@@ -35,7 +34,7 @@
  * 
  * @author Eelco Hillenius
  */
-public class RolesApplication extends WebApplication implements ISessionFactory
+public class RolesApplication extends WebApplication
 {
        /**
         * User DB.
@@ -61,7 +60,8 @@
        }
 
        /**
-        * @see org.apache.wicket.ISessionFactory#newSession(Request, Response)
+        * @see 
org.apache.wicket.protocol.http.WebApplication#newSession(org.apache.wicket.Request,
+        *      org.apache.wicket.Response)
         */
        public Session newSession(Request request, Response response)
        {
@@ -71,7 +71,6 @@
        @Override
        protected void init()
        {
-               setSessionFactory(this);
                getSecuritySettings().setAuthorizationStrategy(
                                new RoleAuthorizationStrategy(new 
UserRolesAuthorizer()));
                
MetaDataRoleAuthorizationStrategy.authorize(AdminBookmarkablePage.class, 
"ADMIN");


Reply via email to