You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/03/07 09:39:03 UTC
[9/19] WICKET-4439 Move classes around so that there are no two
packages with the same name in different modules
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/IPageRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/IPageRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/IPageRequestHandler.java
deleted file mode 100644
index 561b532..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/IPageRequestHandler.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler;
-
-import org.apache.wicket.request.component.IRequestablePage;
-
-/**
- * Request handler that works with a page instance.
- *
- * @author Matej Knopp
- */
-public interface IPageRequestHandler extends IPageClassRequestHandler
-{
- /**
- * Returns the page. Be aware that the page can be instantiated if this wasn't the case already.
- *
- * @return page instance
- */
- IRequestablePage getPage();
-
- /**
- * Returns the page id.
- *
- * @return page id
- */
- Integer getPageId();
-
- /**
- * Checks if the page instance is already created or if it will be created when
- * {@link #getPage()} is called
- *
- * @return {@code true} iff page instance is not yet created
- */
- boolean isPageInstanceCreated();
-
- /**
- * Returns the number of times this page has been rendered.
- *
- * @return the number of times this page has been rendered.
- * @see IRequestablePage#getRenderCount()
- */
- Integer getRenderCount();
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java
deleted file mode 100644
index f1eb7b8..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler;
-
-import org.apache.wicket.Page;
-import org.apache.wicket.RequestListenerInterface;
-import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.behavior.Behavior;
-import org.apache.wicket.request.ILoggableRequestHandler;
-import org.apache.wicket.request.IRequestCycle;
-import org.apache.wicket.request.component.IRequestableComponent;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.handler.RenderPageRequestHandler.RedirectPolicy;
-import org.apache.wicket.request.handler.logger.ListenerInterfaceLogData;
-import org.apache.wicket.request.http.WebRequest;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.lang.Args;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Request handler that invokes the listener interface on component and renders page afterwards.
- *
- * @author Matej Knopp
- */
-public class ListenerInterfaceRequestHandler
- implements
- IPageRequestHandler,
- IComponentRequestHandler,
- ILoggableRequestHandler
-{
-
- private static final Logger LOG = LoggerFactory.getLogger(ListenerInterfaceRequestHandler.class);
-
- private final IPageAndComponentProvider pageComponentProvider;
-
- private final RequestListenerInterface listenerInterface;
-
- private final Integer behaviorId;
-
- private ListenerInterfaceLogData logData;
-
- /**
- * Construct.
- *
- * @param pageComponentProvider
- * @param listenerInterface
- * @param behaviorIndex
- */
- public ListenerInterfaceRequestHandler(IPageAndComponentProvider pageComponentProvider,
- RequestListenerInterface listenerInterface, Integer behaviorIndex)
- {
- Args.notNull(pageComponentProvider, "pageComponentProvider");
- Args.notNull(listenerInterface, "listenerInterface");
-
- this.pageComponentProvider = pageComponentProvider;
- this.listenerInterface = listenerInterface;
- behaviorId = behaviorIndex;
- }
-
- /**
- * Construct.
- *
- * @param pageComponentProvider
- * @param listenerInterface
- */
- public ListenerInterfaceRequestHandler(PageAndComponentProvider pageComponentProvider,
- RequestListenerInterface listenerInterface)
- {
- this(pageComponentProvider, listenerInterface, null);
- }
-
- /**
- * @see org.apache.wicket.request.handler.IComponentRequestHandler#getComponent()
- */
- @Override
- public IRequestableComponent getComponent()
- {
- return pageComponentProvider.getComponent();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageRequestHandler#getPage()
- */
- @Override
- public IRequestablePage getPage()
- {
- return pageComponentProvider.getPageInstance();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageClassRequestHandler#getPageClass()
- */
- @Override
- public Class<? extends IRequestablePage> getPageClass()
- {
- return pageComponentProvider.getPageClass();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageRequestHandler#getPageId()
- */
- @Override
- public Integer getPageId()
- {
- return pageComponentProvider.getPageId();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageClassRequestHandler#getPageParameters()
- */
- @Override
- public PageParameters getPageParameters()
- {
- return pageComponentProvider.getPageParameters();
- }
-
- /**
- * @see org.apache.wicket.request.IRequestHandler#detach(org.apache.wicket.request.IRequestCycle)
- */
- @Override
- public void detach(IRequestCycle requestCycle)
- {
- if (logData == null)
- {
- logData = new ListenerInterfaceLogData(pageComponentProvider, listenerInterface,
- behaviorId);
- }
- pageComponentProvider.detach();
- }
-
- /**
- * Returns the listener interface.
- *
- * @return listener interface
- */
- public RequestListenerInterface getListenerInterface()
- {
- return listenerInterface;
- }
-
- /**
- * Index of target behavior or <code>null</code> if component is the target.
- *
- * @return behavior index or <code>null</code>
- */
- public Integer getBehaviorIndex()
- {
- return behaviorId;
- }
-
- /**
- * @see org.apache.wicket.request.IRequestHandler#respond(org.apache.wicket.request.IRequestCycle)
- */
- @Override
- public void respond(final IRequestCycle requestCycle)
- {
- final IRequestablePage page = getPage();
- final boolean freshPage = pageComponentProvider.isPageInstanceFresh();
- final boolean isAjax = ((WebRequest)requestCycle.getRequest()).isAjax();
-
- IRequestableComponent component = null;
- try
- {
- component = getComponent();
- }
- catch (ComponentNotFoundException e)
- {
- // either the page is stateless and the component we are looking for is not added in the
- // constructor
- // or the page is stateful+stale and a new instances was created by pageprovider
- // we denote this by setting component to null
- component = null;
- }
-
- if ((component == null && freshPage) ||
- (component != null && getComponent().getPage() == page))
- {
- if (page instanceof Page)
- {
- // initialize the page to be able to check whether it is stateless
- ((Page)page).internalInitialize();
- }
- final boolean isStateless = page.isPageStateless();
-
- RedirectPolicy policy = isStateless ? RedirectPolicy.NEVER_REDIRECT
- : RedirectPolicy.AUTO_REDIRECT;
- final IPageProvider pageProvider = new PageProvider(page);
-
- if (freshPage && isStateless == false)
- {
- // A listener interface is invoked on an expired page.
-
- // If the page is stateful then we cannot assume that the listener interface is
- // invoked on its initial state (right after page initialization) and that its
- // component and/or behavior will be available. That's why the listener interface
- // should be ignored and the best we can do is to re-paint the newly constructed
- // page.
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug(
- "A ListenerInterface '{}' assigned to '{}' is executed on an expired stateful page. "
- + "Scheduling re-create of the page and ignoring the listener interface...",
- listenerInterface, getComponentPath());
- }
-
- if (isAjax)
- {
- policy = RedirectPolicy.ALWAYS_REDIRECT;
- }
-
- requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
- pageProvider, policy));
- return;
- }
-
- if (isAjax == false && listenerInterface.isRenderPageAfterInvocation())
- {
- // schedule page render after current request handler is done. this can be
- // overridden during invocation of listener
- // method (i.e. by calling RequestCycle#setResponsePage)
- requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
- pageProvider, policy));
- }
-
- invokeListener();
-
- }
- else
- {
- throw new WicketRuntimeException("Component " + getComponent() +
- " has been removed from page.");
- }
- }
-
- private void invokeListener()
- {
- if (getBehaviorIndex() == null)
- {
- listenerInterface.invoke(getComponent());
- }
- else
- {
- try
- {
- Behavior behavior = getComponent().getBehaviorById(behaviorId);
- listenerInterface.invoke(getComponent(), behavior);
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new WicketRuntimeException("Couldn't find component behavior.", e);
- }
-
- }
- }
-
- @Override
- public final boolean isPageInstanceCreated()
- {
- return pageComponentProvider.hasPageInstance();
- }
-
- @Override
- public final String getComponentPath()
- {
- return pageComponentProvider.getComponentPath();
- }
-
- @Override
- public final Integer getRenderCount()
- {
- return pageComponentProvider.getRenderCount();
- }
-
- /** {@inheritDoc} */
- @Override
- public ListenerInterfaceLogData getLogData()
- {
- return logData;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java.orig
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java.orig b/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java.orig
deleted file mode 100644
index a864258..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java.orig
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler;
-
-import org.apache.wicket.Page;
-import org.apache.wicket.RequestListenerInterface;
-import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.behavior.Behavior;
-import org.apache.wicket.request.IRequestCycle;
-import org.apache.wicket.request.component.IRequestableComponent;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.handler.RenderPageRequestHandler.RedirectPolicy;
-import org.apache.wicket.request.http.WebRequest;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.lang.Args;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Request handler that invokes the listener interface on component and renders page afterwards.
- *
- * @author Matej Knopp
- */
-public class ListenerInterfaceRequestHandler
- implements
- IPageRequestHandler,
- IComponentRequestHandler
-{
-
- private static final Logger LOG = LoggerFactory.getLogger(ListenerInterfaceRequestHandler.class);
-
- private final IPageAndComponentProvider pageComponentProvider;
-
- private final RequestListenerInterface listenerInterface;
-
- private final Integer behaviorId;
-
- /**
- * Construct.
- *
- * @param pageComponentProvider
- * @param listenerInterface
- * @param behaviorIndex
- */
- public ListenerInterfaceRequestHandler(IPageAndComponentProvider pageComponentProvider,
- RequestListenerInterface listenerInterface, Integer behaviorIndex)
- {
- Args.notNull(pageComponentProvider, "pageComponentProvider");
- Args.notNull(listenerInterface, "listenerInterface");
-
- this.pageComponentProvider = pageComponentProvider;
- this.listenerInterface = listenerInterface;
- behaviorId = behaviorIndex;
- }
-
- /**
- * Construct.
- *
- * @param pageComponentProvider
- * @param listenerInterface
- */
- public ListenerInterfaceRequestHandler(PageAndComponentProvider pageComponentProvider,
- RequestListenerInterface listenerInterface)
- {
- this(pageComponentProvider, listenerInterface, null);
- }
-
- /**
- * @see org.apache.wicket.request.handler.IComponentRequestHandler#getComponent()
- */
- public IRequestableComponent getComponent()
- {
- return pageComponentProvider.getComponent();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageRequestHandler#getPage()
- */
- public IRequestablePage getPage()
- {
- return pageComponentProvider.getPageInstance();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageClassRequestHandler#getPageClass()
- */
- public Class<? extends IRequestablePage> getPageClass()
- {
- return pageComponentProvider.getPageClass();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageRequestHandler#getPageId()
- */
- public Integer getPageId()
- {
- return pageComponentProvider.getPageId();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageClassRequestHandler#getPageParameters()
- */
- public PageParameters getPageParameters()
- {
- return pageComponentProvider.getPageParameters();
- }
-
- /**
- * @see org.apache.wicket.request.IRequestHandler#detach(org.apache.wicket.request.IRequestCycle)
- */
- public void detach(IRequestCycle requestCycle)
- {
- pageComponentProvider.detach();
- }
-
- /**
- * Returns the listener interface.
- *
- * @return listener interface
- */
- public RequestListenerInterface getListenerInterface()
- {
- return listenerInterface;
- }
-
- /**
- * Index of target behavior or <code>null</code> if component is the target.
- *
- * @return behavior index or <code>null</code>
- */
- public Integer getBehaviorIndex()
- {
- return behaviorId;
- }
-
- /**
- * @see org.apache.wicket.request.IRequestHandler#respond(org.apache.wicket.request.IRequestCycle)
- */
- public void respond(final IRequestCycle requestCycle)
- {
- final boolean isNewPageInstance = pageComponentProvider.isNewPageInstance();
- final boolean isAjax = ((WebRequest)requestCycle.getRequest()).isAjax();
- final IRequestablePage page = getPage();
-
- if (getComponent().getPage() == page)
- {
- if (page instanceof Page)
- {
- // initialize the page to be able to check whether it is stateless
- ((Page)page).internalInitialize();
- }
- final boolean isStateless = page.isPageStateless();
-
- RedirectPolicy policy = isStateless ? RedirectPolicy.NEVER_REDIRECT
- : RedirectPolicy.AUTO_REDIRECT;
- final IPageProvider pageProvider = new PageProvider(page);
-
- if (isNewPageInstance && isStateless == false)
- {
- // A listener interface is invoked on an expired page.
-
- // If the page is stateful then we cannot assume that the listener interface is
- // invoked on its initial state (right after page initialization) and that its
- // component and/or behavior will be available. That's why the listener interface
- // should be ignored and the best we can do is to re-paint the newly constructed
- // page.
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug(
- "A ListenerInterface '{}' assigned to '{}' is executed on an expired stateful page. "
- + "Scheduling re-create of the page and ignoring the listener interface...",
- listenerInterface, getComponentPath());
- }
-
- if (isAjax)
- {
- policy = RedirectPolicy.ALWAYS_REDIRECT;
- }
-
- requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
- pageProvider, policy));
- return;
- }
-
- if (isAjax == false && listenerInterface.isRenderPageAfterInvocation())
- {
- // schedule page render after current request handler is done. this can be
- // overridden during invocation of listener
- // method (i.e. by calling RequestCycle#setResponsePage)
- requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
- pageProvider, policy));
- }
-
- invokeListener();
-
- }
- else
- {
- throw new WicketRuntimeException("Component " + getComponent() +
- " has been removed from page.");
- }
- }
-
- private void invokeListener()
- {
- if (getBehaviorIndex() == null)
- {
- listenerInterface.invoke(getComponent());
- }
- else
- {
- try
- {
- Behavior behavior = getComponent().getBehaviorById(behaviorId);
- listenerInterface.invoke(getComponent(), behavior);
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new WicketRuntimeException("Couldn't find component behavior.", e);
- }
-
- }
- }
-
- public final boolean isPageInstanceCreated()
- {
- return !pageComponentProvider.isNewPageInstance();
- }
-
- public final String getComponentPath()
- {
- return pageComponentProvider.getComponentPath();
- }
-
- public final Integer getRenderCount()
- {
- return pageComponentProvider.getRenderCount();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInvocationNotAllowedException.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInvocationNotAllowedException.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInvocationNotAllowedException.java
deleted file mode 100644
index ac007a4..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInvocationNotAllowedException.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.RequestListenerInterface;
-import org.apache.wicket.behavior.Behavior;
-
-/**
- * Thrown when a listener invocation is attempted on a component or behavior that does not allow it.
- * For example, somehow the user attempted to invoke link's onclick method on a disabled link.
- *
- * @author igor
- */
-public class ListenerInvocationNotAllowedException extends RuntimeException
-{
- private static final long serialVersionUID = 1L;
-
- private final Component component;
- private final Behavior behavior;
- private final RequestListenerInterface iface;
-
- /**
- * Constructor
- *
- * @param iface
- * @param component
- * @param behavior
- * @param message
- */
- public ListenerInvocationNotAllowedException(RequestListenerInterface iface,
- Component component, Behavior behavior, String message)
- {
- super(message + detail(iface, component, behavior));
- this.iface = iface;
- this.component = component;
- this.behavior = behavior;
-
- }
-
- private static String detail(RequestListenerInterface iface, Component component,
- Behavior behavior)
- {
- StringBuilder detail = new StringBuilder("Component: ").append(component.toString(false));
- if (behavior != null)
- {
- detail.append(" Behavior: ").append(behavior.toString());
- }
- detail.append(" Listener: ").append(iface.toString());
- return detail.toString();
- }
-
- /**
- * @return component that was the target of invocation or hosted the behavior that was
- */
- public Component getComponent()
- {
- return component;
- }
-
- /**
- * @return behavior that was the target of invocation or {@code null}
- */
- public Behavior getBehavior()
- {
- return behavior;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/PageAndComponentProvider.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageAndComponentProvider.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/PageAndComponentProvider.java
deleted file mode 100644
index f8abe86..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageAndComponentProvider.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler;
-
-import org.apache.wicket.Page;
-import org.apache.wicket.request.component.IRequestableComponent;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.lang.Args;
-
-/**
- * Extension of {@link PageProvider} that is also capable of providing a Component belonging to the
- * page.
- *
- * @see PageProvider
- *
- * @author Matej Knopp
- */
-public class PageAndComponentProvider extends PageProvider implements IPageAndComponentProvider
-{
- private IRequestableComponent component;
-
- private String componentPath;
-
- /**
- * @see PageProvider#PageProvider(IRequestablePage)
- *
- * @param page
- * @param componentPath
- */
- public PageAndComponentProvider(IRequestablePage page, String componentPath)
- {
- super(page);
- setComponentPath(componentPath);
- }
-
- /**
- * @see PageProvider#PageProvider(IRequestablePage)
- *
- * @param page
- * @param component
- */
- public PageAndComponentProvider(IRequestablePage page, IRequestableComponent component)
- {
- super(page);
-
- Args.notNull(component, "component");
-
- this.component = component;
- }
-
- /**
- * @see PageProvider#PageProvider(Class, PageParameters)
- *
- * @param pageClass
- * @param pageParameters
- * @param componentPath
- */
- public PageAndComponentProvider(Class<? extends IRequestablePage> pageClass,
- PageParameters pageParameters, String componentPath)
- {
- super(pageClass, pageParameters);
- setComponentPath(componentPath);
- }
-
- /**
- * @see PageProvider#PageProvider(Class)
- *
- * @param pageClass
- * @param componentPath
- */
- public PageAndComponentProvider(Class<? extends IRequestablePage> pageClass,
- String componentPath)
- {
- super(pageClass);
- setComponentPath(componentPath);
- }
-
- /**
- * @see PageProvider#PageProvider(int, Class, Integer)
- *
- * @param pageId
- * @param pageClass
- * @param renderCount
- * @param componentPath
- */
- public PageAndComponentProvider(int pageId, Class<? extends IRequestablePage> pageClass,
- Integer renderCount, String componentPath)
- {
- super(pageId, pageClass, renderCount);
- setComponentPath(componentPath);
- }
-
- /**
- * @see PageProvider#PageProvider(int, Class, PageParameters, Integer)
- *
- * @param pageId
- * @param pageClass
- * @param pageParameters
- * @param renderCount
- * @param componentPath
- */
- public PageAndComponentProvider(int pageId, Class<? extends IRequestablePage> pageClass,
- PageParameters pageParameters, Integer renderCount, String componentPath)
- {
- super(pageId, pageClass, pageParameters, renderCount);
- setComponentPath(componentPath);
- }
-
- /**
- * @see PageProvider#PageProvider(int, Integer)
- *
- * @param pageId
- * @param renderCount
- * @param componentPath
- */
- public PageAndComponentProvider(int pageId, Integer renderCount, String componentPath)
- {
- super(pageId, renderCount);
- setComponentPath(componentPath);
- }
-
- public PageAndComponentProvider(IRequestablePage page, IRequestableComponent component,
- PageParameters parameters)
- {
- super(page);
-
- Args.notNull(component, "component");
-
- this.component = component;
- if (parameters != null)
- {
- setPageParameters(parameters);
- }
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageAndComponentProvider#getComponent()
- */
- @Override
- public IRequestableComponent getComponent()
- {
- if (component == null)
- {
- IRequestablePage page = getPageInstance();
- component = page.get(componentPath);
- if (component == null)
- {
-
- /*
- * on stateless pages it is possible that the component may not yet exist because it
- * couldve been created in one of the lifecycle callbacks of this page. Lets invoke
- * the callbacks to give the page a chance to create the missing component.
- */
-
- // make sure this page instance was just created so the page can be stateless
- if (page.isPageStateless())
- {
- Page p = (Page)page;
- p.internalInitialize();
- p.internalPrepareForRender(false);
- component = page.get(componentPath);
- }
- }
- }
- if (component == null)
- {
- throw new ComponentNotFoundException("Could not find component '" + componentPath +
- "' on page '" + getPageClass());
- }
- return component;
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageAndComponentProvider#getComponentPath()
- */
- @Override
- public String getComponentPath()
- {
- if (componentPath != null)
- {
- return componentPath;
- }
- else
- {
- return component.getPageRelativePath();
- }
- }
-
- /**
- *
- * @param componentPath
- */
- private void setComponentPath(String componentPath)
- {
- Args.notNull(componentPath, "componentPath");
-
- this.componentPath = componentPath;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
deleted file mode 100644
index c346a8a..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.page.IPageManager;
-import org.apache.wicket.pageStore.IPageStore;
-import org.apache.wicket.protocol.http.PageExpiredException;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.IRequestMapper;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.mapper.IPageSource;
-import org.apache.wicket.request.mapper.StalePageException;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.lang.Args;
-
-/**
- * Provides page instance for request handlers. Each of the constructors has just enough information
- * to get existing or create new page instance. Requesting or creating page instance is deferred
- * until {@link #getPageInstance()} is called.
- * <p>
- * Purpose of this class is to reduce complexity of both {@link IRequestMapper}s and
- * {@link IRequestHandler}s. {@link IRequestMapper} examines the URL, gathers all relevant
- * information about the page in the URL (combination of page id, page class, page parameters and
- * render count), creates {@link PageProvider} object and creates a {@link IRequestHandler} instance
- * that can use the {@link PageProvider} to access the page.
- * <p>
- * Apart from simplifying {@link IRequestMapper}s and {@link IRequestHandler}s {@link PageProvider}
- * also helps performance because creating or obtaining page from {@link IPageManager} is delayed
- * until the {@link IRequestHandler} actually requires the page.
- *
- * @author Matej Knopp
- */
-public class PageProvider implements IPageProvider
-{
- private final Integer renderCount;
-
- private final Integer pageId;
-
- private IPageSource pageSource;
-
- private IRequestablePage pageInstance;
- private boolean pageInstanceIsFresh;
-
- private Class<? extends IRequestablePage> pageClass;
-
- private PageParameters pageParameters;
-
- /**
- * Creates a new page provider object. Upon calling of {@link #getPageInstance()} this provider
- * will return page instance with specified id.
- *
- * @param pageId
- * @param renderCount
- * optional argument
- */
- public PageProvider(final int pageId, final Integer renderCount)
- {
- this.pageId = pageId;
- this.renderCount = renderCount;
- }
-
- /**
- * Creates a new page provider object. Upon calling of {@link #getPageInstance()} this provider
- * will return page instance with specified id if it exists and it's class matches pageClass. If
- * none of these is true new page instance will be created.
- *
- * @param pageId
- * @param pageClass
- * @param renderCount
- * optional argument
- */
- public PageProvider(final int pageId, final Class<? extends IRequestablePage> pageClass,
- Integer renderCount)
- {
- this(pageId, pageClass, new PageParameters(), renderCount);
- }
-
- /**
- * Creates a new page provider object. Upon calling of {@link #getPageInstance()} this provider
- * will return page instance with specified id if it exists and it's class matches pageClass. If
- * none of these is true new page instance will be created.
- *
- * @param pageId
- * @param pageClass
- * @param pageParameters
- * @param renderCount
- * optional argument
- */
- public PageProvider(final int pageId, final Class<? extends IRequestablePage> pageClass,
- final PageParameters pageParameters, final Integer renderCount)
- {
- this.pageId = pageId;
- setPageClass(pageClass);
- setPageParameters(pageParameters);
- this.renderCount = renderCount;
- }
-
- /**
- * Creates a new page provider object. Upon calling of {@link #getPageInstance()} this provider
- * will return new instance of page with specified class.
- *
- * @param pageClass
- * @param pageParameters
- */
- public PageProvider(final Class<? extends IRequestablePage> pageClass,
- final PageParameters pageParameters)
- {
- setPageClass(pageClass);
- if (pageParameters != null)
- {
- setPageParameters(pageParameters);
- }
- pageId = null;
- renderCount = null;
- }
-
- /**
- * Creates a new page provider object. Upon calling of {@link #getPageInstance()} this provider
- * will return new instance of page with specified class.
- *
- * @param pageClass
- */
- public PageProvider(Class<? extends IRequestablePage> pageClass)
- {
- this(pageClass, null);
- }
-
- /**
- * Creates a new page provider object. Upon calling of {@link #getPageInstance()} this provider
- * will return the given page instance.
- *
- * @param page
- */
- public PageProvider(IRequestablePage page)
- {
- Args.notNull(page, "page");
-
- pageInstance = page;
- pageId = page.getPageId();
- renderCount = page.getRenderCount();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageProvider#getPageInstance()
- */
- @Override
- public IRequestablePage getPageInstance()
- {
- if (pageInstance == null)
- {
- resolvePageInstance(pageId, pageClass, pageParameters, renderCount);
-
- if (pageInstance == null)
- {
- throw new PageExpiredException("Page with id '" + pageId + "' has expired.");
- }
- }
- return pageInstance;
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageProvider#getPageParameters()
- */
- @Override
- public PageParameters getPageParameters()
- {
- if (pageParameters != null)
- {
- return pageParameters;
- }
- else if (isNewPageInstance() == false)
- {
- return pageInstance.getPageParameters();
- }
- else
- {
- return null;
- }
- }
-
- /**
- * The page instance is new only if there is no cached instance or the data stores doesn't have
- * a page with that id with the same {@linkplain #pageClass}.
- *
- * @see org.apache.wicket.request.handler.IPageProvider#isNewPageInstance()
- */
- @Override
- public boolean isNewPageInstance()
- {
- boolean isNew = pageInstance == null;
- if (isNew && pageId != null)
- {
- IRequestablePage storedPageInstance = getStoredPage(pageId);
- if (storedPageInstance != null)
- {
- pageInstance = storedPageInstance;
- isNew = false;
- }
- }
-
- return isNew;
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageProvider#getPageClass()
- */
- @Override
- public Class<? extends IRequestablePage> getPageClass()
- {
- if (pageClass != null)
- {
- return pageClass;
- }
- else
- {
- return getPageInstance().getClass();
- }
- }
-
- protected IPageSource getPageSource()
- {
- if (pageSource != null)
- {
- return pageSource;
- }
- if (Application.exists())
- {
- return Application.get().getMapperContext();
- }
- else
- {
- throw new IllegalStateException(
- "No application is bound to current thread. Call setPageSource() to manually assign pageSource to this provider.");
- }
- }
-
- private void resolvePageInstance(Integer pageId, Class<? extends IRequestablePage> pageClass,
- PageParameters pageParameters, Integer renderCount)
- {
- IRequestablePage page = null;
-
- boolean freshCreated = false;
-
- if (pageId != null)
- {
- page = getStoredPage(pageId);
- }
-
- if (page == null)
- {
- if (pageClass != null)
- {
- page = getPageSource().newPageInstance(pageClass, pageParameters);
- freshCreated = true;
- }
- }
-
- if (page != null && !freshCreated)
- {
- if (renderCount != null && page.getRenderCount() != renderCount)
- {
- throw new StalePageException(page);
- }
- }
-
- pageInstanceIsFresh = freshCreated;
- pageInstance = page;
- }
-
- /**
- * Looks up a page by id from the {@link IPageStore}. <br/>
- * If {@linkplain #pageClass} is specified then compares it against the stored instance class
- * and returns the found instance only if they match.
- *
- * @param pageId
- * the id of the page to look for.
- * @return the found page instance by id.
- */
- private IRequestablePage getStoredPage(final int pageId)
- {
- IRequestablePage storedPageInstance = getPageSource().getPageInstance(pageId);
- if (storedPageInstance != null &&
- (pageClass == null || pageClass.equals(storedPageInstance.getClass())))
- {
- pageInstance = storedPageInstance;
- pageInstanceIsFresh = false;
- if (pageInstance != null)
- {
- if (renderCount != null && pageInstance.getRenderCount() != renderCount)
- {
- throw new StalePageException(pageInstance);
- }
- }
- }
- return storedPageInstance;
- }
-
- /**
- * Detaches the page if it has been loaded (that means either
- * {@link #PageProvider(IRequestablePage)} constructor has been used or
- * {@link #getPageInstance()} has been called).
- */
- @Override
- public void detach()
- {
- if (pageInstance != null)
- {
- pageInstance.detach();
- }
- }
-
- /**
- * If the {@link PageProvider} is used outside request thread (thread that does not have
- * application instance assigned) it is necessary to specify a {@link IPageSource} instance so
- * that {@link PageProvider} knows how to get a page instance.
- *
- * @param pageSource
- */
- public void setPageSource(IPageSource pageSource)
- {
- this.pageSource = pageSource;
- }
-
- /**
- *
- * @param pageClass
- */
- private void setPageClass(Class<? extends IRequestablePage> pageClass)
- {
- Args.notNull(pageClass, "pageClass");
-
- this.pageClass = pageClass;
- }
-
- /**
- *
- * @param pageParameters
- */
- protected void setPageParameters(PageParameters pageParameters)
- {
- this.pageParameters = pageParameters;
- }
-
- /**
- *
- * @return page id
- */
- @Override
- public Integer getPageId()
- {
- return pageId;
- }
-
- @Override
- public Integer getRenderCount()
- {
- return renderCount;
- }
-
- /**
- * Checks whether or not the provider has a page instance. This page instance might have been
- * passed to this page provider directly or it may have been instantiated or retrieved from the
- * page store.
- *
- * @return {@code true} iff page instance has been created or retrieved
- */
- @Override
- public final boolean hasPageInstance()
- {
- if (pageInstance == null && pageId != null)
- {
- // attempt to load a stored page instance from the page store
- getStoredPage(pageId);
- }
- return pageInstance != null;
- }
-
- /**
- * Returns whether or not the page instance held by this provider has been instantiated by the
- * provider.
- *
- * @throws IllegalStateException
- * if this method is called and the provider does not yet have a page instance, ie
- * if {@link #getPageInstance()} has never been called on this provider
- * @return {@code true} iff the page instance held by this provider was instantiated by the
- * provider
- */
- @Override
- public final boolean isPageInstanceFresh()
- {
- if (!hasPageInstance())
- {
- throw new IllegalStateException("Page instance not yet resolved");
- }
- return pageInstanceIsFresh;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/RenderPageRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/RenderPageRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/RenderPageRequestHandler.java
deleted file mode 100644
index a7f0344..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/RenderPageRequestHandler.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.request.ILoggableRequestHandler;
-import org.apache.wicket.request.IRequestCycle;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.handler.logger.PageLogData;
-import org.apache.wicket.request.handler.render.PageRenderer;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.lang.Args;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link IRequestHandler} that renders page instance. Depending on the <code>redirectPolicy</code>
- * flag and current request strategy the handler either just renders the page to the response, or
- * redirects to render the page. <code>REDIRECT_TO_BUFFER</code> strategy is also supported.
- * <p>
- *
- * @author Matej Knopp
- */
-public class RenderPageRequestHandler
- implements
- IPageRequestHandler,
- IPageClassRequestHandler,
- ILoggableRequestHandler
-{
- private static final Logger logger = LoggerFactory.getLogger(RenderPageRequestHandler.class);
-
- private final IPageProvider pageProvider;
-
- private final RedirectPolicy redirectPolicy;
-
- private PageLogData logData;
-
- /**
- * Determines whether Wicket does a redirect when rendering a page
- *
- * @author Matej Knopp
- */
- public enum RedirectPolicy {
- /**
- * Always redirect if current request URL is different than page URL.
- */
- ALWAYS_REDIRECT,
-
- /**
- * Never redirect - always render the page to current response.
- */
- NEVER_REDIRECT,
-
- /**
- * Redirect if necessary. The redirect will happen when all of the following conditions are
- * met:
- * <ul>
- * <li>current request URL is different than page URL
- * <li>page is not stateless or (page is stateless and session is not temporary)
- * <li>render strategy is either REDIRECT_TO_BUFFER or REDIRECT_TO_RENDER
- * </ul>
- */
- AUTO_REDIRECT
- }
-
- /**
- * Construct. Renders the page with a redirect if necessary.
- *
- * @param pageProvider
- */
- public RenderPageRequestHandler(IPageProvider pageProvider)
- {
- this(pageProvider, RedirectPolicy.AUTO_REDIRECT);
- }
-
- /**
- * Construct.
- *
- * @param pageProvider
- * @param redirectPolicy
- */
- public RenderPageRequestHandler(IPageProvider pageProvider, RedirectPolicy redirectPolicy)
- {
- Args.notNull(pageProvider, "pageProvider");
- Args.notNull(redirectPolicy, "redirectPolicy");
-
- this.redirectPolicy = redirectPolicy;
- this.pageProvider = pageProvider;
- }
-
- /**
- * @return page provider
- */
- public IPageProvider getPageProvider()
- {
- return pageProvider;
- }
-
- /**
- * @return redirect policy
- */
- public RedirectPolicy getRedirectPolicy()
- {
- return redirectPolicy;
- }
-
- /** {@inheritDoc} */
- @Override
- public Class<? extends IRequestablePage> getPageClass()
- {
- return pageProvider.getPageClass();
- }
-
- /**
- * @see org.apache.wicket.request.handler.IPageRequestHandler#getPageId()
- */
- @Override
- public Integer getPageId()
- {
- return pageProvider.getPageId();
- }
-
- /** {@inheritDoc} */
- @Override
- public PageParameters getPageParameters()
- {
- return pageProvider.getPageParameters();
- }
-
- /** {@inheritDoc} */
- @Override
- public void detach(IRequestCycle requestCycle)
- {
- if (logData == null)
- logData = new PageLogData(pageProvider);
- pageProvider.detach();
- }
-
- /** {@inheritDoc} */
- @Override
- public PageLogData getLogData()
- {
- return logData;
- }
-
- /** {@inheritDoc} */
- @Override
- public IRequestablePage getPage()
- {
- return pageProvider.getPageInstance();
- }
-
- /** {@inheritDoc} */
- @Override
- public void respond(IRequestCycle requestCycle)
- {
- PageRenderer renderer = Application.get().getPageRendererProvider().get(this);
- renderer.respond((RequestCycle)requestCycle);
- }
-
- @Override
- public final boolean isPageInstanceCreated()
- {
- return pageProvider.hasPageInstance();
- }
-
- @Override
- public final Integer getRenderCount()
- {
- return pageProvider.getRenderCount();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ListenerInterfaceLogData.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ListenerInterfaceLogData.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ListenerInterfaceLogData.java
deleted file mode 100644
index 4431aca..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ListenerInterfaceLogData.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler.logger;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.RequestListenerInterface;
-import org.apache.wicket.behavior.Behavior;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.IFormSubmitListener;
-import org.apache.wicket.markup.html.form.IFormSubmitter;
-import org.apache.wicket.request.component.IRequestableComponent;
-import org.apache.wicket.request.handler.IPageAndComponentProvider;
-
-/**
- * Contains logging data for component/listener-interface request handlers.
- *
- * @author Emond Papegaaij
- */
-public class ListenerInterfaceLogData extends PageLogData
-{
- private static final long serialVersionUID = 1L;
-
- private final Class<? extends IRequestableComponent> componentClass;
- private final String componentPath;
- private final Integer behaviorIndex;
- private Class<? extends Behavior> behaviorClass;
- private final String interfaceName;
- private final String interfaceMethod;
- private Class<? extends IRequestableComponent> submittingComponentClass;
- private String submittingComponentPath;
-
- /**
- * Construct.
- *
- * @param pageAndComponentProvider
- * @param listenerInterface
- * @param behaviorIndex
- */
- public ListenerInterfaceLogData(IPageAndComponentProvider pageAndComponentProvider,
- RequestListenerInterface listenerInterface, Integer behaviorIndex)
- {
- super(pageAndComponentProvider);
- componentClass = tryToGetComponentClass(pageAndComponentProvider);
- componentPath = tryToGetComponentPath(pageAndComponentProvider);
- this.behaviorIndex = behaviorIndex;
- if (behaviorIndex != null && componentClass != null)
- {
- try
- {
- behaviorClass = pageAndComponentProvider.getComponent()
- .getBehaviorById(behaviorIndex)
- .getClass();
- }
- catch (Exception ignore)
- {
- behaviorClass = null;
- }
- }
- else
- {
- behaviorClass = null;
- }
- interfaceName = listenerInterface.getName();
- interfaceMethod = listenerInterface.getMethod().getName();
- if (listenerInterface.getListenerInterfaceClass().equals(IFormSubmitListener.class))
- {
- final Component formSubmitter = tryToGetFormSubmittingComponent(pageAndComponentProvider);
- if (formSubmitter != null)
- {
- submittingComponentClass = formSubmitter.getClass();
- submittingComponentPath = formSubmitter.getPageRelativePath();
- }
- }
- }
-
- private static Class<? extends IRequestableComponent> tryToGetComponentClass(
- IPageAndComponentProvider pageAndComponentProvider)
- {
- try
- {
- return pageAndComponentProvider.getComponent().getClass();
- }
- catch (Exception e)
- {
- // getComponent might fail if the page does not exist (ie session timeout)
- return null;
- }
- }
-
-
- private static String tryToGetComponentPath(IPageAndComponentProvider pageAndComponentProvider)
- {
- try
- {
- return pageAndComponentProvider.getComponentPath();
- }
- catch (Exception e)
- {
- // getComponentPath might fail if the page does not exist (ie session timeout)
- return null;
- }
- }
-
- private static Component tryToGetFormSubmittingComponent(
- IPageAndComponentProvider pageAndComponentProvider)
- {
- try
- {
- final IRequestableComponent component = pageAndComponentProvider.getComponent();
- if (component instanceof Form)
- {
- final IFormSubmitter submitter = ((Form<?>)component).findSubmittingButton();
- return submitter instanceof Component ? (Component)submitter : null;
- }
- return null;
- }
- catch (Exception e)
- {
- // getComponent might fail if the page does not exist (ie session timeout)
- return null;
- }
- }
-
- /**
- * @return componentClass
- */
- public final Class<? extends IRequestableComponent> getComponentClass()
- {
- return componentClass;
- }
-
- /**
- * @return componentPath
- */
- public final String getComponentPath()
- {
- return componentPath;
- }
-
- /**
- * @return behaviorIndex
- */
- public final Integer getBehaviorIndex()
- {
- return behaviorIndex;
- }
-
- /**
- * @return behaviorClass
- */
- public final Class<? extends Behavior> getBehaviorClass()
- {
- return behaviorClass;
- }
-
- /**
- * @return interfaceName
- */
- public final String getInterfaceName()
- {
- return interfaceName;
- }
-
- /**
- * @return interfaceMethod
- */
- public final String getInterfaceMethod()
- {
- return interfaceMethod;
- }
-
- /**
- * @return submittingComponentClass
- */
- public Class<? extends IRequestableComponent> getSubmittingComponentClass()
- {
- return submittingComponentClass;
- }
-
- /**
- * @return submittingComponentPath
- */
- public String getSubmittingComponentPath()
- {
- return submittingComponentPath;
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder(super.toString());
- sb.setCharAt(sb.length() - 1, ',');
- if (getComponentClass() != null)
- {
- sb.append("componentClass=");
- sb.append(getComponentClass().getName());
- sb.append(',');
- }
- if (getComponentPath() != null)
- {
- sb.append("componentPath=");
- sb.append(getComponentPath());
- sb.append(',');
- }
- sb.append("behaviorIndex=");
- sb.append(getBehaviorIndex());
- if (getBehaviorClass() != null)
- {
- sb.append(",behaviorClass=");
- sb.append(getBehaviorClass().getName());
- }
- sb.append(",interfaceName=");
- sb.append(getInterfaceName());
- sb.append(",interfaceMethod=");
- sb.append(getInterfaceMethod());
- if (getSubmittingComponentClass() != null)
- {
- sb.append(",submittingComponentClass=");
- sb.append(getSubmittingComponentClass().getName());
- }
- if (getSubmittingComponentPath() != null)
- {
- sb.append(",submittingComponentPath=");
- sb.append(getSubmittingComponentPath());
- }
- sb.append("}");
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/PageLogData.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/PageLogData.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/PageLogData.java
deleted file mode 100644
index 3cb9b1a..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/PageLogData.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler.logger;
-
-import org.apache.wicket.Page;
-import org.apache.wicket.request.ILogData;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.handler.IPageClassRequestHandler;
-import org.apache.wicket.request.handler.IPageProvider;
-import org.apache.wicket.request.handler.IPageRequestHandler;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-/**
- * Contains logging data for request handlers that are related to pages; most likely
- * {@link IPageRequestHandler} or {@link IPageClassRequestHandler}.
- *
- * @author Emond Papegaaij
- */
-public class PageLogData implements ILogData
-{
- private static final long serialVersionUID = 1L;
-
- private final Class<? extends IRequestablePage> pageClass;
- private final Integer pageId;
- private final PageParameters pageParameters;
- private final Integer renderCount;
-
- /**
- * Construct.
- *
- * @param pageProvider
- */
- public PageLogData(IPageProvider pageProvider)
- {
- pageClass = tryToGetPageClass(pageProvider);
- pageId = pageProvider.getPageId();
- pageParameters = pageProvider.getPageParameters();
- renderCount = pageProvider.getRenderCount();
- }
-
- private static Class<? extends IRequestablePage> tryToGetPageClass(IPageProvider pageProvider)
- {
- try
- {
- return pageProvider.getPageClass();
- }
- catch (Exception e)
- {
- // getPageClass might fail if the page does not exist (ie session timeout)
- return null;
- }
- }
-
- /**
- * Construct.
- *
- * @param page
- */
- public PageLogData(Page page)
- {
- pageClass = page.getPageClass();
- pageId = page.getPageId();
- pageParameters = page.getPageParameters();
- renderCount = page.getRenderCount();
- }
-
- /**
- * @return pageClass
- */
- public final Class<? extends IRequestablePage> getPageClass()
- {
- return pageClass;
- }
-
- /**
- * @return pageId
- */
- public final Integer getPageId()
- {
- return pageId;
- }
-
- /**
- * @return pageParameters
- */
- public final PageParameters getPageParameters()
- {
- return pageParameters;
- }
-
- /**
- * @return renderCount
- */
- public final Integer getRenderCount()
- {
- return renderCount;
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder("{");
- if (pageClass != null)
- {
- sb.append("pageClass=");
- sb.append(getPageClass().getName());
- sb.append(',');
- }
- sb.append("pageId=");
- sb.append(getPageId());
- sb.append(",pageParameters={");
- sb.append(getPageParameters());
- sb.append("},renderCount=");
- sb.append(getRenderCount());
- sb.append("}");
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ResourceReferenceLogData.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ResourceReferenceLogData.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ResourceReferenceLogData.java
deleted file mode 100644
index 54f6762..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ResourceReferenceLogData.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler.logger;
-
-import org.apache.wicket.request.handler.resource.ResourceLogData;
-import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.request.resource.ResourceReference;
-
-/**
- * Contains logging data for resource reference requests.
- *
- * @author Emond Papegaaij
- */
-public class ResourceReferenceLogData extends ResourceLogData
-{
- private static final long serialVersionUID = 1L;
-
- private final Class<? extends ResourceReference> resourceReferenceClass;
- private final Class<?> scope;
- private final PageParameters pageParameters;
-
- /**
- * Construct.
- *
- * @param refHandler
- */
- public ResourceReferenceLogData(ResourceReferenceRequestHandler refHandler)
- {
- super(refHandler.getResourceReference().getName(), refHandler.getLocale(),
- refHandler.getStyle(), refHandler.getVariation());
- resourceReferenceClass = refHandler.getResourceReference().getClass();
- scope = refHandler.getResourceReference().getScope();
- pageParameters = refHandler.getPageParameters();
- }
-
- /**
- * @return resourceReferenceClass
- */
- public final Class<? extends ResourceReference> getResourceReferenceClass()
- {
- return resourceReferenceClass;
- }
-
- /**
- * @return scope
- */
- public final Class<?> getScope()
- {
- return scope;
- }
-
- /***
- * @return pageParameters
- */
- public final PageParameters getPageParameters()
- {
- return pageParameters;
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder("{");
- fillToString(sb);
- sb.append(",resourceReferenceClass=");
- sb.append(getResourceReferenceClass().getName());
- sb.append(",scope=");
- sb.append(getScope() == null ? "null" : getScope().getName());
- sb.append(",pageParameters={");
- sb.append(getPageParameters());
- sb.append("}}");
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ResourceStreamLogData.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ResourceStreamLogData.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ResourceStreamLogData.java
deleted file mode 100644
index 935e74e..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/logger/ResourceStreamLogData.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.handler.logger;
-
-import org.apache.wicket.request.handler.resource.ResourceLogData;
-import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler;
-import org.apache.wicket.request.resource.ContentDisposition;
-import org.apache.wicket.util.resource.IResourceStream;
-
-/**
- * Contains logging data for resource stream requests, handled by
- * {@link ResourceStreamRequestHandler}.
- *
- * @author Emond Papegaaij
- */
-public class ResourceStreamLogData extends ResourceLogData
-{
- private static final long serialVersionUID = 1L;
-
- private final Class<? extends IResourceStream> resourceStreamClass;
- private final ContentDisposition contentDisposition;
- private final String contentType;
-
- /**
- * Construct.
- *
- * @param streamHandler
- */
- public ResourceStreamLogData(ResourceStreamRequestHandler streamHandler)
- {
- super(streamHandler.getFileName(), null, null, null);
- contentDisposition = streamHandler.getContentDisposition();
- resourceStreamClass = null;
- contentType = null;
- }
-
- /**
- * Construct.
- *
- * @param streamHandler
- * @param stream
- */
- public ResourceStreamLogData(ResourceStreamRequestHandler streamHandler, IResourceStream stream)
- {
- super(streamHandler.getFileName(), stream.getLocale(), stream.getStyle(),
- stream.getVariation());
- contentDisposition = streamHandler.getContentDisposition();
- resourceStreamClass = stream.getClass();
- contentType = stream.getContentType();
- }
-
- /**
- * Returns the class of the resource stream.
- *
- * @return The class of the resource stream.
- */
- public final Class<? extends IResourceStream> getResourceStreamClass()
- {
- return resourceStreamClass;
- }
-
- /**
- * @return contentDisposition.
- */
- public final ContentDisposition getContentDisposition()
- {
- return contentDisposition;
- }
-
- /**
- * @return contentType
- */
- public final String getContentType()
- {
- return contentType;
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder("{");
- fillToString(sb);
- sb.append(",contentDisposition=");
- sb.append(getContentDisposition());
- if (getResourceStreamClass() != null)
- {
- sb.append(",resourceStreamClass=");
- sb.append(getResourceStreamClass().getName());
- sb.append(",contentType=");
- sb.append(getContentType());
- }
- sb.append("}");
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/render/PageRenderer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/PageRenderer.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/PageRenderer.java
index 699c76a..f7419be 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/PageRenderer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/PageRenderer.java
@@ -20,9 +20,9 @@ import org.apache.wicket.Application;
import org.apache.wicket.Session;
import org.apache.wicket.request.component.IRequestablePage;
import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.handler.IPageProvider;
-import org.apache.wicket.request.handler.RenderPageRequestHandler;
-import org.apache.wicket.request.handler.RenderPageRequestHandler.RedirectPolicy;
+import org.apache.wicket.core.request.handler.IPageProvider;
+import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
+import org.apache.wicket.core.request.handler.RenderPageRequestHandler.RedirectPolicy;
import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy;
/**
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
index 3c84f2c..b92f3e3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
@@ -23,8 +23,8 @@ import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.handler.RenderPageRequestHandler;
-import org.apache.wicket.request.handler.RenderPageRequestHandler.RedirectPolicy;
+import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
+import org.apache.wicket.core.request.handler.RenderPageRequestHandler.RedirectPolicy;
import org.apache.wicket.request.http.WebRequest;
import org.apache.wicket.request.http.WebResponse;
import org.slf4j.Logger;
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceReferenceRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceReferenceRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceReferenceRequestHandler.java
index 80dc89b..2e9d7b6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceReferenceRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceReferenceRequestHandler.java
@@ -21,7 +21,7 @@ import java.util.Locale;
import org.apache.wicket.request.ILoggableRequestHandler;
import org.apache.wicket.request.IRequestCycle;
import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.handler.logger.ResourceReferenceLogData;
+import org.apache.wicket.core.request.handler.logger.ResourceReferenceLogData;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.IResource;
import org.apache.wicket.request.resource.ResourceReference;
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceStreamRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceStreamRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceStreamRequestHandler.java
index 62ccdae..52ab80c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceStreamRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/ResourceStreamRequestHandler.java
@@ -19,7 +19,7 @@ package org.apache.wicket.request.handler.resource;
import org.apache.wicket.request.ILoggableRequestHandler;
import org.apache.wicket.request.IRequestCycle;
import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.handler.logger.ResourceStreamLogData;
+import org.apache.wicket.core.request.handler.logger.ResourceStreamLogData;
import org.apache.wicket.request.resource.ContentDisposition;
import org.apache.wicket.request.resource.IResource.Attributes;
import org.apache.wicket.request.resource.ResourceStreamResource;
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/WebExternalResourceRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/WebExternalResourceRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/WebExternalResourceRequestHandler.java
index 7b66803..dbcfbb4 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/WebExternalResourceRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/resource/WebExternalResourceRequestHandler.java
@@ -18,7 +18,7 @@ package org.apache.wicket.request.handler.resource;
import org.apache.wicket.request.IRequestCycle;
import org.apache.wicket.request.resource.ContentDisposition;
-import org.apache.wicket.util.resource.WebExternalResourceStream;
+import org.apache.wicket.core.util.resource.WebExternalResourceStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
/**
* Request target that is not a Wicket resource. For example, such a resource could denote an image
* in the web application directory (not mapped to a Wicket servlet). NOTE: this target can only be
- * used in a servlet environment with {@link org.apache.wicket.protocol.http.RequestCycle}s.
+ * used in a servlet environment with {@link org.apache.wicket.request.cycle.RequestCycle}s.
*
* <p>
* <b>NOTE:</b> this class is a wrapper around
http://git-wip-us.apache.org/repos/asf/wicket/blob/53f07873/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java
deleted file mode 100644
index ad48cf1..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.wicket.request.mapper;
-
-import org.apache.wicket.RequestListenerInterface;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.IRequestHandlerDelegate;
-import org.apache.wicket.request.IRequestMapper;
-import org.apache.wicket.request.Request;
-import org.apache.wicket.request.Url;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.handler.BookmarkableListenerInterfaceRequestHandler;
-import org.apache.wicket.request.handler.BookmarkablePageRequestHandler;
-import org.apache.wicket.request.handler.ListenerInterfaceRequestHandler;
-import org.apache.wicket.request.handler.PageAndComponentProvider;
-import org.apache.wicket.request.handler.PageProvider;
-import org.apache.wicket.request.handler.RenderPageRequestHandler;
-import org.apache.wicket.request.http.WebRequest;
-import org.apache.wicket.request.mapper.info.ComponentInfo;
-import org.apache.wicket.request.mapper.info.PageComponentInfo;
-import org.apache.wicket.request.mapper.info.PageInfo;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.lang.Args;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract encoder for Bookmarkable, Hybrid and BookmarkableListenerInterface URLs.
- *
- * @author Matej Knopp
- */
-public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
-{
- private static Logger logger = LoggerFactory.getLogger(AbstractBookmarkableMapper.class);
-
- /**
- * Represents information stored in URL.
- *
- * @author Matej Knopp
- */
- protected static final class UrlInfo
- {
- private final PageComponentInfo pageComponentInfo;
- private final PageParameters pageParameters;
- private final Class<? extends IRequestablePage> pageClass;
-
- /**
- * Construct.
- *
- * @param pageComponentInfo
- * optional parameter providing the page instance and component information
- * @param pageClass
- * mandatory parameter
- * @param pageParameters
- * optional parameter providing pageParameters
- */
- public UrlInfo(PageComponentInfo pageComponentInfo,
- Class<? extends IRequestablePage> pageClass, PageParameters pageParameters)
- {
- Args.notNull(pageClass, "pageClass");
-
- this.pageComponentInfo = pageComponentInfo;
- this.pageParameters = cleanPageParameters(pageParameters);
-
- this.pageClass = pageClass;
- }
-
- /**
- * Cleans the original parameters from entries used by Wicket internals.
- *
- * @param originalParameters
- * the current request's non-modified parameters
- * @return all parameters but Wicket internal ones
- */
- private PageParameters cleanPageParameters(final PageParameters originalParameters)
- {
- PageParameters cleanParameters = null;
- if (originalParameters != null)
- {
- cleanParameters = new PageParameters(originalParameters);
-
- // WICKET-4038: Ajax related parameters are set by wicket-ajax.js when needed.
- // They shouldn't be propagated to the next requests
- cleanParameters.remove(WebRequest.PARAM_AJAX);
- cleanParameters.remove(WebRequest.PARAM_AJAX_BASE_URL);
- cleanParameters.remove(WebRequest.PARAM_AJAX_REQUEST_ANTI_CACHE);
-
- if (cleanParameters.isEmpty())
- {
- cleanParameters = null;
- }
- }
- return cleanParameters;
- }
-
- /**
- * @return PageComponentInfo instance or <code>null</code>
- */
- public PageComponentInfo getPageComponentInfo()
- {
- return pageComponentInfo;
- }
-
- /**
- * @return page class
- */
- public Class<? extends IRequestablePage> getPageClass()
- {
- return pageClass;
- }
-
- /**
- * @return PageParameters instance (never <code>null</code>)
- */
- public PageParameters getPageParameters()
- {
- return pageParameters;
- }
- }
-
- /**
- * Construct.
- */
- public AbstractBookmarkableMapper()
- {
- }
-
- /**
- * Parse the given request to an {@link UrlInfo} instance.
- *
- * @param request
- * @return UrlInfo instance or <code>null</code> if this encoder can not handle the request
- */
- protected abstract UrlInfo parseRequest(Request request);
-
- /**
- * Builds URL for the given {@link UrlInfo} instance. The URL this method produces must be
- * parseable by the {@link #parseRequest(Request)} method.
- *
- * @param info
- * @return Url result URL
- */
- protected abstract Url buildUrl(UrlInfo info);
-
- /**
- * Indicates whether hybrid {@link RenderPageRequestHandler} URL for page will be generated only
- * if page has been created with bookmarkable URL.
- * <p>
- * For generic bookmarkable encoders this method should return <code>true</code>. For explicit
- * (mounted) encoders this method should return <code>false</code>
- *
- * @return <code>true</code> if hybrid URL requires page created bookmarkable,
- * <code>false</code> otherwise.
- */
- protected abstract boolean pageMustHaveBeenCreatedBookmarkable();
-
- /**
- * @see IRequestMapper#getCompatibilityScore(Request)
- */
- @Override
- public abstract int getCompatibilityScore(Request request);
-
- /**
- * Creates a {@code IRequestHandler} that processes a bookmarkable request.
- *
- * @param pageClass
- * @param pageParameters
- * @return a {@code IRequestHandler} capable of processing the bookmarkable request.
- */
- protected IRequestHandler processBookmarkable(Class<? extends IRequestablePage> pageClass,
- PageParameters pageParameters)
- {
- PageProvider provider = new PageProvider(pageClass, pageParameters);
- provider.setPageSource(getContext());
- return new RenderPageRequestHandler(provider);
- }
-
- /**
- * Creates a {@code IRequestHandler} that processes a hybrid request. When the page identified
- * by {@code pageInfo} was not available, the request should be treated as a bookmarkable
- * request.
- *
- * @param pageInfo
- * @param pageClass
- * @param pageParameters
- * @param renderCount
- * @return a {@code IRequestHandler} capable of processing the hybrid request.
- */
- protected IRequestHandler processHybrid(PageInfo pageInfo,
- Class<? extends IRequestablePage> pageClass, PageParameters pageParameters,
- Integer renderCount)
- {
- PageProvider provider = new PageProvider(pageInfo.getPageId(), pageClass, pageParameters,
- renderCount);
- provider.setPageSource(getContext());
- return new RenderPageRequestHandler(provider);
- }
-
- /**
- * Creates a {@code IRequestHandler} that processes a listener request.
- *
- * @param pageComponentInfo
- * @param pageClass
- * @param pageParameters
- * @return a {@code IRequestHandler} that invokes the listener interface
- */
- protected IRequestHandler processListener(PageComponentInfo pageComponentInfo,
- Class<? extends IRequestablePage> pageClass, PageParameters pageParameters)
- {
- PageInfo pageInfo = pageComponentInfo.getPageInfo();
- ComponentInfo componentInfo = pageComponentInfo.getComponentInfo();
- Integer renderCount = null;
- RequestListenerInterface listenerInterface = null;
-
- if (componentInfo != null)
- {
- renderCount = componentInfo.getRenderCount();
- listenerInterface = requestListenerInterfaceFromString(componentInfo.getListenerInterface());
- }
-
- if (listenerInterface != null)
- {
- PageAndComponentProvider provider = new PageAndComponentProvider(pageInfo.getPageId(),
- pageClass, pageParameters, renderCount, componentInfo.getComponentPath());
-
- provider.setPageSource(getContext());
-
- return new ListenerInterfaceRequestHandler(provider, listenerInterface,
- componentInfo.getBehaviorId());
- }
- else
- {
- if (logger.isWarnEnabled())
- {
- if (componentInfo != null)
- {
- logger.warn("Unknown listener interface '{}'",
- componentInfo.getListenerInterface());
- }
- else
- {
- logger.warn("Cannot extract the listener interface for PageComponentInfo: '{}'" +
- pageComponentInfo);
- }
- }
- return null;
- }
- }
-
- /**
- * @see org.apache.wicket.request.IRequestMapper#mapRequest(org.apache.wicket.request.Request)
- */
- @Override
- public IRequestHandler mapRequest(Request request)
- {
- UrlInfo urlInfo = parseRequest(request);
-
- // check if the URL is long enough and starts with the proper segments
- if (urlInfo != null)
- {
- PageComponentInfo info = urlInfo.getPageComponentInfo();
- Class<? extends IRequestablePage> pageClass = urlInfo.getPageClass();
- PageParameters pageParameters = urlInfo.getPageParameters();
-
- if (info == null || info.getPageInfo().getPageId() == null)
- {
- // if there are is no page instance information (only page map name - optionally)
- // then this is a simple bookmarkable URL
- return processBookmarkable(pageClass, pageParameters);
- }
- else if (info.getPageInfo().getPageId() != null && info.getComponentInfo() == null)
- {
- // if there is page instance information in the URL but no component and listener
- // interface then this is a hybrid URL - we need to try to reuse existing page
- // instance
- return processHybrid(info.getPageInfo(), pageClass, pageParameters, null);
- }
- else if (info.getComponentInfo() != null)
- {
- // with both page instance and component+listener this is a listener interface URL
- return processListener(info, pageClass, pageParameters);
- }
- }
- return null;
- }
-
- protected boolean checkPageInstance(IRequestablePage page)
- {
- return page != null && checkPageClass(page.getClass());
- }
-
- protected boolean checkPageClass(Class<? extends IRequestablePage> pageClass)
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Url mapHandler(IRequestHandler requestHandler)
- {
- // TODO see if we can refactor this to remove dependency on instanceof checks below and
- // eliminate the need for IRequestHandlerDelegate
- while (requestHandler instanceof IRequestHandlerDelegate)
- {
- requestHandler = ((IRequestHandlerDelegate)requestHandler).getDelegateHandler();
- }
-
- if (requestHandler instanceof BookmarkablePageRequestHandler)
- {
- // simple bookmarkable URL with no page instance information
- BookmarkablePageRequestHandler handler = (BookmarkablePageRequestHandler)requestHandler;
-
- if (!checkPageClass(handler.getPageClass()))
- {
- return null;
- }
-
- PageInfo info = new PageInfo();
- UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(info, null),
- handler.getPageClass(), handler.getPageParameters());
-
- return buildUrl(urlInfo);
- }
- else if (requestHandler instanceof RenderPageRequestHandler)
- {
- // possibly hybrid URL - bookmarkable URL with page instance information
- // but only allowed if the page was created by bookmarkable URL
-
- RenderPageRequestHandler handler = (RenderPageRequestHandler)requestHandler;
-
- if (!checkPageClass(handler.getPageClass()))
- {
- return null;
- }
-
- if (handler.getPageProvider().isNewPageInstance())
- {
- // no existing page instance available, don't bother creating new page instance
- PageInfo info = new PageInfo();
- UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(info, null),
- handler.getPageClass(), handler.getPageParameters());
-
- return buildUrl(urlInfo);
- }
-
- IRequestablePage page = handler.getPage();
-
- if (checkPageInstance(page) &&
- (!pageMustHaveBeenCreatedBookmarkable() || page.wasCreatedBookmarkable()))
- {
- PageInfo info = null;
- if (!page.isPageStateless())
- {
- info = new PageInfo(page.getPageId());
- }
- PageComponentInfo pageComponentInfo = info != null ? new PageComponentInfo(info,
- null) : null;
-
- UrlInfo urlInfo = new UrlInfo(pageComponentInfo, page.getClass(),
- handler.getPageParameters());
- return buildUrl(urlInfo);
- }
- else
- {
- return null;
- }
-
- }
- else if (requestHandler instanceof BookmarkableListenerInterfaceRequestHandler)
- {
- // listener interface URL with page class information
- BookmarkableListenerInterfaceRequestHandler handler = (BookmarkableListenerInterfaceRequestHandler)requestHandler;
- Class<? extends IRequestablePage> pageClass = handler.getPageClass();
-
- if (!checkPageClass(pageClass))
- {
- return null;
- }
-
- Integer renderCount = null;
- if (handler.getListenerInterface().isIncludeRenderCount())
- {
- renderCount = handler.getRenderCount();
- }
-
- PageInfo pageInfo = new PageInfo(handler.getPageId());
- ComponentInfo componentInfo = new ComponentInfo(renderCount,
- requestListenerInterfaceToString(handler.getListenerInterface()),
- handler.getComponentPath(), handler.getBehaviorIndex());
-
- UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(pageInfo, componentInfo),
- pageClass, handler.getPageParameters());
- return buildUrl(urlInfo);
- }
-
- return null;
- }
-}