You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pa...@apache.org on 2013/11/18 20:37:29 UTC
[14/14] git commit: Use specified,
protable conversation propagation via cid parameter
Use specified, protable conversation propagation via cid parameter
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/0de87fdc
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/0de87fdc
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/0de87fdc
Branch: refs/heads/wicket-cdi-1.1-rewrite
Commit: 0de87fdceec43cb45a4f2b0549565fd3f5ff96bf
Parents: 6564bc9
Author: Emond Papegaaij <em...@topicus.nl>
Authored: Mon Nov 18 20:35:28 2013 +0100
Committer: Emond Papegaaij <em...@topicus.nl>
Committed: Mon Nov 18 20:36:21 2013 +0100
----------------------------------------------------------------------
wicket-experimental/wicket-cdi-1.1/pom.xml | 2 -
.../apache/wicket/cdi/AbstractCdiContainer.java | 139 -------------
.../org/apache/wicket/cdi/AutoConversation.java | 2 +
.../org/apache/wicket/cdi/CdiConfiguration.java | 28 ++-
.../cdi/ConversationExpiredException.java | 1 +
.../wicket/cdi/ConversationExpiryChecker.java | 8 +-
.../wicket/cdi/ConversationIdMetaKey.java | 24 ---
.../wicket/cdi/ConversationPropagation.java | 35 ++--
.../wicket/cdi/ConversationPropagator.java | 207 ++++---------------
.../apache/wicket/cdi/DetachEventEmitter.java | 4 +-
.../wicket/cdi/IConversationPropagation.java | 13 --
.../apache/wicket/cdi/CdiConfigurationTest.java | 4 +-
.../org/apache/wicket/cdi/MockCdiContainer.java | 77 -------
.../apache/wicket/cdi/WicketCdiTestCase.java | 8 +-
.../wicket/cdi/testapp/TestApplication.java | 3 -
.../wicket/cdi/testapp/TestCdiApplication.java | 3 +-
.../cdi/testapp/TestConversationalPage.html | 2 +-
.../testapp/TestNonAutoConversationalPage.html | 2 +-
.../cdi/testapp/TestNonConversationalPage.html | 2 +-
.../wicket/cdi/util/tester/CdiWicketTester.java | 27 ++-
.../wicket-cdi-1.1/wicket-cdi-1.1-weld/pom.xml | 88 --------
.../wicket/cdi/weld/WeldCdiContainer.java | 68 ------
.../src/main/resources/META-INF/beans.xml | 0
.../cdi/weld/ApacheLicenceHeaderTest.java | 41 ----
24 files changed, 116 insertions(+), 672 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/pom.xml b/wicket-experimental/wicket-cdi-1.1/pom.xml
index 7344e1c..ae75c0d 100644
--- a/wicket-experimental/wicket-cdi-1.1/pom.xml
+++ b/wicket-experimental/wicket-cdi-1.1/pom.xml
@@ -30,7 +30,5 @@
<description>Wicket CDI 1.1 Parent.</description>
<modules>
<module>wicket-cdi-1.1-core</module>
- <module>wicket-cdi-1.1-weld</module>
- <!--<module>wicket-cdi-1.1-owb</module>-->
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AbstractCdiContainer.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AbstractCdiContainer.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AbstractCdiContainer.java
deleted file mode 100644
index 7df6553..0000000
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AbstractCdiContainer.java
+++ /dev/null
@@ -1,139 +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.cdi;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.MetaDataKey;
-import org.apache.wicket.Page;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.util.lang.Args;
-
-/**
- * Provides access to CDI features from inside a Wicket request
- *
- * @author igor
- */
-public abstract class AbstractCdiContainer
-{
- private static MetaDataKey<AbstractCdiContainer> CONTEXT_KEY = new MetaDataKey<AbstractCdiContainer>()
- {
- private static final long serialVersionUID = 1L;
- };
-
- /**
- * Constructor
- */
- public AbstractCdiContainer()
- {
- }
-
- /**
- * Deactivates conversational context
- *
- * @param cycle
- */
- public abstract void deactivateConversationalContext(RequestCycle cycle);
-
- /**
- * Activates the conversational context and starts the conversation with the
- * specified cid
- *
- * @param cycle
- * @param cid
- */
- public abstract void activateConversationalContext(RequestCycle cycle, String cid);
-
- protected HttpServletRequest getRequest(RequestCycle cycle)
- {
- return (HttpServletRequest)cycle.getRequest().getContainerRequest();
- }
-
- /**
- * Retrieves a conversation id, if any, that is associated with a
- * {@link Page} instance
- *
- * @param page
- * page instance
- * @return conversation id, if any
- */
- public String getConversationMarker(Page page)
- {
- return page.getMetaData(ConversationIdMetaKey.INSTANCE);
- }
-
- /**
- * Removes conversation marker from the page instance which prevents the
- * conversation from propagating to the page. This method should usually be
- * called from page's {@code onDetach()} method.
- *
- * @param page
- */
- public void removeConversationMarker(Page page)
- {
- Args.notNull(page, "page");
-
- page.setMetaData(ConversationIdMetaKey.INSTANCE, null);
- page.getPageParameters().remove(ConversationPropagator.CID);
- }
-
- /**
- * Binds this container instance to the {@link Application}, making it
- * possible to retrieve it later
- *
- * @param application
- */
- protected void bind(Application application)
- {
- if (application.getMetaData(CONTEXT_KEY) != null)
- {
- throw new IllegalStateException("A CDI container is already bound to this "
- + "application, which probably means you tried to configure the "
- + "application twice");
- }
- application.setMetaData(CONTEXT_KEY, this);
- }
-
- /**
- * Retrieves container instance stored in the application
- *
- * @param application
- * @return container instance or {@code null} if none
- */
- public static AbstractCdiContainer get(Application application)
- {
- AbstractCdiContainer ctx = application.getMetaData(CONTEXT_KEY);
- if (ctx == null)
- {
- throw new IllegalStateException("No CDI Context bound to application");
- }
- return ctx;
- }
-
- /**
- * Retrieves container instance stored in the current thread's application
- *
- * @return container instance or {@code null} if none
- */
- public static AbstractCdiContainer get()
- {
- return get(Application.get());
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AutoConversation.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AutoConversation.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AutoConversation.java
index 0193a7d..6138ac2 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AutoConversation.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/AutoConversation.java
@@ -30,6 +30,8 @@ import org.apache.wicket.util.io.IClusterable;
@ConversationScoped
public class AutoConversation implements IClusterable
{
+ private static final long serialVersionUID = 1L;
+
private boolean automatic;
public AutoConversation()
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
index 9b6b4b3..3ac4abf 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
@@ -17,6 +17,7 @@
package org.apache.wicket.cdi;
import org.apache.wicket.Application;
+import org.apache.wicket.MetaDataKey;
import org.apache.wicket.request.cycle.RequestCycleListenerCollection;
/**
@@ -27,7 +28,12 @@ import org.apache.wicket.request.cycle.RequestCycleListenerCollection;
*/
public class CdiConfiguration
{
- private IConversationPropagation propagation = ConversationPropagation.NONBOOKMARKABLE;
+ private static final MetaDataKey<CdiConfiguration> CDI_CONFIGURATION_KEY = new MetaDataKey<CdiConfiguration>()
+ {
+ private static final long serialVersionUID = 1L;
+ };
+
+ private IConversationPropagation propagation = ConversationPropagation.ALL;
private boolean injectComponents = true;
private boolean injectApplication = true;
@@ -136,9 +142,13 @@ public class CdiConfiguration
* @param application
* @return
*/
- public AbstractCdiContainer configure(Application application, AbstractCdiContainer container)
+ public void configure(Application application)
{
- container.bind(application);
+ if (application.getMetaData(CDI_CONFIGURATION_KEY) != null)
+ {
+ throw new IllegalStateException("Cdi already configured for this application");
+ }
+ application.setMetaData(CDI_CONFIGURATION_KEY, this);
RequestCycleListenerCollection listeners = new RequestCycleListenerCollection();
application.getRequestCycleListeners().add(listeners);
@@ -146,14 +156,14 @@ public class CdiConfiguration
// enable conversation propagation
if (getPropagation() != ConversationPropagation.NONE)
{
- listeners.add(new ConversationPropagator(application, container, getPropagation(),
+ listeners.add(new ConversationPropagator(application, getPropagation(),
autoConversationManagement));
application.getComponentPreOnBeforeRenderListeners().add(
- new ConversationExpiryChecker(container));
+ new ConversationExpiryChecker());
}
// enable detach event
- listeners.add(new DetachEventEmitter(container));
+ listeners.add(new DetachEventEmitter());
// inject application instance
@@ -182,8 +192,10 @@ public class CdiConfiguration
// enable cleanup
application.getApplicationListeners().add(new CdiShutdownCleaner(isInjectApplication()));
-
- return container;
}
+ public static CdiConfiguration get(Application application)
+ {
+ return application.getMetaData(CDI_CONFIGURATION_KEY);
+ }
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
index 7993ae4..a9c7eb1 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
@@ -21,6 +21,7 @@ import org.apache.wicket.request.IRequestHandler;
public class ConversationExpiredException extends RuntimeException
{
+ private static final long serialVersionUID = 1L;
private String cid;
private Page page;
private IRequestHandler handler;
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
index 394ad29..e79f938 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
@@ -45,12 +45,8 @@ public class ConversationExpiryChecker implements IComponentOnBeforeRenderListen
@Inject
private Conversation conversation;
- private final AbstractCdiContainer container;
-
- public ConversationExpiryChecker(AbstractCdiContainer container)
+ public ConversationExpiryChecker()
{
- this.container = container;
-
NonContextual.of(ConversationExpiryChecker.class).inject(this);
}
@@ -60,7 +56,7 @@ public class ConversationExpiryChecker implements IComponentOnBeforeRenderListen
if (component instanceof Page || RequestCycle.get().find(AjaxRequestTarget.class) != null)
{
Page page = component.getPage();
- String cid = container.getConversationMarker(page);
+ String cid = ConversationPropagator.getConversationIdFromPage(page);
if (cid != null && !Objects.isEqual(conversation.getId(), cid))
{
logger.info("Conversation {} has expired for {}", cid, page);
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationIdMetaKey.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationIdMetaKey.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationIdMetaKey.java
deleted file mode 100644
index 94cc70f..0000000
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationIdMetaKey.java
+++ /dev/null
@@ -1,24 +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.cdi;
-
-import org.apache.wicket.MetaDataKey;
-
-final class ConversationIdMetaKey extends MetaDataKey<String>
-{
- static final ConversationIdMetaKey INSTANCE = new ConversationIdMetaKey();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
index e70ff9c..502b6e5 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
@@ -18,7 +18,8 @@ package org.apache.wicket.cdi;
import javax.enterprise.context.ConversationScoped;
-import org.apache.wicket.Page;
+import org.apache.wicket.core.request.handler.BookmarkableListenerInterfaceRequestHandler;
+import org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler;
import org.apache.wicket.request.IRequestHandler;
/**
@@ -32,44 +33,34 @@ public enum ConversationPropagation implements IConversationPropagation {
/** No conversational propagation takes place */
NONE {
@Override
- public boolean propagatesViaPage(Page page, IRequestHandler handler)
- {
- return false;
- }
-
- @Override
public boolean propagatesViaParameters(IRequestHandler handler)
{
return false;
}
},
/**
- * Pesistent conversations are propagated between non-bookmarkable pages only
+ * Pesistent conversations are propagated between non-bookmarkable pages
+ * only
+ *
+ * @deprecated as of cdi-1.1, it is specified that conversations are
+ * propagated via the cid query parameter even for
+ * non-bookmarkable pages
*/
+ @Deprecated
NONBOOKMARKABLE {
@Override
- public boolean propagatesViaPage(Page page, IRequestHandler handler)
- {
- return true;
- }
-
- @Override
public boolean propagatesViaParameters(IRequestHandler handler)
{
- return false;
+ return !(handler instanceof BookmarkableListenerInterfaceRequestHandler)
+ && !(handler instanceof BookmarkablePageRequestHandler);
}
},
/**
- * Persistent conversations are propagated between bookmarkable and non-bookmarkable pages
+ * Persistent conversations are propagated between bookmarkable and
+ * non-bookmarkable pages
*/
ALL {
@Override
- public boolean propagatesViaPage(Page page, IRequestHandler handler)
- {
- return true;
- }
-
- @Override
public boolean propagatesViaParameters(IRequestHandler handler)
{
return true;
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
index 60f46a6..2f43931 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
@@ -18,7 +18,6 @@ package org.apache.wicket.cdi;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
-import javax.enterprise.context.NonexistentConversationException;
import javax.inject.Inject;
import org.apache.wicket.Application;
@@ -28,11 +27,9 @@ import org.apache.wicket.Page;
import org.apache.wicket.core.request.handler.BufferedResponseRequestHandler;
import org.apache.wicket.core.request.handler.IPageClassRequestHandler;
import org.apache.wicket.core.request.handler.IPageRequestHandler;
-import org.apache.wicket.core.request.mapper.StalePageException;
import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.IRequestHandlerDelegate;
import org.apache.wicket.request.Url;
-import org.apache.wicket.request.component.IRequestablePage;
import org.apache.wicket.request.cycle.AbstractRequestCycleListener;
import org.apache.wicket.request.cycle.IRequestCycleListener;
import org.apache.wicket.request.cycle.RequestCycle;
@@ -40,7 +37,6 @@ import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandle
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.PackageResourceReference;
import org.apache.wicket.util.lang.Args;
-import org.apache.wicket.util.lang.Objects;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor;
import org.apache.wicket.util.visit.Visits;
@@ -59,17 +55,18 @@ public class ConversationPropagator extends AbstractRequestCycleListener
{
private static final Logger logger = LoggerFactory.getLogger(ConversationPropagator.class);
- private static final MetaDataKey<String> CID_KEY = ConversationIdMetaKey.INSTANCE;
-
private static final MetaDataKey<Boolean> CONVERSATION_STARTED_KEY = new MetaDataKey<Boolean>()
{
+ private static final long serialVersionUID = 1L;
};
+ private static final MetaDataKey<String> CONVERSATION_ID_KEY = new MetaDataKey<String>()
+ {
+ private static final long serialVersionUID = 1L;
+ };
public static final String CID = "cid";
- private final AbstractCdiContainer container;
-
/** propagation mode to use */
private final IConversationPropagation propagation;
@@ -78,10 +75,10 @@ public class ConversationPropagator extends AbstractRequestCycleListener
private final boolean auto;
@Inject
- Conversation conversation_;
+ private Conversation conversation;
@Inject
- AutoConversation autoConversation;
+ private AutoConversation autoConversation;
/**
* Constructor
@@ -89,24 +86,21 @@ public class ConversationPropagator extends AbstractRequestCycleListener
* @param container
* @param propagation
*/
- public ConversationPropagator(Application application, AbstractCdiContainer container,
- IConversationPropagation propagation)
+ public ConversationPropagator(Application application, IConversationPropagation propagation)
{
- this(application, container, propagation, false);
+ this(application, propagation, false);
}
-
/**
* Constructor
*
* @param container
* @param propagation
*/
- public ConversationPropagator(Application application, AbstractCdiContainer container,
- IConversationPropagation propagation, boolean auto)
+ public ConversationPropagator(Application application, IConversationPropagation propagation,
+ boolean auto)
{
Args.notNull(application, "application");
- Args.notNull(container, "container");
Args.notNull(propagation, "propagation");
if (propagation == ConversationPropagation.NONE)
@@ -116,103 +110,30 @@ public class ConversationPropagator extends AbstractRequestCycleListener
}
this.application = application;
- this.container = container;
this.propagation = propagation;
this.auto = auto;
NonContextual.of(ConversationPropagator.class).postConstruct(this);
}
-
- private Conversation getConversation(RequestCycle cycle)
+
+ public IConversationPropagation getPropagation()
{
- return Boolean.TRUE.equals(cycle.getMetaData(CONVERSATION_STARTED_KEY))
- ? conversation_
- : null;
+ return propagation;
}
@Override
public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler)
{
- String cid = cycle.getRequest().getRequestParameters().getParameterValue(CID).toString();
- Page page = getPage(handler);
-
- if (cid == null && page != null)
- {
- cid = page.getMetaData(CID_KEY);
- }
-
- Conversation current = getConversation(cycle);
- if (current != null && !Objects.isEqual(current.getId(), cid))
+ if (activateForHandler(handler))
{
- logger.info("Conversation {} has expired for {}", cid, page);
- throw new ConversationExpiredException(null, cid, page, handler);
- }
-
- activateConversationIfNeeded(cycle, handler, cid);
- }
-
- @Override
- public IRequestHandler onException(RequestCycle cycle, Exception ex)
- {
- // if we are handling a stale page exception then use its conversation
- // since we are most
- // likely about to rerender it.
-
- if (ex instanceof StalePageException)
- {
- IRequestablePage requestable = ((StalePageException)ex).getPage();
- if (requestable instanceof Page)
- {
- String cid = container.getConversationMarker((Page)requestable);
- if (cid != null)
- {
- try
- {
- activateConversationIfNeeded(cycle, null, cid);
- return null;
- }
- catch (ConversationExpiredException e)
- {
- // ignore, we will start a new one below
- }
- }
- }
- }
-
- activateConversationIfNeeded(cycle, null, null);
- return null;
- }
-
- private void activateConversationIfNeeded(RequestCycle cycle, IRequestHandler handler,
- String cid)
- {
- Conversation current = getConversation(cycle);
-
- if (current != null || !activateForHandler(handler))
- {
- return;
- }
-
- logger.debug("Activating conversation {}", cid);
-
- try
- {
- container.activateConversationalContext(cycle, cid);
- fireOnAfterConversationStarted(cycle);
- }
- catch (NonexistentConversationException e)
- {
- logger.info("Unable to restore conversation with id {}", cid, e.getMessage());
- logger.debug("Unable to restore conversation", e);
+ logger.debug("Activating conversation {}", conversation.getId());
fireOnAfterConversationStarted(cycle);
- throw new ConversationExpiredException(e, cid, getPage(handler), handler);
}
-
- cycle.setMetaData(CONVERSATION_STARTED_KEY, true);
}
private void fireOnAfterConversationStarted(RequestCycle cycle)
{
+ cycle.setMetaData(CONVERSATION_STARTED_KEY, true);
for (IRequestCycleListener listener : application.getRequestCycleListeners())
{
if (listener instanceof ICdiAwareRequestCycleListener)
@@ -225,13 +146,6 @@ public class ConversationPropagator extends AbstractRequestCycleListener
@Override
public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler)
{
- Conversation conversation = getConversation(cycle);
-
- if (conversation == null)
- {
- return;
- }
-
Page page = getPage(handler);
if (page == null)
@@ -243,12 +157,6 @@ public class ConversationPropagator extends AbstractRequestCycleListener
autoEndIfNecessary(page, handler, conversation);
autoBeginIfNecessary(page, handler, conversation);
-
- if (propagation.propagatesViaPage(page, handler))
- {
- // propagate a conversation across non-bookmarkable page instances
- setConversationOnPage(conversation, page);
- }
}
@Override
@@ -256,29 +164,13 @@ public class ConversationPropagator extends AbstractRequestCycleListener
{
// propagate current non-transient conversation to the newly scheduled
// page
-
- Conversation conversation = getConversation(cycle);
-
- if (conversation == null || conversation.isTransient())
+ if (conversation.isTransient())
{
return;
}
- Page page = getPage(handler);
- if (page != null)
- {
- if (propagation.propagatesViaPage(page, handler))
- {
- // propagate a conversation across non-bookmarkable page
- // instances
- setConversationOnPage(conversation, page);
- }
- }
-
if (propagation.propagatesViaParameters(handler))
{
- // propagate cid to a scheduled bookmarkable page
-
logger.debug(
"Propagating non-transient conversation {} via page parameters of handler {}",
conversation.getId(), handler);
@@ -287,28 +179,11 @@ public class ConversationPropagator extends AbstractRequestCycleListener
if (parameters != null)
{
parameters.set(CID, conversation.getId());
+ markPageWithConversationId(handler, conversation.getId());
}
}
}
- protected void setConversationOnPage(Conversation conversation, Page page)
- {
- if (conversation == null || conversation.isTransient())
- {
- logger.debug("Detaching transient conversation {} via meta of page instance {}",
- (conversation == null ? "null" : conversation.getId()), page);
-
- page.setMetaData(CID_KEY, null);
- }
- else
- {
-
- logger.debug("Propagating non-transient conversation {} via meta of page instance {}",
- conversation.getId(), page);
-
- page.setMetaData(CID_KEY, conversation.getId());
- }
- }
@Override
public void onUrlMapped(RequestCycle cycle, IRequestHandler handler, Url url)
@@ -323,42 +198,34 @@ public class ConversationPropagator extends AbstractRequestCycleListener
}
}
- Conversation conversation = getConversation(cycle);
-
- if (conversation == null || conversation.isTransient())
+ if (conversation.isTransient())
{
return;
}
if (propagation.propagatesViaParameters(handler))
{
- // propagate cid to bookmarkable pages via urls
-
logger.debug("Propagating non-transient conversation {} via url", conversation.getId());
-
url.setQueryParameter(CID, conversation.getId());
+ markPageWithConversationId(handler, conversation.getId());
}
}
@Override
public void onDetach(RequestCycle cycle)
{
- Conversation conversation = getConversation(cycle);
- if (conversation != null)
+ if (!Boolean.TRUE.equals(cycle.getMetaData(CONVERSATION_STARTED_KEY)))
{
- logger.debug("Deactivating conversation {}", conversation.getId());
+ return;
+ }
- for (IRequestCycleListener listener : application.getRequestCycleListeners())
+ logger.debug("Deactivating conversation {}", conversation.getId());
+ for (IRequestCycleListener listener : application.getRequestCycleListeners())
+ {
+ if (listener instanceof ICdiAwareRequestCycleListener)
{
- if (listener instanceof ICdiAwareRequestCycleListener)
- {
- ((ICdiAwareRequestCycleListener)listener)
- .onBeforeConversationDeactivated(cycle);
- }
+ ((ICdiAwareRequestCycleListener)listener).onBeforeConversationDeactivated(cycle);
}
- container.deactivateConversationalContext(cycle);
-
- cycle.setMetaData(CONVERSATION_STARTED_KEY, null);
}
}
@@ -389,7 +256,6 @@ public class ConversationPropagator extends AbstractRequestCycleListener
Conversation conversation)
{
if (!auto || conversation == null || !conversation.isTransient() || page == null
- || !propagation.propagatesViaPage(page, handler)
|| !hasConversationalComponent(page))
{
return;
@@ -406,7 +272,6 @@ public class ConversationPropagator extends AbstractRequestCycleListener
protected void autoEndIfNecessary(Page page, IRequestHandler handler, Conversation conversation)
{
if (!auto || conversation == null || conversation.isTransient() || page == null
- || !propagation.propagatesViaPage(page, handler)
|| hasConversationalComponent(page) || autoConversation.isAutomatic() == false)
{
return;
@@ -440,6 +305,20 @@ public class ConversationPropagator extends AbstractRequestCycleListener
return hasConversational == null ? false : hasConversational;
}
+ public static void markPageWithConversationId(IRequestHandler handler, String cid)
+ {
+ Page page = getPage(handler);
+ if (page != null)
+ {
+ page.setMetaData(CONVERSATION_ID_KEY, cid);
+ }
+ }
+
+ public static String getConversationIdFromPage(Page page)
+ {
+ return page.getMetaData(CONVERSATION_ID_KEY);
+ }
+
/**
* Resolves a page instance from the request handler iff the page instance
* is already created
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
index 2de1d76..601b155 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
@@ -23,7 +23,6 @@ import org.apache.wicket.MetaDataKey;
import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.cycle.AbstractRequestCycleListener;
import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.util.lang.Args;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,6 +38,7 @@ public class DetachEventEmitter extends AbstractRequestCycleListener
private static final MetaDataKey<Boolean> DETACH_SCHEDULED_KEY = new MetaDataKey<Boolean>()
{
+ private static final long serialVersionUID = 1L;
};
@Inject
@@ -47,7 +47,7 @@ public class DetachEventEmitter extends AbstractRequestCycleListener
/**
* Constructor
*/
- public DetachEventEmitter(AbstractCdiContainer container)
+ public DetachEventEmitter()
{
NonContextual.of(DetachEventEmitter.class).postConstruct(this);
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
index 154b077..09e39a9 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
@@ -16,7 +16,6 @@
*/
package org.apache.wicket.cdi;
-import org.apache.wicket.Page;
import org.apache.wicket.request.IRequestHandler;
/**
@@ -28,18 +27,6 @@ import org.apache.wicket.request.IRequestHandler;
public interface IConversationPropagation
{
/**
- * Indicates if the conversation should be propagated via page metadata (on an instance) for the
- * given page and request handler.
- *
- * @param page
- * The page on which the tag will be set.
- * @param handler
- * The current request handler
- * @return true if the conversation should be propagated to the given page instance.
- */
- public boolean propagatesViaPage(Page page, IRequestHandler handler);
-
- /**
* Indicates if the conversation should be propagated via url-parameters for the given request
* handler. This can either be a get parameter in a rendered url, or via page parameters.
*
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
index 9d10e62..0c30f70 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
@@ -50,7 +50,7 @@ public class CdiConfigurationTest extends WicketCdiTestCase
public void testConfigureTwice()
{
configure(new CdiConfiguration());
- new CdiConfiguration().configure(tester.getApplication(), new MockCdiContainer());
+ new CdiConfiguration().configure(tester.getApplication());
}
@Test
@@ -83,6 +83,6 @@ public class CdiConfigurationTest extends WicketCdiTestCase
config.setPropagation(cp);
assertEquals(cp, config.getPropagation());
}
- config.configure(tester.getApplication(), new MockCdiContainer());
+ config.configure(tester.getApplication());
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/MockCdiContainer.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/MockCdiContainer.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/MockCdiContainer.java
deleted file mode 100644
index 9b7fc48..0000000
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/MockCdiContainer.java
+++ /dev/null
@@ -1,77 +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.cdi;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.jboss.weld.context.http.HttpConversationContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author jsarman
- */
-@ApplicationScoped
-public class MockCdiContainer extends AbstractCdiContainer
-{
- private static final Logger logger = LoggerFactory.getLogger(MockCdiContainer.class);
-
- @Inject
- private HttpConversationContext conversationContext;
-
- public MockCdiContainer()
- {
- NonContextual.of(MockCdiContainer.class).inject(this);
- }
-
- /**
- * Activates the conversational context and starts the conversation with the
- * specified cid
- *
- * @param cycle
- * @param cid
- */
- @Override
- public void activateConversationalContext(RequestCycle cycle, String cid)
- {
- conversationContext.associate(getRequest(cycle));
- if (conversationContext.isActive())
- {
- conversationContext.invalidate();
- conversationContext.deactivate();
- conversationContext.activate(cid);
- } else
- {
- conversationContext.activate(cid);
- }
- }
-
- @Override
- public void deactivateConversationalContext(RequestCycle cycle)
- {
- // try
- // {
- // conversationContext.deactivate();
- // }
- // finally
- // {
- // conversationContext.dissociate(getRequest(cycle));
- // }
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
index 3bc9c87..ef862c6 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
@@ -16,7 +16,6 @@
*/
package org.apache.wicket.cdi;
-import javax.enterprise.context.Conversation;
import javax.inject.Inject;
import org.apache.wicket.WicketTestCase;
@@ -39,13 +38,12 @@ import org.junit.runner.RunWith;
@AdditionalClasses({ CdiWicketTester.class, BehaviorInjector.class, CdiConfiguration.class,
CdiShutdownCleaner.class, ComponentInjector.class, ConversationExpiryChecker.class,
ConversationPropagator.class, DetachEventEmitter.class, SessionInjector.class,
- MockCdiContainer.class, TestAppScope.class, TestConversationBean.class,
- TestCdiApplication.class })
+ TestAppScope.class, TestConversationBean.class, TestCdiApplication.class })
public abstract class WicketCdiTestCase extends WicketTestCase
{
@Inject
private ContextManager contextManager;
-
+
@Override
protected WicketTester newWicketTester(WebApplication app)
{
@@ -54,7 +52,7 @@ public abstract class WicketCdiTestCase extends WicketTestCase
public void configure(CdiConfiguration configuration)
{
- configuration.configure(tester.getApplication(), new MockCdiContainer());
+ configuration.configure(tester.getApplication());
}
@After
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
index 14a85a4..7b82203 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
@@ -17,9 +17,6 @@
package org.apache.wicket.cdi.testapp;
import org.apache.wicket.Page;
-import org.apache.wicket.cdi.CdiConfiguration;
-import org.apache.wicket.cdi.ConversationPropagation;
-import org.apache.wicket.cdi.MockCdiContainer;
import org.apache.wicket.protocol.http.WebApplication;
/**
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
index 6ea1916..1bd8656 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
@@ -20,7 +20,6 @@ import javax.inject.Inject;
import org.apache.wicket.Page;
import org.apache.wicket.cdi.CdiConfiguration;
-import org.apache.wicket.cdi.MockCdiContainer;
import org.apache.wicket.protocol.http.WebApplication;
/**
@@ -44,7 +43,7 @@ public class TestCdiApplication extends WebApplication
protected void init()
{
super.init();
- new CdiConfiguration().configure(this, new MockCdiContainer());
+ new CdiConfiguration().configure(this);
}
public String getInjectedTestString()
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
index dfd545d..b3550f1 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html>
+<html xmlns:wicket>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.html
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.html b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.html
index dfd545d..b3550f1 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.html
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html>
+<html xmlns:wicket>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
index 9857fca..fd58f2d 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html>
+<html xmlns:wicket>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java
index 4052110..8efd59b 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java
@@ -21,10 +21,14 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
+import org.apache.wicket.Page;
+import org.apache.wicket.cdi.CdiConfiguration;
+import org.apache.wicket.cdi.ConversationPropagator;
import org.apache.wicket.cdi.NonContextual;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.mock.MockHttpServletRequest;
import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.request.Url;
import org.apache.wicket.util.tester.WicketTester;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,7 +39,7 @@ import org.slf4j.LoggerFactory;
public class CdiWicketTester extends WicketTester
{
private static final Logger logger = LoggerFactory.getLogger(CdiWicketTester.class);
-
+
@Inject
ContextManager contextManager;
@@ -46,7 +50,7 @@ public class CdiWicketTester extends WicketTester
super(app);
NonContextual.of(CdiWicketTester.class).inject(this);
}
-
+
/**
* Process the request by first activating the contexts on initial call.
* This call is called recursively in the super class so keep track of the
@@ -69,7 +73,7 @@ public class CdiWicketTester extends WicketTester
{
contextManager.deactivateContexts();
}
- contextManager.activateContexts(getRequest());
+ contextManager.activateContexts(forcedRequest == null ? getRequest() : forcedRequest);
}
try
{
@@ -81,6 +85,23 @@ public class CdiWicketTester extends WicketTester
}
}
+ @Override
+ public Url urlFor(IRequestHandler handler)
+ {
+ Url ret = super.urlFor(handler);
+ final CdiConfiguration configuration = CdiConfiguration.get(getApplication());
+ if (configuration.getPropagation().propagatesViaParameters(handler))
+ {
+ Page page = ConversationPropagator.getPage(handler);
+ if (page != null)
+ {
+ String cid = ConversationPropagator.getConversationIdFromPage(page);
+ ret.addQueryParameter(ConversationPropagator.CID, cid);
+ }
+ }
+ return ret;
+ }
+
@PreDestroy
public void finish()
{
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/pom.xml b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/pom.xml
deleted file mode 100644
index 98f8b3f..0000000
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/pom.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-cdi-1.1</artifactId>
- <version>0.2-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>wicket-cdi-1.1-weld</artifactId>
- <packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
- <name>Wicket CDI 1.1 Weld</name>
- <description>
- Provides integration between Wicket and CDI containers. Adds support for weld
- based containers.
- </description>
- <dependencies>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-cdi-1.1-core</artifactId>
- <version>0.2-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-api</artifactId>
- <version>2.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>javax.el-api</artifactId>
- <version>2.2.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>clirr-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>clirr-check</id>
- <phase>compile</phase>
- <goals>
- <goal>check</goal>
- </goals>
- <configuration>
- <comparisonVersion>6.1.0</comparisonVersion>
- <failOnError>true</failOnError>
- <logResults>true</logResults>
- </configuration>
- </execution>
- </executions>
- <configuration>
- <comparisonVersion>6.1.0</comparisonVersion>
- <failOnError>true</failOnError>
- <logResults>true</logResults>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java
deleted file mode 100644
index 4dcbdb9..0000000
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java
+++ /dev/null
@@ -1,68 +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.cdi.weld;
-
-import javax.inject.Inject;
-
-import org.apache.wicket.cdi.AbstractCdiContainer;
-import org.apache.wicket.cdi.NonContextual;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.jboss.weld.context.http.HttpConversationContext;
-
-/**
- * Provides access to CDI features from inside a Wicket request
- *
- * @author jsarman
- */
-public class WeldCdiContainer extends AbstractCdiContainer
-{
- @Inject
- private HttpConversationContext conversationContext;
-
- public WeldCdiContainer()
- {
- NonContextual.of(WeldCdiContainer.class).inject(this);
- }
-
- /**
- * Activates the conversational context and starts the conversation with the
- * specified cid
- *
- * @param cycle
- * @param cid
- */
- @Override
- public void activateConversationalContext(RequestCycle cycle, String cid)
- {
- conversationContext.associate(getRequest(cycle));
- if (conversationContext.isActive())
- {
- conversationContext.invalidate();
- conversationContext.deactivate();
- conversationContext.activate(cid);
- }
- else
- {
- conversationContext.activate(cid);
- }
- }
-
- @Override
- public void deactivateConversationalContext(RequestCycle cycle)
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/resources/META-INF/beans.xml b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/resources/META-INF/beans.xml
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/wicket/blob/0de87fdc/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/test/java/org/apache/wicket/cdi/weld/ApacheLicenceHeaderTest.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/test/java/org/apache/wicket/cdi/weld/ApacheLicenceHeaderTest.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/test/java/org/apache/wicket/cdi/weld/ApacheLicenceHeaderTest.java
deleted file mode 100644
index d2761ba..0000000
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/test/java/org/apache/wicket/cdi/weld/ApacheLicenceHeaderTest.java
+++ /dev/null
@@ -1,41 +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.cdi.weld;
-
-import java.util.Arrays;
-
-import org.apache.wicket.util.license.ApacheLicenseHeaderTestCase;
-
-/**
- * Test that the license headers are in place in this project. The tests are run
- * from {@link ApacheLicenseHeaderTestCase}, but you can add project specific
- * tests here if needed.
- *
- * @author Frank Bille Jensen (frankbille)
- */
-public class ApacheLicenceHeaderTest extends ApacheLicenseHeaderTestCase
-{
- /**
- * Construct.
- */
- public ApacheLicenceHeaderTest()
- {
- xmlIgnore.add(".settings");
- xmlIgnore.add("src/main/resources/META-INF/beans.xml");
- xmlPrologIgnore = Arrays.asList("src");
- }
-}