You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2018/09/24 20:09:37 UTC
[1/3] wicket git commit: WICKET-6581 Module wicket-cdi-1.1 migrated
to CDI 2 and name changed to wicket-cdi. Solved dependecy problems with weld
versions.
Repository: wicket
Updated Branches:
refs/heads/master 056d726a5 -> 057c402b4
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java
index e041a87..16d9fc1 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java
@@ -17,14 +17,14 @@
package org.apache.wicket.cdi;
/**
- * Marks a component that requires a conversation. This marker is used by the automatic conversation
- * management feature ({@link CdiConfiguration#setAutoConversationManagement(boolean)}) to
- * automatically begin and end conversations based on the presence of these components in the
- * component hierarchy of pages (can be applied to the page itself).
+ * Marks a component that requires a conversation. This marker is used by the
+ * automatic conversation management feature to
+ * automatically begin and end conversations based on the presence of these
+ * components in the component hierarchy of pages (can be applied to the page
+ * itself).
*
* @author igor
*/
public interface ConversationalComponent
{
-
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
index 3ac27fa..b141236 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
+++ b/wicket-cdi/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.IRequestCycleListener;
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 implements IRequestCycleListener
private static final MetaDataKey<Boolean> DETACH_SCHEDULED_KEY = new MetaDataKey<Boolean>()
{
+ private static final long serialVersionUID = 1L;
};
@Inject
@@ -46,13 +46,10 @@ public class DetachEventEmitter implements IRequestCycleListener
/**
* Constructor
- *
- * @param container
*/
- public DetachEventEmitter(CdiContainer container)
+ public DetachEventEmitter()
{
- Args.notNull(container, "container");
- container.getNonContextualManager().postConstruct(this);
+ NonContextual.of(DetachEventEmitter.class).postConstruct(this);
}
@Override
@@ -71,7 +68,7 @@ public class DetachEventEmitter implements IRequestCycleListener
logger.debug("Firing Detach event {}", cycle.getRequest().getUrl());
detachEvent.fire(new DetachEvent());
-
+
cycle.setMetaData(DETACH_SCHEDULED_KEY, null);
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
index f2086a8..b9eb1e3 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
@@ -17,35 +17,31 @@
package org.apache.wicket.cdi;
import org.apache.wicket.Page;
+import org.apache.wicket.core.request.handler.IPageRequestHandler;
import org.apache.wicket.request.IRequestHandler;
/**
- * A strategy that specifies how conversations should be propagated between pages/resources.
- * {@link ConversationPropagation} provides sensible default implementations of this interface.
+ * A strategy that specifies how conversations should be propagated between
+ * pages/resources. {@link ConversationPropagation} provides sensible default
+ * implementations of this interface.
*
* @author papegaaij
*/
+@FunctionalInterface
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.
- */
- 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.
+ * Indicates if the conversation should be propagated via url-parameters for
+ * the given request handler and page (if any). A conversation is always
+ * propagated via the cid query parameter.
*
* @param handler
* The current request handler
- * @return true if the conversation should be propagated for the given request handler.
+ * @param page
+ * The page associated with the request handler, or null if the
+ * handler is not an {@link IPageRequestHandler}.
+ * @return true if the conversation should be propagated for the given
+ * request handler.
*/
- boolean propagatesViaParameters(IRequestHandler handler);
+ boolean propagatesVia(IRequestHandler handler, Page page);
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/INonContextualManager.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/INonContextualManager.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/INonContextualManager.java
deleted file mode 100644
index 7a7c6dc..0000000
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/INonContextualManager.java
+++ /dev/null
@@ -1,55 +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.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-
-import org.apache.wicket.Component;
-
-/**
- * Manages lifecycle of non-contextual objects like {@link Component} instances, etc
- *
- * @author igor
- *
- */
-public interface INonContextualManager
-{
- /**
- * Inject a noncontextual instance
- *
- * @param <T>
- * @param instance
- */
- <T> void inject(T instance);
-
- /**
- * Inject a noncontextual instance and invokes any {@link PostConstruct} callbacks
- *
- * @param <T>
- * @param instance
- */
- <T> void postConstruct(T instance);
-
- /**
- * Invokes any {@link PreDestroy} callbacks and cleans up
- *
- * @param <T>
- * @param instance
- */
- <T> void preDestroy(T instance);
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextual.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextual.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextual.java
index 3a2f8c6..b596f53 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextual.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextual.java
@@ -1,168 +1,164 @@
-/*
- * 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 java.util.Collections;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionTarget;
-
-import org.apache.wicket.util.collections.ClassMetaCache;
-
-/**
- * Manages lifecycle of non-contextual (non-CDI-managed) objects
- *
- * @author igor
- *
- * @param <T>
- */
-public class NonContextual<T>
-{
- private static final Object lock = new Object();
- private static volatile Map<BeanManager, ClassMetaCache<NonContextual<?>>> cache = Collections.emptyMap();
-
- final InjectionTarget<T> it;
- final BeanManager manager;
-
- /**
- * Undeploys specified bean manager from cache
- *
- * @param beanManager
- */
- public static void undeploy(BeanManager beanManager)
- {
- if (cache.containsKey(beanManager))
- {
- synchronized (lock)
- {
- // copy-on-write the cache
- Map<BeanManager, ClassMetaCache<NonContextual<?>>> newCache = new WeakHashMap<>(
- cache);
- newCache.remove(beanManager);
- cache = Collections.unmodifiableMap(newCache);
- }
- }
- }
-
- /**
- * Convenience factory method for an instance, see {@link #of(Class, BeanManager).
- *
- * @param <T>
- * @param beanManager
- * @return The NonContextual for the instance's class managed by the given manager
- */
- @SuppressWarnings("unchecked")
- public static <T> NonContextual<T> of(T t, BeanManager beanManager)
- {
- // cast is necessary for Eclipse compiler :/
- return (NonContextual<T>)of(t.getClass(), beanManager);
- }
-
- /**
- * Factory method for creating noncontextual instances
- *
- * @param <T>
- * @param clazz
- * @param manager
- * @return The NonContextual for the given class managed by the given manager
- */
- public static <T> NonContextual<T> of(Class<? extends T> clazz, BeanManager manager)
- {
- ClassMetaCache<NonContextual<?>> meta = getCache(manager);
-
- @SuppressWarnings("unchecked")
- NonContextual<T> nc = (NonContextual<T>)meta.get(clazz);
-
- if (nc == null)
- {
- nc = new NonContextual<>(manager, clazz);
- meta.put(clazz, nc);
- }
- return nc;
- }
-
- private static ClassMetaCache<NonContextual<?>> getCache(BeanManager manager)
- {
- ClassMetaCache<NonContextual<?>> meta = cache.get(manager);
- if (meta == null)
- {
- synchronized (lock)
- {
- meta = cache.get(manager);
- if (meta == null)
- {
- meta = new ClassMetaCache<>();
-
- // copy-on-write the cache
- Map<BeanManager, ClassMetaCache<NonContextual<?>>> newCache = new WeakHashMap<>(
- cache);
- newCache.put(manager, meta);
- cache = Collections.unmodifiableMap(newCache);
- }
- }
- }
- return meta;
- }
-
- @SuppressWarnings("unchecked")
- private NonContextual(BeanManager manager, Class<? extends T> clazz)
- {
- this.manager = manager;
- AnnotatedType<? extends T> type = manager.createAnnotatedType(clazz);
- this.it = (InjectionTarget<T>)manager.createInjectionTarget(type);
- }
-
- /**
- * Injects the instance and calls any {@link PostConstruct} methods
- *
- * @param instance
- */
- public void postConstruct(T instance)
- {
- CreationalContext<T> cc = manager.createCreationalContext(null);
- it.inject(instance, cc);
- it.postConstruct(instance);
- }
-
- /**
- * Injects the instance
- *
- * @param instance
- */
- public void inject(T instance)
- {
- CreationalContext<T> cc = manager.createCreationalContext(null);
- it.inject(instance, cc);
- }
-
- /**
- * Calls any {@link PreDestroy} methods and destroys any injected dependencies that need to be
- * destroyed.
- *
- * @param instance
- */
- public void preDestroy(T instance)
- {
- it.preDestroy(instance);
- }
-}
+/*
+ * 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 java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+import org.apache.wicket.util.collections.ClassMetaCache;
+
+/**
+ * Manages lifecycle of non-contextual (non-CDI-managed) objects
+ *
+ * @param <T>
+ * @author igor
+ */
+public class NonContextual<T>
+{
+ private static final Object lock = new Object();
+ private static volatile Map<BeanManager, ClassMetaCache<NonContextual<?>>> cache = Collections
+ .emptyMap();
+
+ final InjectionTarget<T> it;
+
+ /**
+ * Undeploys the looked up bean manager from cache
+ */
+ public static void undeploy()
+ {
+ if (cache.containsKey(BeanManagerLookup.lookup()))
+ {
+ synchronized (lock)
+ {
+ // copy-on-write the cache
+ Map<BeanManager, ClassMetaCache<NonContextual<?>>> newCache = new WeakHashMap<BeanManager, ClassMetaCache<NonContextual<?>>>(
+ cache);
+ newCache.remove(BeanManagerLookup.lookup());
+ cache = Collections.unmodifiableMap(newCache);
+ }
+ }
+ }
+
+ /**
+ * Convenience factory method for an instance, see {@link #of(Class).
+ *
+ * @param <T>
+ * @param clazz
+ * @return The NonContextual for the instance's class
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> NonContextual<T> of(T t) {
+ // cast is necessary for Eclipse compiler :/
+ return (NonContextual<T>)of(t.getClass());
+ }
+
+ /**
+ * Factory method for creating non-contextual instances
+ *
+ * @param <T>
+ * @param clazz
+ * @return The NonContextual for the given class
+ */
+ public static <T> NonContextual<T> of(Class<? extends T> clazz)
+ {
+ ClassMetaCache<NonContextual<?>> meta = getCache();
+
+ @SuppressWarnings("unchecked")
+ NonContextual<T> nc = (NonContextual<T>)meta.get(clazz);
+
+ if (nc == null)
+ {
+ nc = new NonContextual<T>(clazz);
+ meta.put(clazz, nc);
+ }
+ return nc;
+ }
+
+ private static ClassMetaCache<NonContextual<?>> getCache()
+ {
+ ClassMetaCache<NonContextual<?>> meta = cache.get(BeanManagerLookup.lookup());
+ if (meta == null)
+ {
+ synchronized (lock)
+ {
+ BeanManager manager = BeanManagerLookup.lookup();
+ meta = cache.get(manager);
+ if (meta == null)
+ {
+ meta = new ClassMetaCache<NonContextual<?>>();
+
+ // copy-on-write the cache
+ Map<BeanManager, ClassMetaCache<NonContextual<?>>> newCache = new WeakHashMap<BeanManager, ClassMetaCache<NonContextual<?>>>(
+ cache);
+ newCache.put(manager, meta);
+ cache = Collections.unmodifiableMap(newCache);
+ }
+ }
+ }
+ return meta;
+ }
+
+ @SuppressWarnings("unchecked")
+ private NonContextual(Class<? extends T> clazz)
+ {
+ BeanManager manager = BeanManagerLookup.lookup();
+ AnnotatedType<? extends T> type = manager.createAnnotatedType(clazz);
+ this.it = (InjectionTarget<T>)manager.createInjectionTarget(type);
+ }
+
+ /**
+ * Injects the instance and calls any {@link PostConstruct} methods
+ *
+ * @param instance
+ */
+ public void postConstruct(T instance)
+ {
+ CreationalContext<T> cc = BeanManagerLookup.lookup().createCreationalContext(null);
+ it.inject(instance, cc);
+ it.postConstruct(instance);
+ }
+
+ /**
+ * Injects the instance
+ *
+ * @param instance
+ */
+ public void inject(T instance)
+ {
+ CreationalContext<T> cc = BeanManagerLookup.lookup().createCreationalContext(null);
+ it.inject(instance, cc);
+ }
+
+ /**
+ * Calls any {@link PreDestroy} methods and destroys any injected
+ * dependencies that need to be destroyed.
+ *
+ * @param instance
+ */
+ public void preDestroy(T instance)
+ {
+ it.preDestroy(instance);
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextualManager.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextualManager.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextualManager.java
deleted file mode 100644
index a5c63d0..0000000
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/NonContextualManager.java
+++ /dev/null
@@ -1,78 +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.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.apache.wicket.util.lang.Args;
-
-/**
- * Default implementation of {@link INonContextualManager} using {@link NonContextual} helper
- *
- * @author igor
- *
- */
-class NonContextualManager implements INonContextualManager
-{
- private final BeanManager beanManager;
-
- /**
- * Constructor
- *
- * @param beanManager
- */
- public NonContextualManager(BeanManager beanManager)
- {
- Args.notNull(beanManager, "beanManager");
-
- this.beanManager = beanManager;
- }
-
- /**
- * Performs dependency injection on the noncontextual instance
- */
- @Override
- public <T> void inject(T instance)
- {
- Args.notNull(instance, "instance");
- NonContextual.of(instance, beanManager).inject(instance);
- }
-
- /**
- * Performs dependency injection on the noncontextual instance and invokes any
- * {@link PostConstruct} callbacks
- */
- @Override
- public <T> void postConstruct(T instance)
- {
- Args.notNull(instance, "instance");
- NonContextual.of(instance, beanManager).postConstruct(instance);
- }
-
- /**
- * Invokes any {@link PreDestroy} callbacks and cleans up any injected dependencies
- */
- @Override
- public <T> void preDestroy(T instance)
- {
- Args.notNull(instance, "instance");
- NonContextual.of(instance, beanManager).preDestroy(instance);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/SessionInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/SessionInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/SessionInjector.java
index d81d62a..a6fb4d2 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/SessionInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/SessionInjector.java
@@ -29,12 +29,9 @@ class SessionInjector extends AbstractInjector implements ISessionListener
{
/**
* Constructor
- *
- * @param container
*/
- public SessionInjector(CdiContainer container)
+ public SessionInjector()
{
- super(container);
}
@Override
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/resources/META-INF/beans.xml b/wicket-cdi/src/main/resources/META-INF/beans.xml
index e69de29..6a2f1ec 100644
--- a/wicket-cdi/src/main/resources/META-INF/beans.xml
+++ b/wicket-cdi/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
+ version="1.1" bean-discovery-mode="annotated" />
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java
index 92efb73..3a3f7bf 100644
--- a/wicket-cdi/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java
@@ -21,8 +21,9 @@ 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.
+ * 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)
*/
@@ -35,6 +36,7 @@ public class ApacheLicenceHeaderTest extends ApacheLicenseHeaderTestCase
{
xmlIgnore.add(".settings");
xmlIgnore.add("src/main/resources/META-INF/beans.xml");
+ xmlIgnore.add("src/test/java/simplelogger.properties");
xmlPrologIgnore = Arrays.asList("src");
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
new file mode 100644
index 0000000..723db16
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.cdi.testapp.TestConversationPage;
+import org.apache.wicket.cdi.testapp.TestPage;
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.Test;
+
+/**
+ * @author jsarman
+ */
+public class CdiConfigurationTest extends WicketCdiTestCase
+{
+ @Test
+ public void testApplicationScope()
+ {
+ configure(new CdiConfiguration());
+ tester.startPage(TestPage.class);
+ tester.assertLabel("appscope", "Test ok");
+ }
+
+ @Test
+ public void testConversationScope()
+ {
+ configure(new CdiConfiguration());
+ tester.startPage(TestConversationPage.class);
+ for (int i = 0; i < 20; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ }
+
+ @Test(expected = Exception.class)
+ public void testConfigureTwice()
+ {
+ configure(new CdiConfiguration());
+ new CdiConfiguration().configure(tester.getApplication());
+ }
+
+ @Test
+ public void testApplicationLevelConfiguration()
+ {
+ WicketTester tester = new WicketTester();
+ CdiConfiguration config = new CdiConfiguration();
+ for (ConversationPropagation cp : ConversationPropagation.values())
+ {
+ config.setPropagation(cp);
+ assertEquals(cp, config.getPropagation());
+ }
+ config.configure(tester.getApplication());
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/CdiWicketTester.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/CdiWicketTester.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/CdiWicketTester.java
new file mode 100644
index 0000000..275a9bc
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/CdiWicketTester.java
@@ -0,0 +1,129 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+
+import org.apache.wicket.Page;
+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;
+
+/**
+ * @author jsarman
+ */
+public class CdiWicketTester extends WicketTester
+{
+ private static final Pattern COUNT_PATTERN = Pattern.compile("COUNT=x([0-9]+)x");
+ private static final Logger logger = LoggerFactory.getLogger(CdiWicketTester.class);
+
+ @Inject
+ ContextManager contextManager;
+
+ public CdiWicketTester(WebApplication app)
+ {
+ super(app);
+ NonContextual.of(CdiWicketTester.class).inject(this);
+ getHttpSession().setTemporary(false);
+ }
+
+ /**
+ * 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
+ * topmost call and only activate and deactivate the contexts during that
+ * time.
+ *
+ * @param forcedRequest
+ * @param forcedRequestHandler
+ * @param redirect
+ * @return
+ */
+ @Override
+ protected boolean processRequest(final MockHttpServletRequest forcedRequest,
+ final IRequestHandler forcedRequestHandler, final boolean redirect)
+ {
+ if (getLastRequest() != null)
+ {
+ contextManager.deactivateContexts();
+ }
+ contextManager.activateContexts(forcedRequest == null ? getRequest() : forcedRequest);
+ return super.processRequest(forcedRequest, forcedRequestHandler, redirect);
+ }
+
+ @Override
+ public Url urlFor(IRequestHandler handler)
+ {
+ Url ret = super.urlFor(handler);
+ final CdiConfiguration configuration = CdiConfiguration.get(getApplication());
+ Page page = ConversationPropagator.getPage(handler);
+ if (configuration.getPropagation().propagatesVia(handler, page))
+ {
+ if (page != null)
+ {
+ String cid = ConversationPropagator.getConversationIdFromPage(page);
+ ret.addQueryParameter(ConversationPropagator.CID, cid);
+ }
+ }
+ return ret;
+ }
+
+ @PreDestroy
+ public void finish()
+ {
+ try
+ {
+ logger.debug("Destroying Cdi Wicket Tester");
+ if (getLastRequest() != null)
+ {
+ contextManager.deactivateContexts();
+ }
+ contextManager.destroy();
+ destroy();
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+
+ /**
+ * Asserts that the response contains the right count. This can only be done
+ * by parsing the markup because models only contain valid values during a
+ * request, not after.
+ *
+ * @param count
+ * TODO
+ */
+ public void assertCount(int count)
+ {
+ assertTrue("Response does not contain a count",
+ getLastResponseAsString().contains("COUNT=x"));
+ Matcher matcher = COUNT_PATTERN.matcher(getLastResponseAsString());
+ assertTrue(matcher.find());
+ assertEquals(Integer.toString(count), matcher.group(1));
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ContextManager.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/ContextManager.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ContextManager.java
new file mode 100644
index 0000000..6a8a49e
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ContextManager.java
@@ -0,0 +1,106 @@
+/*
+ * 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.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.jboss.weld.bean.builtin.BeanManagerProxy;
+import org.jboss.weld.module.web.servlet.HttpContextLifecycle;
+import org.jboss.weld.servlet.spi.helpers.AcceptingHttpContextActivationFilter;
+import org.jglue.cdiunit.internal.CdiUnitInitialListenerImpl;
+import org.jglue.cdiunit.internal.servlet.LifecycleAwareRequest;
+
+/**
+ * @author jsarman
+ */
+@ApplicationScoped
+public class ContextManager
+{
+ private HttpServletRequest currentRequest;
+
+ @Inject
+ private BeanManager beanManager;
+
+ private HttpContextLifecycle lifecycle;
+
+ private HttpSession currentSession;
+
+ @PostConstruct
+ public void setup()
+ {
+ try
+ {
+ lifecycle = new HttpContextLifecycle(BeanManagerProxy.unwrap(beanManager),
+ AcceptingHttpContextActivationFilter.INSTANCE, true, true, false, true);
+ }
+ catch (NoSuchMethodError e)
+ {
+ try
+ {
+ lifecycle = HttpContextLifecycle.class.getConstructor(BeanManager.class,
+ AcceptingHttpContextActivationFilter.class).newInstance(
+ BeanManagerProxy.unwrap(beanManager),
+ AcceptingHttpContextActivationFilter.INSTANCE);
+ }
+ catch (Exception e1)
+ {
+ throw new RuntimeException(e1);
+ }
+ }
+ lifecycle.setConversationActivationEnabled(true);
+ }
+
+ public void activateContexts(HttpServletRequest request)
+ {
+ if (currentRequest != null)
+ return;
+
+ currentRequest = new LifecycleAwareRequest(new CdiUnitInitialListenerImpl(), request);
+ lifecycle.requestInitialized(currentRequest, null);
+ }
+
+ public void deactivateContexts()
+ {
+ lifecycle.requestDestroyed(currentRequest);
+ currentSession = currentRequest.getSession(false);
+ currentRequest = null;
+ }
+
+ public void destroy()
+ {
+ if (currentRequest != null)
+ {
+ currentSession = currentRequest.getSession(false);
+ }
+
+ if (currentSession != null)
+ {
+ lifecycle.sessionDestroyed(currentSession);
+ currentSession = null;
+ }
+ }
+
+ public boolean isRequestActive()
+ {
+ return currentRequest != null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ConversationPropagatorTest.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/ConversationPropagatorTest.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ConversationPropagatorTest.java
new file mode 100644
index 0000000..945c9cf
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ConversationPropagatorTest.java
@@ -0,0 +1,202 @@
+/*
+ * 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.Conversation;
+import javax.inject.Inject;
+
+import org.apache.wicket.cdi.testapp.TestConversationPage;
+import org.apache.wicket.cdi.testapp.TestConversationalPage;
+import org.apache.wicket.core.request.mapper.MountedMapper;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+/**
+ * @author jsarman
+ */
+public class ConversationPropagatorTest extends WicketCdiTestCase
+{
+ @Inject
+ Conversation conversation;
+
+ @Test
+ public void testAutoConversationNonBookmarkable()
+ {
+ configure(new CdiConfiguration());
+
+ tester.startPage(TestConversationalPage.class);
+ int i;
+ for (i = 0; i < 3; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ tester.clickLink("next");
+ for (; i < 6; i++)
+ {
+ tester.clickLink("increment");
+ tester.assertCount(1);
+ }
+ }
+
+ @Test
+ public void testAutoConversationBookmarkable()
+ {
+ configure(new CdiConfiguration());
+
+ tester.startPage(TestConversationalPage.class,
+ new PageParameters().add("pageType", "bookmarkable"));
+
+ int i;
+ for (i = 0; i < 3; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ tester.clickLink("next");
+ for (i = 0; i < 3; i++)
+ {
+ tester.clickLink("increment");
+ tester.assertCount(1);
+ }
+ }
+
+ @Test
+ public void testPropagationAllNonBookmarkable()
+ {
+ configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
+
+ tester.startPage(TestConversationPage.class);
+ int i;
+ for (i = 0; i < 3; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ tester.clickLink("next");
+ for (; i < 6; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ }
+
+ @Test
+ public void testPropagationAllHybrid()
+ {
+ configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
+ tester.getApplication().getRootRequestMapperAsCompound().add(new MountedMapper("segment/${pageType}", TestConversationPage.class));
+
+ tester.startPage(TestConversationPage.class, new PageParameters().add("pageType", "hybrid"));
+
+ int i;
+ for (i = 0; i < 3; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ tester.clickLink("next");
+ for (; i < 6; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ }
+
+ /**
+ * https://issues.apache.org/jira/browse/WICKET-6257
+ */
+ @Test
+ public void testPropagationAllHybridRefresh()
+ {
+ configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
+ tester.getApplication().getRootRequestMapperAsCompound().add(new MountedMapper("segment/${pageType}", TestConversationPage.class));
+
+ tester.startPage(TestConversationPage.class, new PageParameters().add("pageType", "hybrid"));
+
+ String pageId = tester.getLastRenderedPage().getId();
+ String cid = conversation.getId();
+
+ tester.executeUrl("segment/hybrid?"+pageId+"&cid="+cid);
+
+ assertThat(tester.getLastRenderedPage().getId(), CoreMatchers.is(pageId));
+ }
+
+ @Test
+ public void testPropagationAllBookmarkable()
+ {
+ configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
+
+ tester.startPage(TestConversationPage.class,
+ new PageParameters().add("pageType", "bookmarkable"));
+ int i;
+ for (i = 0; i < 3; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ tester.clickLink("next");
+ for (; i < 6; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ }
+
+ @Test
+ public void testPropagationNonBookmarkable()
+ {
+ configure(new CdiConfiguration());
+
+ tester.startPage(TestConversationPage.class,
+ new PageParameters().add("pageType", "bookmarkable"));
+ int i;
+ for (i = 0; i < 3; i++)
+ {
+ tester.assertCount(i);
+ tester.clickLink("increment");
+ }
+ tester.clickLink("next");
+ for (; i < 6; i++)
+ {
+ tester.clickLink("increment");
+ tester.assertCount(1);
+ }
+ }
+
+ @Test
+ public void testPropagationNone()
+ {
+ configure(new CdiConfiguration().setPropagation(ConversationPropagation.NONE));
+
+ tester.startPage(TestConversationPage.class);
+ int i;
+ for (i = 0; i < 3; i++)
+ {
+ tester.clickLink("increment");
+ tester.assertCount(1);
+ }
+ tester.clickLink("next");
+ for (; i < 6; i++)
+ {
+ tester.clickLink("increment");
+ tester.assertCount(1);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
new file mode 100644
index 0000000..3f82075
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
@@ -0,0 +1,185 @@
+/*
+ * 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.inject.Inject;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.ThreadContext;
+import org.apache.wicket.behavior.AbstractAjaxBehavior;
+import org.apache.wicket.cdi.testapp.TestAppScope;
+import org.apache.wicket.cdi.testapp.TestCdiApplication;
+import org.apache.wicket.cdi.testapp.TestConversationBean;
+import org.apache.wicket.mock.MockApplication;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.util.tester.WicketTester;
+import org.jglue.cdiunit.AdditionalClasses;
+import org.jglue.cdiunit.CdiRunner;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+/**
+ * @author jsarman
+ */
+@RunWith(CdiRunner.class)
+@AdditionalClasses({ CdiWicketTester.class, BehaviorInjector.class, CdiConfiguration.class,
+ CdiShutdownCleaner.class, ComponentInjector.class, ConversationExpiryChecker.class,
+ ConversationPropagator.class, DetachEventEmitter.class, SessionInjector.class,
+ TestAppScope.class, TestConversationBean.class, TestCdiApplication.class,
+ AutoConversation.class })
+public abstract class WicketCdiTestCase extends Assert
+{
+ @Inject
+ private ContextManager contextManager;
+ /** */
+ protected CdiWicketTester tester;
+
+ protected CdiWicketTester newWicketTester(WebApplication app)
+ {
+ return new CdiWicketTester(app);
+ }
+
+ public void configure(CdiConfiguration configuration)
+ {
+ configuration.configure(tester.getApplication());
+ }
+
+ @After
+ public void end()
+ {
+ if (contextManager.isRequestActive())
+ {
+ contextManager.deactivateContexts();
+ contextManager.destroy();
+ }
+ }
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Before
+ public void commonBefore()
+ {
+ // make sure no leaked threadlocals are present
+ ThreadContext.detach();
+
+ WebApplication application = newApplication();
+ tester = newWicketTester(application);
+ }
+
+ /**
+ * @return the application that should be used for the test
+ */
+ protected WebApplication newApplication()
+ {
+ return new MockApplication();
+ }
+
+ /**
+ *
+ */
+ @After
+ public void commonAfter()
+ {
+ tester.destroy();
+ }
+
+ /**
+ * Use <code>-Dwicket.replace.expected.results=true</code> to automatically
+ * replace the expected output file.
+ *
+ * @param <T>
+ *
+ * @param pageClass
+ * @param filename
+ * @throws Exception
+ */
+ protected <T extends Page> void executeTest(final Class<T> pageClass, final String filename)
+ throws Exception
+ {
+ tester.executeTest(getClass(), pageClass, filename);
+ }
+
+ /**
+ * Use <code>-Dwicket.replace.expected.results=true</code> to automatically
+ * replace the expected output file.
+ *
+ * @param page
+ * @param filename
+ * @throws Exception
+ */
+ protected void executeTest(final Page page, final String filename) throws Exception
+ {
+ tester.executeTest(getClass(), page, filename);
+ }
+
+ /**
+ * Use <code>-Dwicket.replace.expected.results=true</code> to automatically
+ * replace the expected output file.
+ *
+ * @param <T>
+ *
+ * @param pageClass
+ * @param parameters
+ * @param filename
+ * @throws Exception
+ */
+ protected <T extends Page> void executeTest(final Class<T> pageClass,
+ PageParameters parameters, final String filename) throws Exception
+ {
+ tester.executeTest(getClass(), pageClass, parameters, filename);
+ }
+
+ /**
+ *
+ * @param component
+ * @param filename
+ * @throws Exception
+ */
+ protected void executeListener(final Component component, final String filename)
+ throws Exception
+ {
+ tester.executeListener(getClass(), component, filename);
+ }
+
+ /**
+ *
+ * @param behavior
+ * @param filename
+ * @throws Exception
+ */
+ protected void executeBehavior(final AbstractAjaxBehavior behavior, final String filename)
+ throws Exception
+ {
+ tester.executeBehavior(getClass(), behavior, filename);
+ }
+
+ /**
+ * Returns the current Maven build directory taken from the <tt>basedir</tt>
+ * system property, or null if not set
+ *
+ * @return path with a trailing slash
+ */
+ public String getBasedir()
+ {
+ return WicketTester.getBasedir();
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestAppScope.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestAppScope.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestAppScope.java
new file mode 100644
index 0000000..b36f8a7
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestAppScope.java
@@ -0,0 +1,40 @@
+/*
+ * 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.testapp;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+
+/**
+ * @author jsarman
+ */
+@ApplicationScoped
+public class TestAppScope
+{
+
+ public String test()
+ {
+ return "Test ok";
+ }
+
+ public @Produces
+ @TestQualifier
+ String testString()
+ {
+ return "Test String";
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
new file mode 100644
index 0000000..7b82203
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
@@ -0,0 +1,39 @@
+/*
+ * 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.testapp;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.protocol.http.WebApplication;
+
+/**
+ * @author jsarman
+ */
+public class TestApplication extends WebApplication
+{
+
+ @Override
+ public Class<? extends Page> getHomePage()
+ {
+ return TestPage.class;
+ }
+
+ @Override
+ protected void init()
+ {
+ super.init();
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
new file mode 100644
index 0000000..1bd8656
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
@@ -0,0 +1,54 @@
+/*
+ * 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.testapp;
+
+import javax.inject.Inject;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.cdi.CdiConfiguration;
+import org.apache.wicket.protocol.http.WebApplication;
+
+/**
+ * @author jsarman
+ */
+public class TestCdiApplication extends WebApplication
+{
+
+ @Inject
+ @TestQualifier
+ String testString;
+
+
+ @Override
+ public Class<? extends Page> getHomePage()
+ {
+ return TestPage.class;
+ }
+
+ @Override
+ protected void init()
+ {
+ super.init();
+ new CdiConfiguration().configure(this);
+ }
+
+ public String getInjectedTestString()
+ {
+ return testString;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationBean.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationBean.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationBean.java
new file mode 100644
index 0000000..140ecdb
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationBean.java
@@ -0,0 +1,56 @@
+/*
+ * 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.testapp;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.enterprise.context.ConversationScoped;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author jsarman
+ */
+@ConversationScoped
+public class TestConversationBean implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger = LoggerFactory.getLogger(TestConversationBean.class);
+
+ private AtomicInteger counter = new AtomicInteger();
+
+ public int getCount()
+ {
+ logger.debug("Count = {}", counter.get());
+ return counter.get();
+ }
+
+ public String getCountStr()
+ {
+ return "COUNT=x" + getCount() + "x";
+ }
+
+ public void increment()
+ {
+
+ counter.incrementAndGet();
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.html
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.html b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.html
new file mode 100644
index 0000000..e7f3de7
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html xmlns:wicket>
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+<body>
+<span wicket:id="count">100</span>
+<a wicket:id="increment">increment</a>
+<a wicket:id="next">Reset</a>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.java
new file mode 100644
index 0000000..c6cc8bc
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.java
@@ -0,0 +1,84 @@
+/*
+ * 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.testapp;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Inject;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+
+/**
+ * @author jsarman
+ */
+public class TestConversationPage extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ @Inject
+ Conversation conversation;
+
+ @Inject
+ TestConversationBean counter;
+
+ public TestConversationPage()
+ {
+ this(new PageParameters());
+ }
+
+ public TestConversationPage(final PageParameters parameters)
+ {
+ super(parameters);
+
+ conversation.begin();
+ System.out.println("Opened Conversion with id = " + conversation.getId());
+
+ add(new Label("count", new PropertyModel<String>(this, "counter.countStr")));
+
+ add(new Link<Void>("increment")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick()
+ {
+ counter.increment();
+ }
+ });
+ add(new Link<Void>("next")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick()
+ {
+ String pageType = parameters.get("pageType").toString("nonbookmarkable");
+ if ("bookmarkable".equals(pageType.toLowerCase()))
+ setResponsePage(TestNonConversationalPage.class);
+ else if ("hybrid".equals(pageType.toLowerCase()))
+ setResponsePage(TestConversationPage.this);
+ else
+ setResponsePage(new TestNonConversationalPage());
+ }
+ });
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
new file mode 100644
index 0000000..b3550f1
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html xmlns:wicket>
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+<body>
+<span wicket:id="count">100</span>
+<a wicket:id="increment">increment</a>
+<a wicket:id="next">next</a>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java
new file mode 100644
index 0000000..5e41fd5
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java
@@ -0,0 +1,78 @@
+/*
+ * 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.testapp;
+
+import javax.inject.Inject;
+
+import org.apache.wicket.cdi.ConversationalComponent;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author jsarman
+ */
+public class TestConversationalPage extends WebPage implements ConversationalComponent
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger = LoggerFactory.getLogger(TestConversationPage.class);
+ @Inject
+ TestConversationBean counter;
+
+ public TestConversationalPage()
+ {
+ this(new PageParameters());
+ }
+
+
+ public TestConversationalPage(final PageParameters pp)
+ {
+ logger.debug("Starting TestConversationalPage");
+
+ add(new Label("count", new PropertyModel<String>(this, "counter.countStr")));
+
+ add(new Link<Void>("increment")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick()
+ {
+ counter.increment();
+ }
+ });
+ add(new Link<Void>("next")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick()
+ {
+ String pageType = pp.get("pageType").toString("nonbookmarkable");
+ if ("bookmarkable".equals(pageType.toLowerCase()))
+ setResponsePage(TestNonConversationalPage.class);
+ else
+ setResponsePage(new TestNonConversationalPage());
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
new file mode 100644
index 0000000..fd58f2d
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html xmlns:wicket>
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+<body>
+<span wicket:id="count">100</span>
+<a wicket:id="increment">increment</a>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.java
new file mode 100644
index 0000000..7728e81
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.java
@@ -0,0 +1,55 @@
+/*
+ * 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.testapp;
+
+import javax.inject.Inject;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.PropertyModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author jsarman
+ */
+public class TestNonConversationalPage extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+ private static final Logger logger = LoggerFactory.getLogger(TestConversationPage.class);
+ @Inject
+ TestConversationBean counter;
+
+ public TestNonConversationalPage()
+ {
+ logger.debug("Starting TestConversationalPage");
+ add(new Label("count", new PropertyModel<String>(this, "counter.countStr")));
+
+ add(new Link<Void>("increment")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick()
+ {
+ counter.increment();
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestPage.html
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestPage.html b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestPage.html
new file mode 100644
index 0000000..4689c49
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestPage.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html xmlns:wicket>
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+<body>
+<div wicket:id="appscope">Fail</div>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestPage.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestPage.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestPage.java
new file mode 100644
index 0000000..cf5108b
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestPage.java
@@ -0,0 +1,40 @@
+/*
+ * 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.testapp;
+
+import javax.inject.Inject;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * @author jsarman
+ */
+public class TestPage extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ @Inject
+ TestAppScope appScope;
+
+ public TestPage()
+ {
+
+ add(new Label("appscope", appScope.test()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestQualifier.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestQualifier.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestQualifier.java
new file mode 100644
index 0000000..dcd0289
--- /dev/null
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/testapp/TestQualifier.java
@@ -0,0 +1,35 @@
+/*
+ * 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.testapp;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * @author jsarman
+ */
+@Qualifier
+@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestQualifier {
+
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/test/java/simplelogger.properties
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/simplelogger.properties b/wicket-cdi/src/test/java/simplelogger.properties
new file mode 100644
index 0000000..17c5fe6
--- /dev/null
+++ b/wicket-cdi/src/test/java/simplelogger.properties
@@ -0,0 +1 @@
+org.slf4j.simpleLogger.log.org.apache.wicket.cdi=info
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-examples/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-examples/pom.xml b/wicket-examples/pom.xml
index bc010a3..98bc936 100644
--- a/wicket-examples/pom.xml
+++ b/wicket-examples/pom.xml
@@ -105,7 +105,7 @@
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
- <artifactId>wicket-cdi-1.1</artifactId>
+ <artifactId>wicket-cdi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
@@ -150,7 +150,7 @@
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
- <artifactId>weld-servlet</artifactId>
+ <artifactId>weld-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-ioc/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-ioc/pom.xml b/wicket-ioc/pom.xml
index d2eba4f..5eaa0ab 100644
--- a/wicket-ioc/pom.xml
+++ b/wicket-ioc/pom.xml
@@ -15,7 +15,9 @@
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">
+<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>
@@ -58,6 +60,11 @@
<artifactId>asm-util</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.weld.se</groupId>
+ <artifactId>weld-se-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
[3/3] wicket git commit: WICKET-6581 Module wicket-cdi-1.1 migrated
to CDI 2 and name changed to wicket-cdi. Solved dependecy problems with weld
versions.
Posted by ad...@apache.org.
WICKET-6581 Module wicket-cdi-1.1 migrated to CDI 2 and name changed to wicket-cdi. Solved dependecy problems with weld versions.
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/057c402b
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/057c402b
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/057c402b
Branch: refs/heads/master
Commit: 057c402b473bcb027176d60710e5aadfa9c7f55e
Parents: 056d726
Author: Andrea Del Bene <an...@gmail.com>
Authored: Mon Sep 24 21:21:29 2018 +0200
Committer: Andrea Del Bene <an...@gmail.com>
Committed: Mon Sep 24 22:06:53 2018 +0200
----------------------------------------------------------------------
pom.xml | 42 +--
.../testing/WicketJavaEEApplication.java | 6 +-
wicket-cdi-1.1/pom.xml | 93 ------
.../org/apache/wicket/cdi/AbstractInjector.java | 39 ---
.../org/apache/wicket/cdi/AutoConversation.java | 50 ---
.../wicket/cdi/AutoConversationManager.java | 121 -------
.../apache/wicket/cdi/BeanManagerLookup.java | 128 -------
.../org/apache/wicket/cdi/BehaviorInjector.java | 42 ---
.../org/apache/wicket/cdi/CdiConfiguration.java | 126 -------
.../apache/wicket/cdi/CdiShutdownCleaner.java | 39 ---
.../apache/wicket/cdi/ComponentInjector.java | 43 ---
.../cdi/ConversationExpiredException.java | 52 ---
.../wicket/cdi/ConversationExpiryChecker.java | 70 ----
.../wicket/cdi/ConversationPropagation.java | 62 ----
.../wicket/cdi/ConversationPropagator.java | 291 ----------------
.../wicket/cdi/ConversationalComponent.java | 30 --
.../java/org/apache/wicket/cdi/DetachEvent.java | 28 --
.../apache/wicket/cdi/DetachEventEmitter.java | 75 -----
.../cdi/ICdiAwareRequestCycleListener.java | 41 ---
.../wicket/cdi/IConversationPropagation.java | 47 ---
.../org/apache/wicket/cdi/NonContextual.java | 164 ---------
.../org/apache/wicket/cdi/SessionInjector.java | 42 ---
.../src/main/resources/META-INF/beans.xml | 4 -
.../wicket/cdi/ApacheLicenceHeaderTest.java | 42 ---
.../apache/wicket/cdi/CdiConfigurationTest.java | 68 ----
.../org/apache/wicket/cdi/CdiWicketTester.java | 129 -------
.../org/apache/wicket/cdi/ContextManager.java | 106 ------
.../wicket/cdi/ConversationPropagatorTest.java | 202 -----------
.../apache/wicket/cdi/WicketCdiTestCase.java | 185 -----------
.../apache/wicket/cdi/testapp/TestAppScope.java | 40 ---
.../wicket/cdi/testapp/TestApplication.java | 39 ---
.../wicket/cdi/testapp/TestCdiApplication.java | 54 ---
.../cdi/testapp/TestConversationBean.java | 56 ----
.../cdi/testapp/TestConversationPage.html | 12 -
.../cdi/testapp/TestConversationPage.java | 84 -----
.../cdi/testapp/TestConversationalPage.html | 12 -
.../cdi/testapp/TestConversationalPage.java | 78 -----
.../cdi/testapp/TestNonConversationalPage.html | 11 -
.../cdi/testapp/TestNonConversationalPage.java | 55 ---
.../org/apache/wicket/cdi/testapp/TestPage.html | 10 -
.../org/apache/wicket/cdi/testapp/TestPage.java | 40 ---
.../wicket/cdi/testapp/TestQualifier.java | 35 --
.../src/test/java/simplelogger.properties | 1 -
wicket-cdi/pom.xml | 35 +-
.../org/apache/wicket/cdi/AbstractInjector.java | 12 +-
.../org/apache/wicket/cdi/AutoConversation.java | 7 +-
.../wicket/cdi/AutoConversationManager.java | 121 +++++++
.../apache/wicket/cdi/BeanManagerLookup.java | 128 +++++++
.../org/apache/wicket/cdi/BehaviorInjector.java | 7 +-
.../org/apache/wicket/cdi/CdiConfiguration.java | 184 +++-------
.../org/apache/wicket/cdi/CdiContainer.java | 167 ----------
.../apache/wicket/cdi/CdiShutdownCleaner.java | 20 +-
.../apache/wicket/cdi/ComponentInjector.java | 5 +-
.../cdi/ConversationExpiredException.java | 3 +-
.../wicket/cdi/ConversationExpiryChecker.java | 22 +-
.../wicket/cdi/ConversationIdMetaKey.java | 24 --
.../wicket/cdi/ConversationPropagation.java | 32 +-
.../wicket/cdi/ConversationPropagator.java | 312 ++++-------------
.../wicket/cdi/ConversationalComponent.java | 10 +-
.../apache/wicket/cdi/DetachEventEmitter.java | 11 +-
.../wicket/cdi/IConversationPropagation.java | 32 +-
.../wicket/cdi/INonContextualManager.java | 55 ---
.../org/apache/wicket/cdi/NonContextual.java | 332 +++++++++----------
.../apache/wicket/cdi/NonContextualManager.java | 78 -----
.../org/apache/wicket/cdi/SessionInjector.java | 5 +-
.../src/main/resources/META-INF/beans.xml | 4 +
.../wicket/cdi/ApacheLicenceHeaderTest.java | 6 +-
.../apache/wicket/cdi/CdiConfigurationTest.java | 68 ++++
.../org/apache/wicket/cdi/CdiWicketTester.java | 129 +++++++
.../org/apache/wicket/cdi/ContextManager.java | 106 ++++++
.../wicket/cdi/ConversationPropagatorTest.java | 202 +++++++++++
.../apache/wicket/cdi/WicketCdiTestCase.java | 185 +++++++++++
.../apache/wicket/cdi/testapp/TestAppScope.java | 40 +++
.../wicket/cdi/testapp/TestApplication.java | 39 +++
.../wicket/cdi/testapp/TestCdiApplication.java | 54 +++
.../cdi/testapp/TestConversationBean.java | 56 ++++
.../cdi/testapp/TestConversationPage.html | 12 +
.../cdi/testapp/TestConversationPage.java | 84 +++++
.../cdi/testapp/TestConversationalPage.html | 12 +
.../cdi/testapp/TestConversationalPage.java | 78 +++++
.../cdi/testapp/TestNonConversationalPage.html | 11 +
.../cdi/testapp/TestNonConversationalPage.java | 55 +++
.../org/apache/wicket/cdi/testapp/TestPage.html | 10 +
.../org/apache/wicket/cdi/testapp/TestPage.java | 40 +++
.../wicket/cdi/testapp/TestQualifier.java | 35 ++
.../src/test/java/simplelogger.properties | 1 +
wicket-examples/pom.xml | 4 +-
wicket-ioc/pom.xml | 9 +-
88 files changed, 1858 insertions(+), 3878 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index da33efc..935278b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,7 +108,6 @@
<module>testing/wicket-arquillian</module>
<module>wicket-native-websocket</module>
<module>wicket-bean-validation</module>
- <module>wicket-cdi-1.1</module>
<module>wicket-user-guide</module>
</modules>
<properties>
@@ -294,12 +293,6 @@
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
- <artifactId>wicket-cdi-1.1</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- <type>jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>9.0.0-SNAPSHOT</version>
<type>jar</type>
@@ -418,34 +411,19 @@
<type>jar</type>
</dependency>
<dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-api</artifactId>
- <version>3.0.SP4</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-core</artifactId>
- <version>2.4.7.Final</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-core-impl</artifactId>
- <version>3.0.5.Final</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-spi</artifactId>
- <version>3.0.SP4</version>
- </dependency>
- <dependency>
<groupId>org.jboss.weld.module</groupId>
<artifactId>weld-web</artifactId>
<version>3.0.4.Final</version>
</dependency>
<dependency>
- <groupId>org.jboss.weld.servlet</groupId>
- <artifactId>weld-servlet</artifactId>
- <version>2.4.2.SP1</version>
+ <groupId>org.jboss.weld.se</groupId>
+ <artifactId>weld-se-core</artifactId>
+ <version>3.0.4.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld.servlet</groupId>
+ <artifactId>weld-servlet-core</artifactId>
+ <version>3.0.4.Final</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
@@ -578,7 +556,7 @@
<dependency>
<groupId>org.jglue.cdi-unit</groupId>
<artifactId>cdi-unit</artifactId>
- <version>4.0.2</version>
+ <version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -1003,7 +981,7 @@
<includes>
<include>**/*Test.java</include>
</includes>
- <argLine>--add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-modules=ALL-SYSTEM</argLine>
+
</configuration>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/testing/wicket-arquillian/src/main/java/org/apache/wicket/arquillian/testing/WicketJavaEEApplication.java
----------------------------------------------------------------------
diff --git a/testing/wicket-arquillian/src/main/java/org/apache/wicket/arquillian/testing/WicketJavaEEApplication.java b/testing/wicket-arquillian/src/main/java/org/apache/wicket/arquillian/testing/WicketJavaEEApplication.java
index 6dc0c93..13f57bf 100644
--- a/testing/wicket-arquillian/src/main/java/org/apache/wicket/arquillian/testing/WicketJavaEEApplication.java
+++ b/testing/wicket-arquillian/src/main/java/org/apache/wicket/arquillian/testing/WicketJavaEEApplication.java
@@ -60,8 +60,10 @@ public class WicketJavaEEApplication extends WebApplication {
initResourceFinder();
// Configure CDI, disabling Conversations as we aren't using them
- new CdiConfiguration(bm).setPropagation(ConversationPropagation.NONE).configure(this);
-
+ CdiConfiguration cdiConfiguration = new CdiConfiguration();
+ cdiConfiguration.setPropagation(ConversationPropagation.NONE).configure(this);
+ cdiConfiguration.setFallbackBeanManager(bm);
+
// Mount the InsertContact page at /insert
mountPage("/insert", InsertContact.class);
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/pom.xml b/wicket-cdi-1.1/pom.xml
deleted file mode 100644
index 18448d4..0000000
--- a/wicket-cdi-1.1/pom.xml
+++ /dev/null
@@ -1,93 +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-parent</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>wicket-cdi-1.1</artifactId>
- <packaging>bundle</packaging>
- <name>Wicket CDI 1.1</name>
- <description>
- Provides integration between Wicket and CDI containers. Enables injection of
- components and behaviors, as well as other non-contextual object instances.
- Also enables propagation of conversations between wicket artifacts such as pages
- and resources.
- </description>
- <dependencyManagement>
- <dependencies>
- <!-- local management because we can only define one GAV in the parent -->
- <dependency>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- <version>1.1</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld.module</groupId>
- <artifactId>weld-web</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld.se</groupId>
- <artifactId>weld-se</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jglue.cdi-unit</groupId>
- <artifactId>cdi-unit</artifactId>
- </dependency>
- </dependencies>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AbstractInjector.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
deleted file mode 100644
index cf8d67f..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
+++ /dev/null
@@ -1,39 +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;
-
-/**
- * Base class for injectors
- *
- * @author igor
- */
-class AbstractInjector
-{
- public AbstractInjector()
- {
- }
-
- protected <T> void postConstruct(T instance)
- {
- NonContextual.of(instance).postConstruct(instance);
- }
-
- protected <T> void inject(T instance)
- {
- NonContextual.of(instance).inject(instance);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversation.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversation.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversation.java
deleted file mode 100644
index 90f5e19..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversation.java
+++ /dev/null
@@ -1,50 +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.ConversationScoped;
-
-import org.apache.wicket.util.io.IClusterable;
-
-/**
- * A bean that can be used to override whether the lifecycle of the conversation
- * should be managed automatically or not.
- *
- * @author igor
- */
-@ConversationScoped
-public class AutoConversation implements IClusterable
-{
- private static final long serialVersionUID = 1L;
-
- private boolean automatic;
-
- public AutoConversation()
- {
- automatic = false;
- }
-
- public void setAutomatic(boolean automatic)
- {
- this.automatic = automatic;
- }
-
- public boolean isAutomatic()
- {
- return automatic;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
deleted file mode 100644
index 4aedb48..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
+++ /dev/null
@@ -1,121 +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.Conversation;
-import javax.inject.Inject;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.application.IComponentOnBeforeRenderListener;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.util.visit.IVisit;
-import org.apache.wicket.util.visit.IVisitor;
-import org.apache.wicket.util.visit.Visits;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Automatically starts and ends conversations for pages with a
- * {@link ConversationalComponent}.
- *
- * @author papegaaij
- */
-public class AutoConversationManager implements IComponentOnBeforeRenderListener
-{
- private static final Logger logger = LoggerFactory.getLogger(AutoConversationManager.class);
-
- @Inject
- private Conversation conversation;
-
- @Inject
- private AutoConversation autoConversation;
-
- private IConversationPropagation propagation;
-
- public AutoConversationManager(IConversationPropagation propagation)
- {
- NonContextual.of(AutoConversationManager.class).inject(this);
- this.propagation = propagation;
- }
-
- @Override
- public void onBeforeRender(Component component)
- {
- if (component instanceof Page)
- {
- Page page = (Page)component;
- IRequestHandler activeRequestHandler = page.getRequestCycle().getActiveRequestHandler();
- autoEndIfNecessary(page, activeRequestHandler);
- autoBeginIfNecessary(page, activeRequestHandler);
- }
- }
-
- protected void autoBeginIfNecessary(Page page, IRequestHandler handler)
- {
- if (conversation == null || !conversation.isTransient() || page == null
- || !hasConversationalComponent(page) || !propagation.propagatesVia(handler, page))
- {
- return;
- }
-
- // auto activate conversation
-
- conversation.begin();
- autoConversation.setAutomatic(true);
-
- logger.debug("Auto-began conversation '{}' for page '{}'", conversation.getId(), page);
- }
-
- protected void autoEndIfNecessary(Page page, IRequestHandler handler)
- {
- if (conversation == null || conversation.isTransient() || page == null
- || hasConversationalComponent(page) || !propagation.propagatesVia(handler, page)
- || autoConversation.isAutomatic() == false)
- {
- return;
- }
-
- // auto de-activate conversation
-
- String cid = conversation.getId();
-
- autoConversation.setAutomatic(false);
- conversation.end();
- ConversationPropagator.removeConversationIdFromPage(page);
-
- logger.debug("Auto-ended conversation '{}' for page '{}'", cid, page);
- }
-
- protected boolean hasConversationalComponent(Page page)
- {
- Boolean hasConversational = Visits.visit(page, new IVisitor<Component, Boolean>()
- {
- @Override
- public void component(Component object, IVisit<Boolean> visit)
- {
- if (object instanceof ConversationalComponent)
- {
- visit.stop(true);
- }
- }
- });
-
- return hasConversational == null ? false : hasConversational;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java
deleted file mode 100644
index f44e513..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java
+++ /dev/null
@@ -1,128 +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.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.CDI;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.wicket.Application;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Defines several strategies for looking up a CDI BeanManager in a portable
- * way. The following strategies are tried (in order):
- * <ul>
- * <li>JNDI under java:comp/BeanManager (default location)</li>
- * <li>JNDI under java:comp/env/BeanManager (for servlet containers like Tomcat
- * and Jetty)</li>
- * <li>CDI.current().getBeanManager() (portable lookup)</li>
- * <li>{@linkplain CdiConfiguration#getFallbackBeanManager() Fallback}</li>
- * </ul>
- *
- * The last successful lookup strategy is saved and tried first next time.
- *
- * @author papegaaij
- */
-public final class BeanManagerLookup
-{
- private static final Logger log = LoggerFactory.getLogger(BeanManagerLookup.class);
-
- private enum BeanManagerLookupStrategy {
- JNDI {
- @Override
- public BeanManager lookup()
- {
- try
- {
- return InitialContext.doLookup("java:comp/BeanManager");
- }
- catch (NamingException e)
- {
- return null;
- }
- }
- },
- JNDI_ENV {
- @Override
- public BeanManager lookup()
- {
- try
- {
- return InitialContext.doLookup("java:comp/env/BeanManager");
- }
- catch (NamingException e)
- {
- return null;
- }
- }
- },
- CDI_PROVIDER {
- @Override
- public BeanManager lookup()
- {
- try
- {
- return CDI.current().getBeanManager();
- }
- catch (Exception e)
- {
- log.debug(e.getMessage(), e);
- return null;
- }
- }
- },
- FALLBACK {
- @Override
- public BeanManager lookup()
- {
- return CdiConfiguration.get(Application.get()).getFallbackBeanManager();
- }
- };
-
- public abstract BeanManager lookup();
- }
-
- private static BeanManagerLookupStrategy lastSuccessful = BeanManagerLookupStrategy.JNDI;
-
- private BeanManagerLookup()
- {
- }
-
- public static BeanManager lookup()
- {
- BeanManager ret = lastSuccessful.lookup();
- if (ret != null)
- return ret;
-
- for (BeanManagerLookupStrategy curStrategy : BeanManagerLookupStrategy.values())
- {
- ret = curStrategy.lookup();
- if (ret != null)
- {
- lastSuccessful = curStrategy;
- return ret;
- }
- }
-
- throw new IllegalStateException(
- "No BeanManager found via the CDI provider and no fallback specified. Check your "
- + "CDI setup or specify a fallback BeanManager in the CdiConfiguration.");
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java
deleted file mode 100644
index 15979f6..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java
+++ /dev/null
@@ -1,42 +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.IBehaviorInstantiationListener;
-import org.apache.wicket.behavior.Behavior;
-
-/**
- * Injects components with CDI dependencies
- *
- * @author igor
- *
- */
-public class BehaviorInjector extends AbstractInjector implements IBehaviorInstantiationListener
-{
- /**
- * Constructor
- */
- public BehaviorInjector()
- {
- }
-
- @Override
- public void onInstantiation(Behavior behavior)
- {
- inject(behavior);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
deleted file mode 100644
index 30778aa..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
+++ /dev/null
@@ -1,126 +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.inject.spi.BeanManager;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.MetaDataKey;
-import org.apache.wicket.request.cycle.RequestCycleListenerCollection;
-
-/**
- * Configures CDI integration
- *
- * @author igor
- *
- */
-public class CdiConfiguration
-{
- private static final MetaDataKey<CdiConfiguration> CDI_CONFIGURATION_KEY = new MetaDataKey<CdiConfiguration>()
- {
- private static final long serialVersionUID = 1L;
- };
-
- private IConversationPropagation propagation = ConversationPropagation.NONBOOKMARKABLE;
-
- private BeanManager fallbackBeanManager;
-
- /**
- * Constructor
- */
- public CdiConfiguration()
- {
- }
-
- public IConversationPropagation getPropagation()
- {
- return propagation;
- }
-
- public CdiConfiguration setPropagation(IConversationPropagation propagation)
- {
- this.propagation = propagation;
- return this;
- }
-
- public BeanManager getFallbackBeanManager()
- {
- return fallbackBeanManager;
- }
-
- /**
- * Sets a BeanManager that should be used if all strategies to lookup a
- * BeanManager fail. This can be used in scenarios where you do not have
- * JNDI available and do not want to bootstrap the CDI provider. It should
- * be noted that the fallback BeanManager can only be used within the
- * context of a Wicket application (ie. Application.get() should return the
- * application that was configured with this CdiConfiguration).
- *
- * @param fallbackBeanManager
- * @return this instance
- */
- public CdiConfiguration setFallbackBeanManager(BeanManager fallbackBeanManager)
- {
- this.fallbackBeanManager = fallbackBeanManager;
- return this;
- }
-
- /**
- * Configures the specified application
- *
- * @param application
- */
- public void configure(Application 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);
-
- // enable conversation propagation
- if (getPropagation() != ConversationPropagation.NONE)
- {
- listeners.add(new ConversationPropagator(application, getPropagation()));
- application.getComponentPreOnBeforeRenderListeners().add(
- new AutoConversationManager(getPropagation()));
- application.getComponentPreOnBeforeRenderListeners().add(
- new ConversationExpiryChecker());
- }
-
- // enable detach event
- listeners.add(new DetachEventEmitter());
-
- NonContextual.of(application).postConstruct(application);
-
- // enable injection of various framework components
- application.getSessionListeners().add(new SessionInjector());
- application.getComponentInstantiationListeners().add(new ComponentInjector());
- application.getBehaviorInstantiationListeners().add(new BehaviorInjector());
-
- // enable cleanup
- application.getApplicationListeners().add(new CdiShutdownCleaner());
- }
-
- public static CdiConfiguration get(Application application)
- {
- return application.getMetaData(CDI_CONFIGURATION_KEY);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java
deleted file mode 100644
index 25c29dd..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java
+++ /dev/null
@@ -1,39 +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.Application;
-import org.apache.wicket.IApplicationListener;
-
-/**
- * Listens to application shutdown and cleans up
- *
- * @author igor
- */
-class CdiShutdownCleaner implements IApplicationListener
-{
- public CdiShutdownCleaner()
- {
- }
-
- @Override
- public void onBeforeDestroyed(Application application)
- {
- NonContextual.of(application).preDestroy(application);
- NonContextual.undeploy();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ComponentInjector.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
deleted file mode 100644
index 65a4879..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
+++ /dev/null
@@ -1,43 +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.Component;
-import org.apache.wicket.application.IComponentInstantiationListener;
-
-/**
- * Injects components with CDI dependencies
- *
- * @author igor
- *
- */
-class ComponentInjector extends AbstractInjector implements IComponentInstantiationListener
-{
- /**
- * Constructor
- */
- public ComponentInjector()
- {
- }
-
- @Override
- public void onInstantiation(Component component)
- {
- inject(component);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
deleted file mode 100644
index 16df7b1..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
+++ /dev/null
@@ -1,52 +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.Page;
-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;
-
- public ConversationExpiredException(Throwable cause, String cid, Page page,
- IRequestHandler handler)
- {
- super(cause);
- this.cid = cid;
- this.page = page;
- this.handler = handler;
- }
-
- public String getCid()
- {
- return cid;
- }
-
- public Page getPage()
- {
- return page;
- }
-
- public IRequestHandler getHandler()
- {
- return handler;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
deleted file mode 100644
index 3e2bc94..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
+++ /dev/null
@@ -1,70 +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.Conversation;
-import javax.inject.Inject;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.application.IComponentOnBeforeRenderListener;
-import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.util.lang.Objects;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Checks for conversation expiration during page render and throws a
- * {@link ConversationExpiredException} when an expired conversation is
- * detected.
- *
- * For example a link that calls {@link Conversation#end()} but does not
- * redirect to a non-conversation-dependent page will be caught by this
- * listener.
- *
- * @author igor
- *
- */
-public class ConversationExpiryChecker implements IComponentOnBeforeRenderListener
-{
- private static final Logger logger = LoggerFactory.getLogger(ConversationExpiryChecker.class);
-
- @Inject
- private Conversation conversation;
-
- public ConversationExpiryChecker()
- {
- NonContextual.of(ConversationExpiryChecker.class).inject(this);
- }
-
- @Override
- public void onBeforeRender(Component component)
- {
- if (component instanceof Page || RequestCycle.get().find(IPartialPageRequestHandler.class).isPresent())
- {
- Page page = component.getPage();
- String cid = ConversationPropagator.getConversationIdFromPage(page);
- if (cid != null && !Objects.isEqual(conversation.getId(), cid))
- {
- logger.info("Conversation {} has expired for {}", cid, page);
- throw new ConversationExpiredException(null, cid, page, RequestCycle.get()
- .getActiveRequestHandler());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
deleted file mode 100644
index 3c1eb89..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
+++ /dev/null
@@ -1,62 +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.ConversationScoped;
-
-import org.apache.wicket.Page;
-import org.apache.wicket.request.IRequestHandler;
-
-/**
- * Various modes of propagating persistent conversations across requests.
- *
- * @see ConversationScoped
- *
- * @author igor
- */
-public enum ConversationPropagation implements IConversationPropagation {
- /** No conversational propagation takes place */
- NONE {
- @Override
- public boolean propagatesVia(IRequestHandler handler, Page page)
- {
- return false;
- }
- },
- /**
- * Pesistent conversations are propagated between non-bookmarkable pages
- * only
- */
- NONBOOKMARKABLE {
- @Override
- public boolean propagatesVia(IRequestHandler handler, Page page)
- {
- return page != null;
- }
- },
- /**
- * Persistent conversations are propagated between bookmarkable and
- * non-bookmarkable pages
- */
- ALL {
- @Override
- public boolean propagatesVia(IRequestHandler handler, Page page)
- {
- return true;
- }
- };
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
deleted file mode 100644
index 613f6a5..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
+++ /dev/null
@@ -1,291 +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.ContextNotActiveException;
-import javax.enterprise.context.Conversation;
-import javax.enterprise.context.ConversationScoped;
-import javax.inject.Inject;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.MetaDataKey;
-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.request.IRequestHandler;
-import org.apache.wicket.request.IRequestHandlerDelegate;
-import org.apache.wicket.request.Url;
-import org.apache.wicket.request.cycle.IRequestCycleListener;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
-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.Classes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A request cycle listener that takes care of propagating persistent
- * conversations.
- *
- * @see ConversationScoped
- *
- * @author igor
- */
-public class ConversationPropagator implements IRequestCycleListener
-{
- private static final Logger logger = LoggerFactory.getLogger(ConversationPropagator.class);
-
- 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";
-
- /** propagation mode to use */
- private final IConversationPropagation propagation;
-
- private final Application application;
-
- @Inject
- private Conversation conversation;
-
- /**
- * Constructor
- *
- * @param application
- * @param propagation
- */
- public ConversationPropagator(Application application, IConversationPropagation propagation)
- {
- Args.notNull(application, "application");
- Args.notNull(propagation, "propagation");
-
- if (propagation == ConversationPropagation.NONE)
- {
- throw new IllegalArgumentException(
- "If propagation is NONE do not set up the propagator");
- }
-
- this.application = application;
- this.propagation = propagation;
-
- NonContextual.of(ConversationPropagator.class).postConstruct(this);
- }
-
- public IConversationPropagation getPropagation()
- {
- return propagation;
- }
-
- @Override
- public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler)
- {
- if (activateForHandler(handler))
- {
- logger.debug("Activating conversation {}", conversation.getId());
- fireOnAfterConversationStarted(cycle);
- }
- }
-
- private void fireOnAfterConversationStarted(RequestCycle cycle)
- {
- cycle.setMetaData(CONVERSATION_STARTED_KEY, true);
- for (IRequestCycleListener listener : application.getRequestCycleListeners())
- {
- if (listener instanceof ICdiAwareRequestCycleListener)
- {
- ((ICdiAwareRequestCycleListener)listener).onAfterConversationActivated(cycle);
- }
- }
- }
-
- @Override
- public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler)
- {
- // propagate current non-transient conversation to the newly scheduled
- // page
- try
- {
- if (conversation.isTransient())
- {
- return;
- }
- } catch (ContextNotActiveException cnax)
- {
- logger.debug("There is no active context for the requested scope!", cnax);
- return;
- }
-
- if (propagation.propagatesVia(handler, getPage(handler)))
- {
- logger.debug(
- "Propagating non-transient conversation {} via page parameters of handler {}",
- conversation.getId(), handler);
-
- PageParameters parameters = getPageParameters(handler);
- if (parameters != null)
- {
- parameters.set(CID, conversation.getId());
- markPageWithConversationId(handler, conversation.getId());
- }
- }
- }
-
-
- @Override
- public void onUrlMapped(RequestCycle cycle, IRequestHandler handler, Url url)
- {
- // no need to propagate the conversation to packaged resources, they
- // should never change
- if (handler instanceof ResourceReferenceRequestHandler)
- {
- if (((ResourceReferenceRequestHandler)handler).getResourceReference() instanceof PackageResourceReference)
- {
- return;
- }
- }
-
- if (conversation.isTransient())
- {
- return;
- }
-
- if (propagation.propagatesVia(handler, getPage(handler)))
- {
- 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)
- {
- if (!Boolean.TRUE.equals(cycle.getMetaData(CONVERSATION_STARTED_KEY)))
- {
- return;
- }
-
- logger.debug("Deactivating conversation {}", conversation.getId());
- for (IRequestCycleListener listener : application.getRequestCycleListeners())
- {
- if (listener instanceof ICdiAwareRequestCycleListener)
- {
- ((ICdiAwareRequestCycleListener)listener).onBeforeConversationDeactivated(cycle);
- }
- }
- }
-
- /**
- * Determines whether or not a conversation should be activated fro the
- * specified handler. This method is used to filter out conversation
- * activation for utility handlers such as the
- * {@link BufferedResponseRequestHandler}
- *
- * @param handler
- * @return {@code true} iff a conversation should be activated
- */
- protected boolean activateForHandler(IRequestHandler handler)
- {
- if (handler != null)
- {
- String handlerClassName = Classes.name(handler.getClass());
-
- if (handler instanceof BufferedResponseRequestHandler)
- {
- // we do not care about pages that are being rendered from a buffer
- return false;
- } else if ("org.apache.wicket.protocol.ws.api.WebSocketMessageBroadcastHandler".equals(handlerClassName))
- {
- return false;
- } else if ("org.apache.wicket.protocol.ws.api.WebSocketRequestHandler".equals(handlerClassName)) {
- // injection is not supported in web sockets communication
- return false;
- }
- }
- return true;
- }
-
- 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);
- }
-
- public static void removeConversationIdFromPage(Page page)
- {
- page.setMetaData(CONVERSATION_ID_KEY, null);
- }
-
- /**
- * Resolves a page instance from the request handler iff the page instance
- * is already created
- *
- * @param handler
- * @return page or {@code null} if none
- */
- public static Page getPage(IRequestHandler handler)
- {
- while (handler instanceof IRequestHandlerDelegate)
- {
- handler = ((IRequestHandlerDelegate)handler).getDelegateHandler();
- }
-
- if (handler instanceof IPageRequestHandler)
- {
- IPageRequestHandler pageHandler = (IPageRequestHandler)handler;
- if (pageHandler.isPageInstanceCreated())
- {
- return (Page)pageHandler.getPage();
- }
- }
- return null;
- }
-
- /**
- * Resolves page parameters from a request handler
- *
- * @param handler
- * @return page parameters or {@code null} if none
- */
- protected PageParameters getPageParameters(IRequestHandler handler)
- {
- if (handler instanceof IPageClassRequestHandler)
- {
- IPageClassRequestHandler pageHandler = (IPageClassRequestHandler)handler;
- return pageHandler.getPageParameters();
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java
deleted file mode 100644
index 16d9fc1..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ConversationalComponent.java
+++ /dev/null
@@ -1,30 +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;
-
-/**
- * Marks a component that requires a conversation. This marker is used by the
- * automatic conversation management feature to
- * automatically begin and end conversations based on the presence of these
- * components in the component hierarchy of pages (can be applied to the page
- * itself).
- *
- * @author igor
- */
-public interface ConversationalComponent
-{
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/DetachEvent.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/DetachEvent.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/DetachEvent.java
deleted file mode 100644
index ac99ec3..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/DetachEvent.java
+++ /dev/null
@@ -1,28 +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;
-
-/**
- * Fired when request cycle is detached
- *
- * @author igor
- *
- */
-public class DetachEvent
-{
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
deleted file mode 100644
index b141236..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/DetachEventEmitter.java
+++ /dev/null
@@ -1,75 +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.event.Event;
-import javax.inject.Inject;
-
-import org.apache.wicket.MetaDataKey;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.cycle.IRequestCycleListener;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Request cycle listener that fires the {@link DetachEvent} event
- *
- * @author igor
- *
- */
-public class DetachEventEmitter implements IRequestCycleListener
-{
- private static final Logger logger = LoggerFactory.getLogger(DetachEventEmitter.class);
-
- private static final MetaDataKey<Boolean> DETACH_SCHEDULED_KEY = new MetaDataKey<Boolean>()
- {
- private static final long serialVersionUID = 1L;
- };
-
- @Inject
- Event<DetachEvent> detachEvent;
-
- /**
- * Constructor
- */
- public DetachEventEmitter()
- {
- NonContextual.of(DetachEventEmitter.class).postConstruct(this);
- }
-
- @Override
- public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler)
- {
- // this is a wicket request, schedule detach event to be fired
-
- cycle.setMetaData(DETACH_SCHEDULED_KEY, true);
- }
-
- @Override
- public void onDetach(RequestCycle cycle)
- {
- if (Boolean.TRUE.equals(cycle.getMetaData(DETACH_SCHEDULED_KEY)))
- {
- logger.debug("Firing Detach event {}", cycle.getRequest().getUrl());
-
- detachEvent.fire(new DetachEvent());
-
- cycle.setMetaData(DETACH_SCHEDULED_KEY, null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ICdiAwareRequestCycleListener.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ICdiAwareRequestCycleListener.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ICdiAwareRequestCycleListener.java
deleted file mode 100644
index a577954..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/ICdiAwareRequestCycleListener.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;
-
-import org.apache.wicket.request.cycle.IRequestCycleListener;
-import org.apache.wicket.request.cycle.RequestCycle;
-
-public interface ICdiAwareRequestCycleListener extends IRequestCycleListener
-{
- /**
- * Called right after a conversation context for this request is activated
- *
- * @param cycle
- * request cycle
- */
- default void onAfterConversationActivated(RequestCycle cycle)
- {}
-
- /**
- * Called right before the current conversation context is deactivated
- *
- * @param cycle
- * request cycle
- */
- default void onBeforeConversationDeactivated(RequestCycle cycle)
- {}
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
deleted file mode 100644
index b9eb1e3..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/IConversationPropagation.java
+++ /dev/null
@@ -1,47 +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.Page;
-import org.apache.wicket.core.request.handler.IPageRequestHandler;
-import org.apache.wicket.request.IRequestHandler;
-
-/**
- * A strategy that specifies how conversations should be propagated between
- * pages/resources. {@link ConversationPropagation} provides sensible default
- * implementations of this interface.
- *
- * @author papegaaij
- */
-@FunctionalInterface
-public interface IConversationPropagation
-{
- /**
- * Indicates if the conversation should be propagated via url-parameters for
- * the given request handler and page (if any). A conversation is always
- * propagated via the cid query parameter.
- *
- * @param handler
- * The current request handler
- * @param page
- * The page associated with the request handler, or null if the
- * handler is not an {@link IPageRequestHandler}.
- * @return true if the conversation should be propagated for the given
- * request handler.
- */
- boolean propagatesVia(IRequestHandler handler, Page page);
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/NonContextual.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/NonContextual.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/NonContextual.java
deleted file mode 100644
index b596f53..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/NonContextual.java
+++ /dev/null
@@ -1,164 +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 java.util.Collections;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionTarget;
-
-import org.apache.wicket.util.collections.ClassMetaCache;
-
-/**
- * Manages lifecycle of non-contextual (non-CDI-managed) objects
- *
- * @param <T>
- * @author igor
- */
-public class NonContextual<T>
-{
- private static final Object lock = new Object();
- private static volatile Map<BeanManager, ClassMetaCache<NonContextual<?>>> cache = Collections
- .emptyMap();
-
- final InjectionTarget<T> it;
-
- /**
- * Undeploys the looked up bean manager from cache
- */
- public static void undeploy()
- {
- if (cache.containsKey(BeanManagerLookup.lookup()))
- {
- synchronized (lock)
- {
- // copy-on-write the cache
- Map<BeanManager, ClassMetaCache<NonContextual<?>>> newCache = new WeakHashMap<BeanManager, ClassMetaCache<NonContextual<?>>>(
- cache);
- newCache.remove(BeanManagerLookup.lookup());
- cache = Collections.unmodifiableMap(newCache);
- }
- }
- }
-
- /**
- * Convenience factory method for an instance, see {@link #of(Class).
- *
- * @param <T>
- * @param clazz
- * @return The NonContextual for the instance's class
- */
- @SuppressWarnings("unchecked")
- public static <T> NonContextual<T> of(T t) {
- // cast is necessary for Eclipse compiler :/
- return (NonContextual<T>)of(t.getClass());
- }
-
- /**
- * Factory method for creating non-contextual instances
- *
- * @param <T>
- * @param clazz
- * @return The NonContextual for the given class
- */
- public static <T> NonContextual<T> of(Class<? extends T> clazz)
- {
- ClassMetaCache<NonContextual<?>> meta = getCache();
-
- @SuppressWarnings("unchecked")
- NonContextual<T> nc = (NonContextual<T>)meta.get(clazz);
-
- if (nc == null)
- {
- nc = new NonContextual<T>(clazz);
- meta.put(clazz, nc);
- }
- return nc;
- }
-
- private static ClassMetaCache<NonContextual<?>> getCache()
- {
- ClassMetaCache<NonContextual<?>> meta = cache.get(BeanManagerLookup.lookup());
- if (meta == null)
- {
- synchronized (lock)
- {
- BeanManager manager = BeanManagerLookup.lookup();
- meta = cache.get(manager);
- if (meta == null)
- {
- meta = new ClassMetaCache<NonContextual<?>>();
-
- // copy-on-write the cache
- Map<BeanManager, ClassMetaCache<NonContextual<?>>> newCache = new WeakHashMap<BeanManager, ClassMetaCache<NonContextual<?>>>(
- cache);
- newCache.put(manager, meta);
- cache = Collections.unmodifiableMap(newCache);
- }
- }
- }
- return meta;
- }
-
- @SuppressWarnings("unchecked")
- private NonContextual(Class<? extends T> clazz)
- {
- BeanManager manager = BeanManagerLookup.lookup();
- AnnotatedType<? extends T> type = manager.createAnnotatedType(clazz);
- this.it = (InjectionTarget<T>)manager.createInjectionTarget(type);
- }
-
- /**
- * Injects the instance and calls any {@link PostConstruct} methods
- *
- * @param instance
- */
- public void postConstruct(T instance)
- {
- CreationalContext<T> cc = BeanManagerLookup.lookup().createCreationalContext(null);
- it.inject(instance, cc);
- it.postConstruct(instance);
- }
-
- /**
- * Injects the instance
- *
- * @param instance
- */
- public void inject(T instance)
- {
- CreationalContext<T> cc = BeanManagerLookup.lookup().createCreationalContext(null);
- it.inject(instance, cc);
- }
-
- /**
- * Calls any {@link PreDestroy} methods and destroys any injected
- * dependencies that need to be destroyed.
- *
- * @param instance
- */
- public void preDestroy(T instance)
- {
- it.preDestroy(instance);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/SessionInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/SessionInjector.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/SessionInjector.java
deleted file mode 100644
index a6fb4d2..0000000
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/SessionInjector.java
+++ /dev/null
@@ -1,42 +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.ISessionListener;
-import org.apache.wicket.Session;
-
-/**
- * Injects components with CDI dependencies
- *
- * @author igor
- *
- */
-class SessionInjector extends AbstractInjector implements ISessionListener
-{
- /**
- * Constructor
- */
- public SessionInjector()
- {
- }
-
- @Override
- public void onCreated(Session session)
- {
- postConstruct(session);
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/resources/META-INF/beans.xml b/wicket-cdi-1.1/src/main/resources/META-INF/beans.xml
deleted file mode 100644
index 6a2f1ec..0000000
--- a/wicket-cdi-1.1/src/main/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
- version="1.1" bean-discovery-mode="annotated" />
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java
deleted file mode 100644
index 3a3f7bf..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ApacheLicenceHeaderTest.java
+++ /dev/null
@@ -1,42 +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 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");
- xmlIgnore.add("src/test/java/simplelogger.properties");
- xmlPrologIgnore = Arrays.asList("src");
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java
deleted file mode 100644
index 723db16..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.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;
-
-import org.apache.wicket.cdi.testapp.TestConversationPage;
-import org.apache.wicket.cdi.testapp.TestPage;
-import org.apache.wicket.util.tester.WicketTester;
-import org.junit.Test;
-
-/**
- * @author jsarman
- */
-public class CdiConfigurationTest extends WicketCdiTestCase
-{
- @Test
- public void testApplicationScope()
- {
- configure(new CdiConfiguration());
- tester.startPage(TestPage.class);
- tester.assertLabel("appscope", "Test ok");
- }
-
- @Test
- public void testConversationScope()
- {
- configure(new CdiConfiguration());
- tester.startPage(TestConversationPage.class);
- for (int i = 0; i < 20; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- }
-
- @Test(expected = Exception.class)
- public void testConfigureTwice()
- {
- configure(new CdiConfiguration());
- new CdiConfiguration().configure(tester.getApplication());
- }
-
- @Test
- public void testApplicationLevelConfiguration()
- {
- WicketTester tester = new WicketTester();
- CdiConfiguration config = new CdiConfiguration();
- for (ConversationPropagation cp : ConversationPropagation.values())
- {
- config.setPropagation(cp);
- assertEquals(cp, config.getPropagation());
- }
- config.configure(tester.getApplication());
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiWicketTester.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiWicketTester.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiWicketTester.java
deleted file mode 100644
index 275a9bc..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiWicketTester.java
+++ /dev/null
@@ -1,129 +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 static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-
-import org.apache.wicket.Page;
-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;
-
-/**
- * @author jsarman
- */
-public class CdiWicketTester extends WicketTester
-{
- private static final Pattern COUNT_PATTERN = Pattern.compile("COUNT=x([0-9]+)x");
- private static final Logger logger = LoggerFactory.getLogger(CdiWicketTester.class);
-
- @Inject
- ContextManager contextManager;
-
- public CdiWicketTester(WebApplication app)
- {
- super(app);
- NonContextual.of(CdiWicketTester.class).inject(this);
- getHttpSession().setTemporary(false);
- }
-
- /**
- * 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
- * topmost call and only activate and deactivate the contexts during that
- * time.
- *
- * @param forcedRequest
- * @param forcedRequestHandler
- * @param redirect
- * @return
- */
- @Override
- protected boolean processRequest(final MockHttpServletRequest forcedRequest,
- final IRequestHandler forcedRequestHandler, final boolean redirect)
- {
- if (getLastRequest() != null)
- {
- contextManager.deactivateContexts();
- }
- contextManager.activateContexts(forcedRequest == null ? getRequest() : forcedRequest);
- return super.processRequest(forcedRequest, forcedRequestHandler, redirect);
- }
-
- @Override
- public Url urlFor(IRequestHandler handler)
- {
- Url ret = super.urlFor(handler);
- final CdiConfiguration configuration = CdiConfiguration.get(getApplication());
- Page page = ConversationPropagator.getPage(handler);
- if (configuration.getPropagation().propagatesVia(handler, page))
- {
- if (page != null)
- {
- String cid = ConversationPropagator.getConversationIdFromPage(page);
- ret.addQueryParameter(ConversationPropagator.CID, cid);
- }
- }
- return ret;
- }
-
- @PreDestroy
- public void finish()
- {
- try
- {
- logger.debug("Destroying Cdi Wicket Tester");
- if (getLastRequest() != null)
- {
- contextManager.deactivateContexts();
- }
- contextManager.destroy();
- destroy();
- }
- catch (Throwable t)
- {
- }
- }
-
- /**
- * Asserts that the response contains the right count. This can only be done
- * by parsing the markup because models only contain valid values during a
- * request, not after.
- *
- * @param count
- * TODO
- */
- public void assertCount(int count)
- {
- assertTrue("Response does not contain a count",
- getLastResponseAsString().contains("COUNT=x"));
- Matcher matcher = COUNT_PATTERN.matcher(getLastResponseAsString());
- assertTrue(matcher.find());
- assertEquals(Integer.toString(count), matcher.group(1));
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ContextManager.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ContextManager.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ContextManager.java
deleted file mode 100644
index ee92367..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ContextManager.java
+++ /dev/null
@@ -1,106 +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.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.jboss.weld.bean.builtin.BeanManagerProxy;
-import org.jboss.weld.servlet.HttpContextLifecycle;
-import org.jboss.weld.servlet.spi.helpers.AcceptingHttpContextActivationFilter;
-import org.jglue.cdiunit.internal.CdiUnitInitialListenerImpl;
-import org.jglue.cdiunit.internal.servlet.LifecycleAwareRequest;
-
-/**
- * @author jsarman
- */
-@ApplicationScoped
-public class ContextManager
-{
- private HttpServletRequest currentRequest;
-
- @Inject
- private BeanManager beanManager;
-
- private HttpContextLifecycle lifecycle;
-
- private HttpSession currentSession;
-
- @PostConstruct
- public void setup()
- {
- try
- {
- lifecycle = new HttpContextLifecycle(BeanManagerProxy.unwrap(beanManager),
- AcceptingHttpContextActivationFilter.INSTANCE, true, true, false, true);
- }
- catch (NoSuchMethodError e)
- {
- try
- {
- lifecycle = HttpContextLifecycle.class.getConstructor(BeanManager.class,
- AcceptingHttpContextActivationFilter.class).newInstance(
- BeanManagerProxy.unwrap(beanManager),
- AcceptingHttpContextActivationFilter.INSTANCE);
- }
- catch (Exception e1)
- {
- throw new RuntimeException(e1);
- }
- }
- lifecycle.setConversationActivationEnabled(true);
- }
-
- public void activateContexts(HttpServletRequest request)
- {
- if (currentRequest != null)
- return;
-
- currentRequest = new LifecycleAwareRequest(new CdiUnitInitialListenerImpl(), request);
- lifecycle.requestInitialized(currentRequest, null);
- }
-
- public void deactivateContexts()
- {
- lifecycle.requestDestroyed(currentRequest);
- currentSession = currentRequest.getSession(false);
- currentRequest = null;
- }
-
- public void destroy()
- {
- if (currentRequest != null)
- {
- currentSession = currentRequest.getSession(false);
- }
-
- if (currentSession != null)
- {
- lifecycle.sessionDestroyed(currentSession);
- currentSession = null;
- }
- }
-
- public boolean isRequestActive()
- {
- return currentRequest != null;
- }
-}
[2/3] wicket git commit: WICKET-6581 Module wicket-cdi-1.1 migrated
to CDI 2 and name changed to wicket-cdi. Solved dependecy problems with weld
versions.
Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ConversationPropagatorTest.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ConversationPropagatorTest.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ConversationPropagatorTest.java
deleted file mode 100644
index 945c9cf..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ConversationPropagatorTest.java
+++ /dev/null
@@ -1,202 +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.Conversation;
-import javax.inject.Inject;
-
-import org.apache.wicket.cdi.testapp.TestConversationPage;
-import org.apache.wicket.cdi.testapp.TestConversationalPage;
-import org.apache.wicket.core.request.mapper.MountedMapper;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-
-/**
- * @author jsarman
- */
-public class ConversationPropagatorTest extends WicketCdiTestCase
-{
- @Inject
- Conversation conversation;
-
- @Test
- public void testAutoConversationNonBookmarkable()
- {
- configure(new CdiConfiguration());
-
- tester.startPage(TestConversationalPage.class);
- int i;
- for (i = 0; i < 3; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- tester.clickLink("next");
- for (; i < 6; i++)
- {
- tester.clickLink("increment");
- tester.assertCount(1);
- }
- }
-
- @Test
- public void testAutoConversationBookmarkable()
- {
- configure(new CdiConfiguration());
-
- tester.startPage(TestConversationalPage.class,
- new PageParameters().add("pageType", "bookmarkable"));
-
- int i;
- for (i = 0; i < 3; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- tester.clickLink("next");
- for (i = 0; i < 3; i++)
- {
- tester.clickLink("increment");
- tester.assertCount(1);
- }
- }
-
- @Test
- public void testPropagationAllNonBookmarkable()
- {
- configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
-
- tester.startPage(TestConversationPage.class);
- int i;
- for (i = 0; i < 3; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- tester.clickLink("next");
- for (; i < 6; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- }
-
- @Test
- public void testPropagationAllHybrid()
- {
- configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
- tester.getApplication().getRootRequestMapperAsCompound().add(new MountedMapper("segment/${pageType}", TestConversationPage.class));
-
- tester.startPage(TestConversationPage.class, new PageParameters().add("pageType", "hybrid"));
-
- int i;
- for (i = 0; i < 3; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- tester.clickLink("next");
- for (; i < 6; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- }
-
- /**
- * https://issues.apache.org/jira/browse/WICKET-6257
- */
- @Test
- public void testPropagationAllHybridRefresh()
- {
- configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
- tester.getApplication().getRootRequestMapperAsCompound().add(new MountedMapper("segment/${pageType}", TestConversationPage.class));
-
- tester.startPage(TestConversationPage.class, new PageParameters().add("pageType", "hybrid"));
-
- String pageId = tester.getLastRenderedPage().getId();
- String cid = conversation.getId();
-
- tester.executeUrl("segment/hybrid?"+pageId+"&cid="+cid);
-
- assertThat(tester.getLastRenderedPage().getId(), CoreMatchers.is(pageId));
- }
-
- @Test
- public void testPropagationAllBookmarkable()
- {
- configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
-
- tester.startPage(TestConversationPage.class,
- new PageParameters().add("pageType", "bookmarkable"));
- int i;
- for (i = 0; i < 3; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- tester.clickLink("next");
- for (; i < 6; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- }
-
- @Test
- public void testPropagationNonBookmarkable()
- {
- configure(new CdiConfiguration());
-
- tester.startPage(TestConversationPage.class,
- new PageParameters().add("pageType", "bookmarkable"));
- int i;
- for (i = 0; i < 3; i++)
- {
- tester.assertCount(i);
- tester.clickLink("increment");
- }
- tester.clickLink("next");
- for (; i < 6; i++)
- {
- tester.clickLink("increment");
- tester.assertCount(1);
- }
- }
-
- @Test
- public void testPropagationNone()
- {
- configure(new CdiConfiguration().setPropagation(ConversationPropagation.NONE));
-
- tester.startPage(TestConversationPage.class);
- int i;
- for (i = 0; i < 3; i++)
- {
- tester.clickLink("increment");
- tester.assertCount(1);
- }
- tester.clickLink("next");
- for (; i < 6; i++)
- {
- tester.clickLink("increment");
- tester.assertCount(1);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
deleted file mode 100644
index 3f82075..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/WicketCdiTestCase.java
+++ /dev/null
@@ -1,185 +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.inject.Inject;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.ThreadContext;
-import org.apache.wicket.behavior.AbstractAjaxBehavior;
-import org.apache.wicket.cdi.testapp.TestAppScope;
-import org.apache.wicket.cdi.testapp.TestCdiApplication;
-import org.apache.wicket.cdi.testapp.TestConversationBean;
-import org.apache.wicket.mock.MockApplication;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.tester.WicketTester;
-import org.jglue.cdiunit.AdditionalClasses;
-import org.jglue.cdiunit.CdiRunner;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-
-/**
- * @author jsarman
- */
-@RunWith(CdiRunner.class)
-@AdditionalClasses({ CdiWicketTester.class, BehaviorInjector.class, CdiConfiguration.class,
- CdiShutdownCleaner.class, ComponentInjector.class, ConversationExpiryChecker.class,
- ConversationPropagator.class, DetachEventEmitter.class, SessionInjector.class,
- TestAppScope.class, TestConversationBean.class, TestCdiApplication.class,
- AutoConversation.class })
-public abstract class WicketCdiTestCase extends Assert
-{
- @Inject
- private ContextManager contextManager;
- /** */
- protected CdiWicketTester tester;
-
- protected CdiWicketTester newWicketTester(WebApplication app)
- {
- return new CdiWicketTester(app);
- }
-
- public void configure(CdiConfiguration configuration)
- {
- configuration.configure(tester.getApplication());
- }
-
- @After
- public void end()
- {
- if (contextManager.isRequestActive())
- {
- contextManager.deactivateContexts();
- contextManager.destroy();
- }
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Before
- public void commonBefore()
- {
- // make sure no leaked threadlocals are present
- ThreadContext.detach();
-
- WebApplication application = newApplication();
- tester = newWicketTester(application);
- }
-
- /**
- * @return the application that should be used for the test
- */
- protected WebApplication newApplication()
- {
- return new MockApplication();
- }
-
- /**
- *
- */
- @After
- public void commonAfter()
- {
- tester.destroy();
- }
-
- /**
- * Use <code>-Dwicket.replace.expected.results=true</code> to automatically
- * replace the expected output file.
- *
- * @param <T>
- *
- * @param pageClass
- * @param filename
- * @throws Exception
- */
- protected <T extends Page> void executeTest(final Class<T> pageClass, final String filename)
- throws Exception
- {
- tester.executeTest(getClass(), pageClass, filename);
- }
-
- /**
- * Use <code>-Dwicket.replace.expected.results=true</code> to automatically
- * replace the expected output file.
- *
- * @param page
- * @param filename
- * @throws Exception
- */
- protected void executeTest(final Page page, final String filename) throws Exception
- {
- tester.executeTest(getClass(), page, filename);
- }
-
- /**
- * Use <code>-Dwicket.replace.expected.results=true</code> to automatically
- * replace the expected output file.
- *
- * @param <T>
- *
- * @param pageClass
- * @param parameters
- * @param filename
- * @throws Exception
- */
- protected <T extends Page> void executeTest(final Class<T> pageClass,
- PageParameters parameters, final String filename) throws Exception
- {
- tester.executeTest(getClass(), pageClass, parameters, filename);
- }
-
- /**
- *
- * @param component
- * @param filename
- * @throws Exception
- */
- protected void executeListener(final Component component, final String filename)
- throws Exception
- {
- tester.executeListener(getClass(), component, filename);
- }
-
- /**
- *
- * @param behavior
- * @param filename
- * @throws Exception
- */
- protected void executeBehavior(final AbstractAjaxBehavior behavior, final String filename)
- throws Exception
- {
- tester.executeBehavior(getClass(), behavior, filename);
- }
-
- /**
- * Returns the current Maven build directory taken from the <tt>basedir</tt>
- * system property, or null if not set
- *
- * @return path with a trailing slash
- */
- public String getBasedir()
- {
- return WicketTester.getBasedir();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestAppScope.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestAppScope.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestAppScope.java
deleted file mode 100644
index b36f8a7..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestAppScope.java
+++ /dev/null
@@ -1,40 +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.testapp;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Produces;
-
-/**
- * @author jsarman
- */
-@ApplicationScoped
-public class TestAppScope
-{
-
- public String test()
- {
- return "Test ok";
- }
-
- public @Produces
- @TestQualifier
- String testString()
- {
- return "Test String";
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
deleted file mode 100644
index 7b82203..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestApplication.java
+++ /dev/null
@@ -1,39 +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.testapp;
-
-import org.apache.wicket.Page;
-import org.apache.wicket.protocol.http.WebApplication;
-
-/**
- * @author jsarman
- */
-public class TestApplication extends WebApplication
-{
-
- @Override
- public Class<? extends Page> getHomePage()
- {
- return TestPage.class;
- }
-
- @Override
- protected void init()
- {
- super.init();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
deleted file mode 100644
index 1bd8656..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java
+++ /dev/null
@@ -1,54 +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.testapp;
-
-import javax.inject.Inject;
-
-import org.apache.wicket.Page;
-import org.apache.wicket.cdi.CdiConfiguration;
-import org.apache.wicket.protocol.http.WebApplication;
-
-/**
- * @author jsarman
- */
-public class TestCdiApplication extends WebApplication
-{
-
- @Inject
- @TestQualifier
- String testString;
-
-
- @Override
- public Class<? extends Page> getHomePage()
- {
- return TestPage.class;
- }
-
- @Override
- protected void init()
- {
- super.init();
- new CdiConfiguration().configure(this);
- }
-
- public String getInjectedTestString()
- {
- return testString;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationBean.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationBean.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationBean.java
deleted file mode 100644
index 140ecdb..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationBean.java
+++ /dev/null
@@ -1,56 +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.testapp;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.enterprise.context.ConversationScoped;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author jsarman
- */
-@ConversationScoped
-public class TestConversationBean implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- private static final Logger logger = LoggerFactory.getLogger(TestConversationBean.class);
-
- private AtomicInteger counter = new AtomicInteger();
-
- public int getCount()
- {
- logger.debug("Count = {}", counter.get());
- return counter.get();
- }
-
- public String getCountStr()
- {
- return "COUNT=x" + getCount() + "x";
- }
-
- public void increment()
- {
-
- counter.incrementAndGet();
-
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.html
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.html b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.html
deleted file mode 100644
index e7f3de7..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:wicket>
-<head>
- <title></title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-</head>
-<body>
-<span wicket:id="count">100</span>
-<a wicket:id="increment">increment</a>
-<a wicket:id="next">Reset</a>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.java
deleted file mode 100644
index c6cc8bc..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationPage.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.cdi.testapp;
-
-import javax.enterprise.context.Conversation;
-import javax.inject.Inject;
-
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-
-/**
- * @author jsarman
- */
-public class TestConversationPage extends WebPage
-{
- private static final long serialVersionUID = 1L;
-
- @Inject
- Conversation conversation;
-
- @Inject
- TestConversationBean counter;
-
- public TestConversationPage()
- {
- this(new PageParameters());
- }
-
- public TestConversationPage(final PageParameters parameters)
- {
- super(parameters);
-
- conversation.begin();
- System.out.println("Opened Conversion with id = " + conversation.getId());
-
- add(new Label("count", new PropertyModel<String>(this, "counter.countStr")));
-
- add(new Link<Void>("increment")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick()
- {
- counter.increment();
- }
- });
- add(new Link<Void>("next")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick()
- {
- String pageType = parameters.get("pageType").toString("nonbookmarkable");
- if ("bookmarkable".equals(pageType.toLowerCase()))
- setResponsePage(TestNonConversationalPage.class);
- else if ("hybrid".equals(pageType.toLowerCase()))
- setResponsePage(TestConversationPage.this);
- else
- setResponsePage(new TestNonConversationalPage());
- }
- });
-
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
deleted file mode 100644
index b3550f1..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:wicket>
-<head>
- <title></title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-</head>
-<body>
-<span wicket:id="count">100</span>
-<a wicket:id="increment">increment</a>
-<a wicket:id="next">next</a>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java
deleted file mode 100644
index 5e41fd5..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java
+++ /dev/null
@@ -1,78 +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.testapp;
-
-import javax.inject.Inject;
-
-import org.apache.wicket.cdi.ConversationalComponent;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author jsarman
- */
-public class TestConversationalPage extends WebPage implements ConversationalComponent
-{
- private static final long serialVersionUID = 1L;
-
- private static final Logger logger = LoggerFactory.getLogger(TestConversationPage.class);
- @Inject
- TestConversationBean counter;
-
- public TestConversationalPage()
- {
- this(new PageParameters());
- }
-
-
- public TestConversationalPage(final PageParameters pp)
- {
- logger.debug("Starting TestConversationalPage");
-
- add(new Label("count", new PropertyModel<String>(this, "counter.countStr")));
-
- add(new Link<Void>("increment")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick()
- {
- counter.increment();
- }
- });
- add(new Link<Void>("next")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick()
- {
- String pageType = pp.get("pageType").toString("nonbookmarkable");
- if ("bookmarkable".equals(pageType.toLowerCase()))
- setResponsePage(TestNonConversationalPage.class);
- else
- setResponsePage(new TestNonConversationalPage());
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
deleted file mode 100644
index fd58f2d..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:wicket>
-<head>
- <title></title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-</head>
-<body>
-<span wicket:id="count">100</span>
-<a wicket:id="increment">increment</a>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.java
deleted file mode 100644
index 7728e81..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestNonConversationalPage.java
+++ /dev/null
@@ -1,55 +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.testapp;
-
-import javax.inject.Inject;
-
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.model.PropertyModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * @author jsarman
- */
-public class TestNonConversationalPage extends WebPage
-{
- private static final long serialVersionUID = 1L;
- private static final Logger logger = LoggerFactory.getLogger(TestConversationPage.class);
- @Inject
- TestConversationBean counter;
-
- public TestNonConversationalPage()
- {
- logger.debug("Starting TestConversationalPage");
- add(new Label("count", new PropertyModel<String>(this, "counter.countStr")));
-
- add(new Link<Void>("increment")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick()
- {
- counter.increment();
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestPage.html
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestPage.html b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestPage.html
deleted file mode 100644
index 4689c49..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestPage.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:wicket>
-<head>
- <title></title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-</head>
-<body>
-<div wicket:id="appscope">Fail</div>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestPage.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestPage.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestPage.java
deleted file mode 100644
index cf5108b..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestPage.java
+++ /dev/null
@@ -1,40 +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.testapp;
-
-import javax.inject.Inject;
-
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.basic.Label;
-
-/**
- * @author jsarman
- */
-public class TestPage extends WebPage
-{
- private static final long serialVersionUID = 1L;
-
- @Inject
- TestAppScope appScope;
-
- public TestPage()
- {
-
- add(new Label("appscope", appScope.test()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestQualifier.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestQualifier.java b/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestQualifier.java
deleted file mode 100644
index dcd0289..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/testapp/TestQualifier.java
+++ /dev/null
@@ -1,35 +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.testapp;
-
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * @author jsarman
- */
-@Qualifier
-@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface TestQualifier {
-
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi-1.1/src/test/java/simplelogger.properties
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/test/java/simplelogger.properties b/wicket-cdi-1.1/src/test/java/simplelogger.properties
deleted file mode 100644
index 17c5fe6..0000000
--- a/wicket-cdi-1.1/src/test/java/simplelogger.properties
+++ /dev/null
@@ -1 +0,0 @@
-org.slf4j.simpleLogger.log.org.apache.wicket.cdi=info
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-cdi/pom.xml b/wicket-cdi/pom.xml
index a0cf977..29de4bb 100644
--- a/wicket-cdi/pom.xml
+++ b/wicket-cdi/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>wicket-cdi</artifactId>
<packaging>bundle</packaging>
- <name>Wicket CDI Integration</name>
+ <name>Wicket CDI</name>
<description>
Provides integration between Wicket and CDI containers. Enables injection of
components and behaviors, as well as other non-contextual object instances.
@@ -55,12 +55,41 @@
<artifactId>wicket-core</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-core-impl</artifactId>
+ <groupId>org.jboss.weld.module</groupId>
+ <artifactId>weld-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld.se</groupId>
+ <artifactId>weld-se-core</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jglue.cdi-unit</groupId>
+ <artifactId>cdi-unit</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>org.jboss.spec.javax.annotation</artifactId>
+ <groupId>jboss-annotations-api_1.2_spec</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
index b77aa6e..cf8d67f 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
@@ -16,8 +16,6 @@
*/
package org.apache.wicket.cdi;
-import org.apache.wicket.util.lang.Args;
-
/**
* Base class for injectors
*
@@ -25,21 +23,17 @@ import org.apache.wicket.util.lang.Args;
*/
class AbstractInjector
{
- private final CdiContainer container;
-
- public AbstractInjector(CdiContainer container)
+ public AbstractInjector()
{
- Args.notNull(container, "container");
- this.container = container;
}
protected <T> void postConstruct(T instance)
{
- container.getNonContextualManager().postConstruct(instance);
+ NonContextual.of(instance).postConstruct(instance);
}
protected <T> void inject(T instance)
{
- container.getNonContextualManager().inject(instance);
+ NonContextual.of(instance).inject(instance);
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversation.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversation.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversation.java
index 0193a7d..90f5e19 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversation.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversation.java
@@ -21,15 +21,16 @@ import javax.enterprise.context.ConversationScoped;
import org.apache.wicket.util.io.IClusterable;
/**
- * A bean that can be used to override whether the lifecycle of the conversation should be managed
- * automatically or not. See {@link CdiConfiguration#setAutoConversationManagement(boolean)} for
- * details.
+ * A bean that can be used to override whether the lifecycle of the conversation
+ * should be managed automatically or not.
*
* @author igor
*/
@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/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
new file mode 100644
index 0000000..4aedb48
--- /dev/null
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
@@ -0,0 +1,121 @@
+/*
+ * 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.Conversation;
+import javax.inject.Inject;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.application.IComponentOnBeforeRenderListener;
+import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.util.visit.IVisit;
+import org.apache.wicket.util.visit.IVisitor;
+import org.apache.wicket.util.visit.Visits;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Automatically starts and ends conversations for pages with a
+ * {@link ConversationalComponent}.
+ *
+ * @author papegaaij
+ */
+public class AutoConversationManager implements IComponentOnBeforeRenderListener
+{
+ private static final Logger logger = LoggerFactory.getLogger(AutoConversationManager.class);
+
+ @Inject
+ private Conversation conversation;
+
+ @Inject
+ private AutoConversation autoConversation;
+
+ private IConversationPropagation propagation;
+
+ public AutoConversationManager(IConversationPropagation propagation)
+ {
+ NonContextual.of(AutoConversationManager.class).inject(this);
+ this.propagation = propagation;
+ }
+
+ @Override
+ public void onBeforeRender(Component component)
+ {
+ if (component instanceof Page)
+ {
+ Page page = (Page)component;
+ IRequestHandler activeRequestHandler = page.getRequestCycle().getActiveRequestHandler();
+ autoEndIfNecessary(page, activeRequestHandler);
+ autoBeginIfNecessary(page, activeRequestHandler);
+ }
+ }
+
+ protected void autoBeginIfNecessary(Page page, IRequestHandler handler)
+ {
+ if (conversation == null || !conversation.isTransient() || page == null
+ || !hasConversationalComponent(page) || !propagation.propagatesVia(handler, page))
+ {
+ return;
+ }
+
+ // auto activate conversation
+
+ conversation.begin();
+ autoConversation.setAutomatic(true);
+
+ logger.debug("Auto-began conversation '{}' for page '{}'", conversation.getId(), page);
+ }
+
+ protected void autoEndIfNecessary(Page page, IRequestHandler handler)
+ {
+ if (conversation == null || conversation.isTransient() || page == null
+ || hasConversationalComponent(page) || !propagation.propagatesVia(handler, page)
+ || autoConversation.isAutomatic() == false)
+ {
+ return;
+ }
+
+ // auto de-activate conversation
+
+ String cid = conversation.getId();
+
+ autoConversation.setAutomatic(false);
+ conversation.end();
+ ConversationPropagator.removeConversationIdFromPage(page);
+
+ logger.debug("Auto-ended conversation '{}' for page '{}'", cid, page);
+ }
+
+ protected boolean hasConversationalComponent(Page page)
+ {
+ Boolean hasConversational = Visits.visit(page, new IVisitor<Component, Boolean>()
+ {
+ @Override
+ public void component(Component object, IVisit<Boolean> visit)
+ {
+ if (object instanceof ConversationalComponent)
+ {
+ visit.stop(true);
+ }
+ }
+ });
+
+ return hasConversational == null ? false : hasConversational;
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java
new file mode 100644
index 0000000..f44e513
--- /dev/null
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/BeanManagerLookup.java
@@ -0,0 +1,128 @@
+/*
+ * 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.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.CDI;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.wicket.Application;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Defines several strategies for looking up a CDI BeanManager in a portable
+ * way. The following strategies are tried (in order):
+ * <ul>
+ * <li>JNDI under java:comp/BeanManager (default location)</li>
+ * <li>JNDI under java:comp/env/BeanManager (for servlet containers like Tomcat
+ * and Jetty)</li>
+ * <li>CDI.current().getBeanManager() (portable lookup)</li>
+ * <li>{@linkplain CdiConfiguration#getFallbackBeanManager() Fallback}</li>
+ * </ul>
+ *
+ * The last successful lookup strategy is saved and tried first next time.
+ *
+ * @author papegaaij
+ */
+public final class BeanManagerLookup
+{
+ private static final Logger log = LoggerFactory.getLogger(BeanManagerLookup.class);
+
+ private enum BeanManagerLookupStrategy {
+ JNDI {
+ @Override
+ public BeanManager lookup()
+ {
+ try
+ {
+ return InitialContext.doLookup("java:comp/BeanManager");
+ }
+ catch (NamingException e)
+ {
+ return null;
+ }
+ }
+ },
+ JNDI_ENV {
+ @Override
+ public BeanManager lookup()
+ {
+ try
+ {
+ return InitialContext.doLookup("java:comp/env/BeanManager");
+ }
+ catch (NamingException e)
+ {
+ return null;
+ }
+ }
+ },
+ CDI_PROVIDER {
+ @Override
+ public BeanManager lookup()
+ {
+ try
+ {
+ return CDI.current().getBeanManager();
+ }
+ catch (Exception e)
+ {
+ log.debug(e.getMessage(), e);
+ return null;
+ }
+ }
+ },
+ FALLBACK {
+ @Override
+ public BeanManager lookup()
+ {
+ return CdiConfiguration.get(Application.get()).getFallbackBeanManager();
+ }
+ };
+
+ public abstract BeanManager lookup();
+ }
+
+ private static BeanManagerLookupStrategy lastSuccessful = BeanManagerLookupStrategy.JNDI;
+
+ private BeanManagerLookup()
+ {
+ }
+
+ public static BeanManager lookup()
+ {
+ BeanManager ret = lastSuccessful.lookup();
+ if (ret != null)
+ return ret;
+
+ for (BeanManagerLookupStrategy curStrategy : BeanManagerLookupStrategy.values())
+ {
+ ret = curStrategy.lookup();
+ if (ret != null)
+ {
+ lastSuccessful = curStrategy;
+ return ret;
+ }
+ }
+
+ throw new IllegalStateException(
+ "No BeanManager found via the CDI provider and no fallback specified. Check your "
+ + "CDI setup or specify a fallback BeanManager in the CdiConfiguration.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java
index 0ba6219..15979f6 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/BehaviorInjector.java
@@ -25,16 +25,13 @@ import org.apache.wicket.behavior.Behavior;
* @author igor
*
*/
-class BehaviorInjector extends AbstractInjector implements IBehaviorInstantiationListener
+public class BehaviorInjector extends AbstractInjector implements IBehaviorInstantiationListener
{
/**
* Constructor
- *
- * @param container
*/
- public BehaviorInjector(CdiContainer container)
+ public BehaviorInjector()
{
- super(container);
}
@Override
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
index ad369a1..30778aa 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
@@ -19,8 +19,8 @@ package org.apache.wicket.cdi;
import javax.enterprise.inject.spi.BeanManager;
import org.apache.wicket.Application;
+import org.apache.wicket.MetaDataKey;
import org.apache.wicket.request.cycle.RequestCycleListenerCollection;
-import org.apache.wicket.util.lang.Args;
/**
* Configures CDI integration
@@ -30,37 +30,20 @@ import org.apache.wicket.util.lang.Args;
*/
public class CdiConfiguration
{
- private BeanManager beanManager;
+ private static final MetaDataKey<CdiConfiguration> CDI_CONFIGURATION_KEY = new MetaDataKey<CdiConfiguration>()
+ {
+ private static final long serialVersionUID = 1L;
+ };
+
private IConversationPropagation propagation = ConversationPropagation.NONBOOKMARKABLE;
- private INonContextualManager nonContextualManager;
- private boolean injectComponents = true;
- private boolean injectApplication = true;
- private boolean injectSession = true;
- private boolean injectBehaviors = true;
- private boolean autoConversationManagement = false;
+ private BeanManager fallbackBeanManager;
/**
* Constructor
- *
- * @param beanManager
- */
- public CdiConfiguration(BeanManager beanManager)
- {
- Args.notNull(beanManager, "beanManager");
-
- this.beanManager = beanManager;
- nonContextualManager = new NonContextualManager(beanManager);
- }
-
- /**
- * Gets the configured bean manager
- *
- * @return bean manager or {@code null} if none
*/
- public BeanManager getBeanManager()
+ public CdiConfiguration()
{
- return beanManager;
}
public IConversationPropagation getPropagation()
@@ -68,96 +51,31 @@ public class CdiConfiguration
return propagation;
}
- /**
- * Checks if auto conversation management is enabled. See
- * {@link #setAutoConversationManagement(boolean)} for details.
- */
- public boolean isAutoConversationManagement()
- {
- return autoConversationManagement;
- }
-
- /**
- * Toggles automatic conversation management feature.
- *
- * Automatic conversation management controls the lifecycle of the conversation based on
- * presence of components implementing the {@link ConversationalComponent} interface. If such
- * components are found in the page a conversation is marked persistent, and if they are not the
- * conversation is marked transient. This greatly simplifies the management of conversation
- * lifecycle.
- *
- * Sometimes it is necessary to manually control the application. For these cases, once a
- * conversation is started {@link AutoConversation} bean can be used to mark the conversation as
- * manually-managed.
- *
- * @param enabled
- *
- * @return {@code this} for easy chaining
- */
- public CdiConfiguration setAutoConversationManagement(boolean enabled)
- {
- autoConversationManagement = enabled;
- return this;
- }
-
public CdiConfiguration setPropagation(IConversationPropagation propagation)
{
this.propagation = propagation;
return this;
}
- public INonContextualManager getNonContextualManager()
- {
- return nonContextualManager;
- }
-
- public CdiConfiguration setNonContextualManager(INonContextualManager nonContextualManager)
- {
- this.nonContextualManager = nonContextualManager;
- return this;
- }
-
- public boolean isInjectComponents()
- {
- return injectComponents;
- }
-
- public CdiConfiguration setInjectComponents(boolean injectComponents)
- {
- this.injectComponents = injectComponents;
- return this;
- }
-
- public boolean isInjectApplication()
- {
- return injectApplication;
- }
-
- public CdiConfiguration setInjectApplication(boolean injectApplication)
- {
- this.injectApplication = injectApplication;
- return this;
- }
-
- public boolean isInjectSession()
+ public BeanManager getFallbackBeanManager()
{
- return injectSession;
+ return fallbackBeanManager;
}
- public CdiConfiguration setInjectSession(boolean injectSession)
- {
- this.injectSession = injectSession;
- return this;
- }
-
- public boolean isInjectBehaviors()
- {
- return injectBehaviors;
- }
-
- public CdiConfiguration setInjectBehaviors(boolean injectBehaviors)
+ /**
+ * Sets a BeanManager that should be used if all strategies to lookup a
+ * BeanManager fail. This can be used in scenarios where you do not have
+ * JNDI available and do not want to bootstrap the CDI provider. It should
+ * be noted that the fallback BeanManager can only be used within the
+ * context of a Wicket application (ie. Application.get() should return the
+ * application that was configured with this CdiConfiguration).
+ *
+ * @param fallbackBeanManager
+ * @return this instance
+ */
+ public CdiConfiguration setFallbackBeanManager(BeanManager fallbackBeanManager)
{
- this.injectBehaviors = injectBehaviors;
+ this.fallbackBeanManager = fallbackBeanManager;
return this;
}
@@ -165,18 +83,14 @@ public class CdiConfiguration
* Configures the specified application
*
* @param application
- * @return The CdiContainer
*/
- public CdiContainer configure(Application application)
+ public void configure(Application application)
{
- if (beanManager == null)
+ if (application.getMetaData(CDI_CONFIGURATION_KEY) != null)
{
- throw new IllegalStateException(
- "Configuration does not have a BeanManager instance configured");
+ throw new IllegalStateException("Cdi already configured for this application");
}
-
- CdiContainer container = new CdiContainer(beanManager, nonContextualManager);
- container.bind(application);
+ application.setMetaData(CDI_CONFIGURATION_KEY, this);
RequestCycleListenerCollection listeners = new RequestCycleListenerCollection();
application.getRequestCycleListeners().add(listeners);
@@ -184,45 +98,29 @@ public class CdiConfiguration
// enable conversation propagation
if (getPropagation() != ConversationPropagation.NONE)
{
- listeners.add(new ConversationPropagator(application, container, getPropagation(),
- autoConversationManagement));
+ listeners.add(new ConversationPropagator(application, getPropagation()));
+ application.getComponentPreOnBeforeRenderListeners().add(
+ new AutoConversationManager(getPropagation()));
application.getComponentPreOnBeforeRenderListeners().add(
- new ConversationExpiryChecker(container));
+ new ConversationExpiryChecker());
}
// enable detach event
- listeners.add(new DetachEventEmitter(container));
-
+ listeners.add(new DetachEventEmitter());
- // inject application instance
- if (isInjectApplication())
- {
- container.getNonContextualManager().postConstruct(application);
- }
+ NonContextual.of(application).postConstruct(application);
// enable injection of various framework components
-
- if (isInjectSession())
- {
- application.getSessionListeners().add(new SessionInjector(container));
- }
-
- if (isInjectComponents())
- {
- application.getComponentInstantiationListeners().add(new ComponentInjector(container));
- }
-
- if (isInjectBehaviors())
- {
- application.getBehaviorInstantiationListeners().add(new BehaviorInjector(container));
- }
+ application.getSessionListeners().add(new SessionInjector());
+ application.getComponentInstantiationListeners().add(new ComponentInjector());
+ application.getBehaviorInstantiationListeners().add(new BehaviorInjector());
// enable cleanup
-
- application.getApplicationListeners().add(
- new CdiShutdownCleaner(beanManager, isInjectApplication()));
-
- return container;
+ application.getApplicationListeners().add(new CdiShutdownCleaner());
}
+ public static CdiConfiguration get(Application application)
+ {
+ return application.getMetaData(CDI_CONFIGURATION_KEY);
+ }
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiContainer.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiContainer.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiContainer.java
deleted file mode 100644
index 168588d..0000000
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiContainer.java
+++ /dev/null
@@ -1,167 +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.inject.spi.BeanManager;
-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;
-import org.jboss.weld.Container;
-import org.jboss.weld.context.http.HttpConversationContext;
-
-/**
- * Provides access to CDI features from inside a Wicket request
- *
- * @author igor
- *
- */
-public class CdiContainer
-{
- private static final MetaDataKey<CdiContainer> CONTEXT_KEY = new MetaDataKey<CdiContainer>()
- {
- private static final long serialVersionUID = 1L;
- };
-
- protected final BeanManager beanManager;
- private final HttpConversationContext conversationContext;
- private final INonContextualManager nonContextualManager;
-
- /**
- * Constructor
- *
- * @param beanManager
- * bean manager
- */
- public CdiContainer(BeanManager beanManager, INonContextualManager nonContextualManager)
- {
- Args.notNull(beanManager, "beanManager");
- Args.notNull(nonContextualManager, "nonContextualManager");
-
- this.beanManager = beanManager;
- this.nonContextualManager = nonContextualManager;
-
- conversationContext = Container.instance().deploymentManager().instance().select(HttpConversationContext.class).get();
- if (conversationContext == null)
- {
- throw new IllegalStateException(
- "Could not resolve conversation context manager. Make sure a Seam-Conversation module for your CDI container implementation is included in your dependencies.");
- }
- }
-
- public INonContextualManager getNonContextualManager()
- {
- return nonContextualManager;
- }
-
- /**
- * Deactivates conversational context
- *
- * @param cycle
- */
- public void deactivateConversationalContext(RequestCycle cycle)
- {
- conversationContext.deactivate();
- conversationContext.dissociate(getRequest(cycle));
- }
-
- /**
- * Activates the conversational context and starts the conversation with the specified cid
- *
- * @param cycle
- * @param cid
- */
- public void activateConversationalContext(RequestCycle cycle, String cid)
- {
- conversationContext.associate(getRequest(cycle));
- conversationContext.activate(cid);
- }
-
- private 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)
- {
- application.setMetaData(CONTEXT_KEY, this);
- }
-
- /**
- * Retrieves container instance stored in the application
- *
- * @param application
- * @return container instance or {@code null} if none
- */
- public static final CdiContainer get(Application application)
- {
- CdiContainer 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 final CdiContainer get()
- {
- return get(Application.get());
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java
index aa219da..25c29dd 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/CdiShutdownCleaner.java
@@ -16,11 +16,8 @@
*/
package org.apache.wicket.cdi;
-import javax.enterprise.inject.spi.BeanManager;
-
import org.apache.wicket.Application;
import org.apache.wicket.IApplicationListener;
-import org.apache.wicket.util.lang.Args;
/**
* Listens to application shutdown and cleans up
@@ -29,25 +26,14 @@ import org.apache.wicket.util.lang.Args;
*/
class CdiShutdownCleaner implements IApplicationListener
{
- private final BeanManager beanManager;
- private final boolean preDestroyApplication;
-
- public CdiShutdownCleaner(BeanManager beanManager, boolean preDestroyApplication)
+ public CdiShutdownCleaner()
{
- Args.notNull(beanManager, "beanManager");
-
- this.beanManager = beanManager;
- this.preDestroyApplication = preDestroyApplication;
}
@Override
public void onBeforeDestroyed(Application application)
{
- if (preDestroyApplication)
- {
- NonContextual.of(application, beanManager).preDestroy(application);
- }
- NonContextual.undeploy(beanManager);
+ NonContextual.of(application).preDestroy(application);
+ NonContextual.undeploy();
}
-
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
index bc302ef..65a4879 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
@@ -29,12 +29,9 @@ class ComponentInjector extends AbstractInjector implements IComponentInstantiat
{
/**
* Constructor
- *
- * @param container
*/
- public ComponentInjector(CdiContainer container)
+ public ComponentInjector()
{
- super(container);
}
@Override
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
index 7993ae4..16df7b1 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiredException.java
@@ -21,12 +21,13 @@ 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;
public ConversationExpiredException(Throwable cause, String cid, Page page,
- IRequestHandler handler)
+ IRequestHandler handler)
{
super(cause);
this.cid = cid;
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
index 8881485..3e2bc94 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationExpiryChecker.java
@@ -30,10 +30,12 @@ import org.slf4j.LoggerFactory;
/**
* Checks for conversation expiration during page render and throws a
- * {@link ConversationExpiredException} when an expired conversation is detected.
+ * {@link ConversationExpiredException} when an expired conversation is
+ * detected.
*
- * For example a link that calls {@link Conversation#end()} but does not redirect to a
- * non-conversation-dependent page will be caught by this listener.
+ * For example a link that calls {@link Conversation#end()} but does not
+ * redirect to a non-conversation-dependent page will be caught by this
+ * listener.
*
* @author igor
*
@@ -41,17 +43,13 @@ import org.slf4j.LoggerFactory;
public class ConversationExpiryChecker implements IComponentOnBeforeRenderListener
{
private static final Logger logger = LoggerFactory.getLogger(ConversationExpiryChecker.class);
-
+
@Inject
private Conversation conversation;
- private final CdiContainer container;
-
- public ConversationExpiryChecker(CdiContainer container)
+ public ConversationExpiryChecker()
{
- this.container = container;
-
- container.getNonContextualManager().inject(this);
+ NonContextual.of(ConversationExpiryChecker.class).inject(this);
}
@Override
@@ -60,12 +58,12 @@ public class ConversationExpiryChecker implements IComponentOnBeforeRenderListen
if (component instanceof Page || RequestCycle.get().find(IPartialPageRequestHandler.class).isPresent())
{
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);
throw new ConversationExpiredException(null, cid, page, RequestCycle.get()
- .getActiveRequestHandler());
+ .getActiveRequestHandler());
}
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationIdMetaKey.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationIdMetaKey.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationIdMetaKey.java
deleted file mode 100644
index 94cc70f..0000000
--- a/wicket-cdi/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/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
index e70ff9c..3c1eb89 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagation.java
@@ -32,45 +32,29 @@ 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)
+ public boolean propagatesVia(IRequestHandler handler, Page page)
{
return false;
}
},
/**
- * Pesistent conversations are propagated between non-bookmarkable pages only
+ * Pesistent conversations are propagated between non-bookmarkable pages
+ * only
*/
NONBOOKMARKABLE {
@Override
- public boolean propagatesViaPage(Page page, IRequestHandler handler)
- {
- return true;
- }
-
- @Override
- public boolean propagatesViaParameters(IRequestHandler handler)
+ public boolean propagatesVia(IRequestHandler handler, Page page)
{
- return false;
+ return page != null;
}
},
/**
- * 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)
+ public boolean propagatesVia(IRequestHandler handler, Page page)
{
return true;
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/057c402b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
index 92f261c..613f6a5 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
@@ -16,38 +16,33 @@
*/
package org.apache.wicket.cdi;
+import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
-import javax.enterprise.context.NonexistentConversationException;
import javax.inject.Inject;
import org.apache.wicket.Application;
-import org.apache.wicket.Component;
import org.apache.wicket.MetaDataKey;
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.IRequestCycleListener;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
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;
+import org.apache.wicket.util.lang.Classes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * A request cycle listener that takes care of propagating persistent conversations.
+ * A request cycle listener that takes care of propagating persistent
+ * conversations.
*
* @see ConversationScoped
*
@@ -57,158 +52,67 @@ public class ConversationPropagator implements IRequestCycleListener
{
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 CdiContainer container;
-
/** propagation mode to use */
private final IConversationPropagation propagation;
private final Application application;
- private final boolean auto;
-
- @Inject
- Conversation conversation_;
-
@Inject
- AutoConversation autoConversation;
-
- /**
- * Constructor
- *
- * @param container
- * @param propagation
- */
- public ConversationPropagator(Application application, CdiContainer container,
- IConversationPropagation propagation)
- {
- this(application, container, propagation, false);
- }
-
+ private Conversation conversation;
/**
* Constructor
*
- * @param container
+ * @param application
* @param propagation
*/
- public ConversationPropagator(Application application, CdiContainer container,
- IConversationPropagation propagation, boolean auto)
+ public ConversationPropagator(Application application, IConversationPropagation propagation)
{
Args.notNull(application, "application");
- Args.notNull(container, "container");
Args.notNull(propagation, "propagation");
if (propagation == ConversationPropagation.NONE)
{
throw new IllegalArgumentException(
- "If propagation is NONE do not set up the propagator");
+ "If propagation is NONE do not set up the propagator");
}
this.application = application;
- this.container = container;
this.propagation = propagation;
- this.auto = auto;
- container.getNonContextualManager().postConstruct(this);
+ 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))
- {
- 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))
+ if (activateForHandler(handler))
{
- return;
- }
-
- logger.debug("Activating conversation {}", cid);
-
- try
- {
- container.activateConversationalContext(cycle, cid);
+ logger.debug("Activating conversation {}", conversation.getId());
fireOnAfterConversationStarted(cycle);
}
- catch (NonexistentConversationException e)
- {
- logger.info("Unable to restore conversation with id {}", cid, e.getMessage());
- logger.debug("Unable to restore conversation", e);
- 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)
@@ -221,93 +125,41 @@ public class ConversationPropagator implements IRequestCycleListener
@Override
public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler)
{
- Conversation conversation = getConversation(cycle);
-
- if (conversation == null)
- {
- return;
- }
-
- Page page = getPage(handler);
-
- if (page == null)
- {
- return;
- }
-
- // apply auto semantics
-
- 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
- public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler)
- {
- // propagate current non-transient conversation to the newly scheduled page
-
- Conversation conversation = getConversation(cycle);
-
- if (conversation == null || conversation.isTransient())
- {
- return;
- }
-
- Page page = getPage(handler);
- if (page != null)
+ // propagate current non-transient conversation to the newly scheduled
+ // page
+ try
{
- if (propagation.propagatesViaPage(page, handler))
+ if (conversation.isTransient())
{
- // propagate a conversation across non-bookmarkable page instances
- setConversationOnPage(conversation, page);
+ return;
}
+ } catch (ContextNotActiveException cnax)
+ {
+ logger.debug("There is no active context for the requested scope!", cnax);
+ return;
}
- if (propagation.propagatesViaParameters(handler))
+ if (propagation.propagatesVia(handler, getPage(handler)))
{
- // propagate cid to a scheduled bookmarkable page
-
logger.debug(
- "Propagating non-transient conversation {} via page parameters of handler {}",
- conversation.getId(), handler);
+ "Propagating non-transient conversation {} via page parameters of handler {}",
+ conversation.getId(), handler);
PageParameters parameters = getPageParameters(handler);
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)
{
- // no need to propagate the conversation to packaged resources, they should never change
+ // no need to propagate the conversation to packaged resources, they
+ // should never change
if (handler instanceof ResourceReferenceRequestHandler)
{
if (((ResourceReferenceRequestHandler)handler).getResourceReference() instanceof PackageResourceReference)
@@ -316,47 +168,41 @@ public class ConversationPropagator implements IRequestCycleListener
}
}
- Conversation conversation = getConversation(cycle);
-
- if (conversation == null || conversation.isTransient())
+ if (conversation.isTransient())
{
return;
}
- if (propagation.propagatesViaParameters(handler))
+ if (propagation.propagatesVia(handler, getPage(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);
}
}
/**
- * Determines whether or not a conversation should be activated fro the specified handler. This
- * method is used to filter out conversation activation for utility handlers such as the
+ * Determines whether or not a conversation should be activated fro the
+ * specified handler. This method is used to filter out conversation
+ * activation for utility handlers such as the
* {@link BufferedResponseRequestHandler}
*
* @param handler
@@ -366,71 +212,45 @@ public class ConversationPropagator implements IRequestCycleListener
{
if (handler != null)
{
+ String handlerClassName = Classes.name(handler.getClass());
+
if (handler instanceof BufferedResponseRequestHandler)
{
// we do not care about pages that are being rendered from a buffer
return false;
+ } else if ("org.apache.wicket.protocol.ws.api.WebSocketMessageBroadcastHandler".equals(handlerClassName))
+ {
+ return false;
+ } else if ("org.apache.wicket.protocol.ws.api.WebSocketRequestHandler".equals(handlerClassName)) {
+ // injection is not supported in web sockets communication
+ return false;
}
}
return true;
}
- protected void autoBeginIfNecessary(Page page, IRequestHandler handler,
- Conversation conversation)
+ public static void markPageWithConversationId(IRequestHandler handler, String cid)
{
- if (!auto || conversation == null || !conversation.isTransient() || page == null ||
- !propagation.propagatesViaPage(page, handler) || !hasConversationalComponent(page))
+ Page page = getPage(handler);
+ if (page != null)
{
- return;
+ page.setMetaData(CONVERSATION_ID_KEY, cid);
}
-
- // auto activate conversation
-
- conversation.begin();
- autoConversation.setAutomatic(true);
-
- logger.debug("Auto-began conversation {} for page {}", conversation.getId(), page);
}
- protected void autoEndIfNecessary(Page page, IRequestHandler handler, Conversation conversation)
+ public static String getConversationIdFromPage(Page page)
{
- if (!auto || conversation == null || conversation.isTransient() || page == null ||
- !propagation.propagatesViaPage(page, handler) || hasConversationalComponent(page) ||
- autoConversation.isAutomatic() == false)
- {
- return;
- }
-
- // auto de-activate conversation
-
- String cid = conversation.getId();
-
- autoConversation.setAutomatic(false);
- conversation.end();
-
- logger.debug("Auto-ended conversation {} for page {}", cid, page);
+ return page.getMetaData(CONVERSATION_ID_KEY);
}
-
- protected boolean hasConversationalComponent(Page page)
+ public static void removeConversationIdFromPage(Page page)
{
- Boolean hasConversational = Visits.visit(page, new IVisitor<Component, Boolean>()
- {
- @Override
- public void component(Component object, IVisit<Boolean> visit)
- {
- if (object instanceof ConversationalComponent)
- {
- visit.stop(true);
- }
- }
- });
-
- return hasConversational == null ? false : hasConversational;
+ page.setMetaData(CONVERSATION_ID_KEY, null);
}
/**
- * Resolves a page instance from the request handler iff the page instance is already created
+ * Resolves a page instance from the request handler iff the page instance
+ * is already created
*
* @param handler
* @return page or {@code null} if none