http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiAdditionApplication.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiAdditionApplication.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiAdditionApplication.java deleted file mode 100644 index 1f8bfed..0000000 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiAdditionApplication.java +++ /dev/null @@ -1,58 +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.annotation.PostConstruct; -import javax.inject.Inject; - -import org.apache.wicket.Page; -import org.apache.wicket.cdi.WicketApp; -import org.apache.wicket.protocol.http.WebApplication; - -/** - * @author jsarman - */ -@WicketApp("test2") -public class TestCdiAdditionApplication extends WebApplication -{ - - @Inject - @TestQualifier - String testString; - - - @Override - public Class<? extends Page> getHomePage() - { - return TestPage.class; - } - - - @PostConstruct - @Override - protected void init() - { - super.init(); - - } - - public String getInjectedTestString() - { - return testString; - } - -}
http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java index 71248c9..6ea1916 100644 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java +++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestCdiApplication.java @@ -16,17 +16,16 @@ */ package org.apache.wicket.cdi.testapp; -import javax.annotation.PostConstruct; import javax.inject.Inject; import org.apache.wicket.Page; -import org.apache.wicket.cdi.WicketApp; +import org.apache.wicket.cdi.CdiConfiguration; +import org.apache.wicket.cdi.MockCdiContainer; import org.apache.wicket.protocol.http.WebApplication; /** * @author jsarman */ -@WicketApp("mockApp") public class TestCdiApplication extends WebApplication { @@ -41,13 +40,11 @@ public class TestCdiApplication extends WebApplication return TestPage.class; } - - @PostConstruct @Override protected void init() { super.init(); - + new CdiConfiguration().configure(this, new MockCdiContainer()); } public String getInjectedTestString() http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java index b88a28a..a106936 100644 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java +++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestConversationalPage.java @@ -20,7 +20,7 @@ import java.util.Random; import javax.inject.Inject; -import org.apache.wicket.cdi.Conversational; +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; @@ -29,12 +29,10 @@ import org.apache.wicket.request.mapper.parameter.PageParameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * @author jsarman */ -@Conversational -public class TestConversationalPage extends WebPage +public class TestConversationalPage extends WebPage implements ConversationalComponent { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.java index 4380fbe..2a78914 100644 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.java +++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/testapp/TestNonAutoConversationalPage.java @@ -21,8 +21,6 @@ import java.util.Random; import javax.enterprise.context.Conversation; import javax.inject.Inject; -import org.apache.wicket.cdi.ConversationPropagation; -import org.apache.wicket.cdi.Conversational; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.Link; @@ -31,11 +29,9 @@ import org.apache.wicket.request.mapper.parameter.PageParameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * @author jsarman */ -@Conversational(auto = false, prop = ConversationPropagation.ALL) public class TestNonAutoConversationalPage extends WebPage { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java index 7ba82a5..4052110 100644 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java +++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/CdiWicketTester.java @@ -18,14 +18,11 @@ package org.apache.wicket.cdi.util.tester; import java.util.concurrent.atomic.AtomicInteger; -import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import javax.enterprise.context.Dependent; import javax.inject.Inject; -import javax.servlet.FilterConfig; -import org.apache.wicket.cdi.CdiWebApplicationFactory; -import org.apache.wicket.protocol.http.WicketFilter; +import org.apache.wicket.cdi.NonContextual; +import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.protocol.http.mock.MockHttpServletRequest; import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.util.tester.WicketTester; @@ -35,57 +32,21 @@ import org.slf4j.LoggerFactory; /** * @author jsarman */ -@Dependent public class CdiWicketTester extends WicketTester { - private static final Logger logger = LoggerFactory.getLogger(CdiWicketTester.class); + @Inject ContextManager contextManager; - TestCdiConfiguration cdiConfiguration; - FilterConfig filterConfig; - - - @Inject - public CdiWicketTester(TestCdiConfiguration cdiConfiguration, CdiWebApplicationFactory factory, - @ConfigurationFilter final FilterConfig filterConfig) - { - super(factory.createApplication(new WicketFilter() - { - - @Override - public FilterConfig getFilterConfig() - { - return filterConfig; - } - - })); - this.cdiConfiguration = cdiConfiguration; - this.filterConfig = filterConfig; - } - - @PostConstruct - public void initializeApp() - { - logger.debug("Initialized Cdi Wicket Tester"); - cdiConfiguration.remapApplicationKey(filterConfig.getFilterName(), getApplication()); - contextManager.activateContexts(getRequest()); // Start up contexts in - // case no requests are - // performed - } - + private AtomicInteger count = new AtomicInteger(); - public void configure() + public CdiWicketTester(WebApplication app) { - if (!cdiConfiguration.isConfigured()) - { - cdiConfiguration.configure(getApplication()); - } + super(app); + NonContextual.of(CdiWicketTester.class).inject(this); } - - private AtomicInteger count = new AtomicInteger(); - + /** * 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 @@ -106,11 +67,7 @@ public class CdiWicketTester extends WicketTester if (getLastRequest() != null) { - contextManager.deactivateContexts(getLastRequest()); - } - else - { - configure();// make sure we are configured for cdi + contextManager.deactivateContexts(); } contextManager.activateContexts(getRequest()); } @@ -132,9 +89,9 @@ public class CdiWicketTester extends WicketTester logger.debug("Destroying Cdi Wicket Tester"); if (getLastRequest() != null) { - contextManager.deactivateContexts(getLastRequest()); + contextManager.deactivateContexts(); } - contextManager.destroy(getHttpSession()); + contextManager.destroy(); destroy(); } catch (Throwable t) http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ConfigurationFilter.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ConfigurationFilter.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ConfigurationFilter.java deleted file mode 100644 index b902d95..0000000 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ConfigurationFilter.java +++ /dev/null @@ -1,37 +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.util.tester; - - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Qualifier for injecting the FilterConfiguration for testing - * - * @author jsarman - */ -@Qualifier -@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface ConfigurationFilter { - -} http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ContextManager.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ContextManager.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ContextManager.java index d163da0..fb9eeb1 100644 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ContextManager.java +++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/ContextManager.java @@ -77,14 +77,14 @@ public class ContextManager lifecycle.requestInitialized(currentRequest, null); } - public void deactivateContexts(HttpServletRequest request) + public void deactivateContexts() { lifecycle.requestDestroyed(currentRequest); currentSession = currentRequest.getSession(false); currentRequest = null; } - public void destroy(HttpSession session) + public void destroy() { if (currentRequest != null) { @@ -97,4 +97,9 @@ public class ContextManager currentSession = null; } } + + public boolean isRequestActive() + { + return currentRequest != null; + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/FilterConfigProducer.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/FilterConfigProducer.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/FilterConfigProducer.java deleted file mode 100644 index 4f99bf2..0000000 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/FilterConfigProducer.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.util.tester; - -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.servlet.FilterConfig; - -/** - * @author jsarman - */ -@ApplicationScoped -public class FilterConfigProducer -{ - - TestFilterConfig config; - - @PostConstruct - public void init() - { - config = new TestFilterConfig(); - } - - @Produces - @ConfigurationFilter - public FilterConfig getConfig() - { - return config; - } - - public void addParameter(String paramName, String value) - { - config.put(paramName, value); - } - - public void removeParameter(String paramName) - { - config.remove(paramName); - } - - public void addParameters(Map<String, String> params) - { - config.putAll(params); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestBehaviorInjector.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestBehaviorInjector.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestBehaviorInjector.java deleted file mode 100644 index 9f92eee..0000000 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestBehaviorInjector.java +++ /dev/null @@ -1,51 +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.util.tester; - -import java.lang.reflect.Modifier; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Alternative; -import javax.enterprise.inject.Specializes; - -import org.apache.wicket.behavior.Behavior; -import org.apache.wicket.cdi.BehaviorInjector; - -/** - * Injects components with CDI dependencies - * - * @author igor - */ -@ApplicationScoped -@Alternative -@Specializes -public class TestBehaviorInjector extends BehaviorInjector -{ - - @Override - public void onInstantiation(Behavior behavior) - { - Class instanceClass = behavior.getClass(); - if (instanceClass.isAnonymousClass() - || (instanceClass.isMemberClass() && Modifier - .isStatic(instanceClass.getModifiers()) == false)) - { - return; - } - inject(behavior); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestCdiConfiguration.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestCdiConfiguration.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestCdiConfiguration.java deleted file mode 100644 index 7715bb3..0000000 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestCdiConfiguration.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.util.tester; - -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Alternative; -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.Specializes; - -import org.apache.wicket.Application; -import org.apache.wicket.cdi.Auto; -import org.apache.wicket.cdi.CdiConfiguration; -import org.apache.wicket.cdi.ConfigurationParameters; -import org.apache.wicket.cdi.IConversationPropagation; -import org.apache.wicket.cdi.Propagation; - -/** - * Specializes the CdiConfigration to allow the ConfigurationParams key to be - * remapped after the Application is used to construct the WicketTester. This is - * needed because WicketTester generates the ApplicationKey during construction - * and does not contain a mechanism to override the name. In the normal code the - * WicketFilter sets the key to the filtername so remapping is not necessary. - * - * @author jsarman - */ -@ApplicationScoped -@Alternative -@Specializes -public class TestCdiConfiguration extends CdiConfiguration -{ - - @PostConstruct - @Override - public void init() - { - super.init(); - } - - public @Produces - @Propagation - IConversationPropagation getPropagation() - { - return super.getPropagation(); - } - - - public @Produces - @Auto - @Override - Boolean isAutoConversationManagement() - { - return super.isAutoConversationManagement(); - } - - public void remapApplicationKey(String key, Application app) - { - ConfigurationParameters cp = parameters.remove(key); - parameters.put(app.getApplicationKey(), cp); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestComponentInjector.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestComponentInjector.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestComponentInjector.java deleted file mode 100644 index 6847ed9..0000000 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestComponentInjector.java +++ /dev/null @@ -1,51 +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.util.tester; - -import java.lang.reflect.Modifier; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Alternative; -import javax.enterprise.inject.Specializes; - -import org.apache.wicket.Component; -import org.apache.wicket.cdi.ComponentInjector; - -/** - * Injects components with CDI dependencies - * - * @author igor - */ -@ApplicationScoped -@Alternative -@Specializes -public class TestComponentInjector extends ComponentInjector -{ - - @Override - public void onInstantiation(Component component) - { - Class instanceClass = component.getClass(); - if (instanceClass.isAnonymousClass() - || (instanceClass.isMemberClass() && Modifier - .isStatic(instanceClass.getModifiers()) == false)) - { - return; - } - inject(component); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestFilterConfig.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestFilterConfig.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestFilterConfig.java deleted file mode 100644 index 27a2238..0000000 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/test/java/org/apache/wicket/cdi/util/tester/TestFilterConfig.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.cdi.util.tester; - -import java.util.Enumeration; -import java.util.Map; -import java.util.TreeMap; -import java.util.UUID; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletContext; - -/** - * @author jsarman - */ -public class TestFilterConfig implements FilterConfig -{ - - private String filterName = "CdiApp" + UUID.randomUUID(); - private Map<String, String> params; - - public TestFilterConfig() - { - this(null); - } - - public TestFilterConfig(Map<String, String> initialParams) - { - this.params = new TreeMap<String, String>(); - this.params.put("applicationName", "mockApp"); - if (initialParams != null) - { - this.params.putAll(initialParams); - } - } - - public void put(String paramName, String value) - { - params.put(paramName, value); - } - - public void remove(String paramName) - { - params.remove(paramName); - } - - public void putAll(Map<String, String> additionalParams) - { - params.putAll(additionalParams); - } - - @Override - public String getFilterName() - { - return filterName; - } - - @Override - public ServletContext getServletContext() - { - throw new UnsupportedOperationException("This is not supported."); - } - - @Override - public String getInitParameter(String name) - { - return params.get(name); - } - - @Override - public Enumeration<String> getInitParameterNames() - { - throw new UnsupportedOperationException("This is not Supported."); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/967cda31/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java index b4e13db..4dcbdb9 100644 --- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java +++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-weld/src/main/java/org/apache/wicket/cdi/weld/WeldCdiContainer.java @@ -16,11 +16,10 @@ */ package org.apache.wicket.cdi.weld; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.Conversation; import javax.inject.Inject; import org.apache.wicket.cdi.AbstractCdiContainer; +import org.apache.wicket.cdi.NonContextual; import org.apache.wicket.request.cycle.RequestCycle; import org.jboss.weld.context.http.HttpConversationContext; @@ -29,12 +28,16 @@ import org.jboss.weld.context.http.HttpConversationContext; * * @author jsarman */ -@ApplicationScoped public class WeldCdiContainer extends AbstractCdiContainer { @Inject private HttpConversationContext conversationContext; + public WeldCdiContainer() + { + NonContextual.of(WeldCdiContainer.class).inject(this); + } + /** * Activates the conversational context and starts the conversation with the * specified cid @@ -59,9 +62,7 @@ public class WeldCdiContainer extends AbstractCdiContainer } @Override - public Conversation getCurrentConversation() + public void deactivateConversationalContext(RequestCycle cycle) { - return conversationContext.getCurrentConversation(); } - }
