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/04/16 09:38:08 UTC
[5/7] wicket git commit: Removed wicket-cdi-1.1 and Arquillian testing
http://git-wip-us.apache.org/repos/asf/wicket/blob/9578a8a1/testing/wicket-arquillian/src/test/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/testing/wicket-arquillian/src/test/webapp/WEB-INF/web.xml b/testing/wicket-arquillian/src/test/webapp/WEB-INF/web.xml
deleted file mode 100644
index 54c8105..0000000
--- a/testing/wicket-arquillian/src/test/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,58 +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.
--->
-<!-- JBoss, Home of Professional Open Source Copyright 2013, Red Hat, Inc.
- and/or its affiliates, and individual contributors by the @authors tag. See
- the copyright.txt in the distribution for a full listing of individual contributors.
- Licensed 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. -->
-<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
-
- <display-name>Wicket Arquillian WildFly Quickstart: Wicket TEST WAR</display-name>
-
- <!-- Enable Wicket -->
- <filter>
- <filter-name>WicketTesterFilter</filter-name>
- <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
- <init-param>
- <!-- Specify the "entry point" for Wicket to configure itself from -->
- <param-name>applicationClassName</param-name>
- <param-value>org.apache.wicket.arquillian.testing.TestWicketJavaEEApplication</param-value>
- </init-param>
- </filter>
-
- <!-- Have wicket manage the context root -->
- <filter-mapping>
- <filter-name>WicketTesterFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- A message displayed on the page, externalized into web.xml -->
- <env-entry>
- <env-entry-name>welcomeMessage</env-entry-name>
- <env-entry-type>java.lang.String</env-entry-type>
- <env-entry-value>Welcome to the WildFly Quickstart showing the use of Wicket, packaged in an WAR</env-entry-value>
- </env-entry>
-
-</web-app>
http://git-wip-us.apache.org/repos/asf/wicket/blob/9578a8a1/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 82058a8..0000000
--- a/wicket-cdi-1.1/pom.xml
+++ /dev/null
@@ -1,64 +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>8.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>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jglue.cdi-unit</groupId>
- <artifactId>cdi-unit</artifactId>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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/9578a8a1/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 35bec1b..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/CdiWicketTester.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 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);
- }
-
- /**
- * 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/9578a8a1/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 3e22aef..0000000
--- a/wicket-cdi-1.1/src/test/java/org/apache/wicket/cdi/ContextManager.java
+++ /dev/null
@@ -1,105 +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.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);
- }
- 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(lifecycle, request, currentSession);
- 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/9578a8a1/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/9578a8a1/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();
- }
-}