You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pa...@apache.org on 2013/07/05 16:58:10 UTC
[1/3] git commit: Revert "WICKET-5226 CDI integration fails in
Glassfish 4.0 with WELD-000070"
Updated Branches:
refs/heads/wicket-6.x 8cb340aea -> 0fa7cb72a
Revert "WICKET-5226 CDI integration fails in Glassfish 4.0 with WELD-000070"
This reverts commit 90eba1eef88cdf3a19b04ba3811643dd55c604cc.
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/d0d1d44d
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/d0d1d44d
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/d0d1d44d
Branch: refs/heads/wicket-6.x
Commit: d0d1d44d0f7e673d7bf9713943367703063a2ae8
Parents: 8cb340a
Author: Emond Papegaaij <em...@topicus.nl>
Authored: Fri Jul 5 16:56:01 2013 +0200
Committer: Emond Papegaaij <em...@topicus.nl>
Committed: Fri Jul 5 16:57:48 2013 +0200
----------------------------------------------------------------------
.../org/apache/wicket/cdi/AbstractInjector.java | 34 +-------------------
.../apache/wicket/cdi/ComponentInjector.java | 18 ++++++++++-
2 files changed, 18 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/d0d1d44d/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
index 1c7bac2..b77aa6e 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/AbstractInjector.java
@@ -16,11 +16,7 @@
*/
package org.apache.wicket.cdi;
-import java.lang.reflect.Modifier;
-
import org.apache.wicket.util.lang.Args;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Base class for injectors
@@ -29,8 +25,6 @@ import org.slf4j.LoggerFactory;
*/
class AbstractInjector
{
- private static final Logger LOG = LoggerFactory.getLogger(AbstractInjector.class);
-
private final CdiContainer container;
public AbstractInjector(CdiContainer container)
@@ -41,37 +35,11 @@ class AbstractInjector
protected <T> void postConstruct(T instance)
{
- // TODO: is #canProcess() needed here too ?
- // What are the rules to post construct an instance
container.getNonContextualManager().postConstruct(instance);
}
protected <T> void inject(T instance)
{
- if (canProcess(instance))
- {
- container.getNonContextualManager().inject(instance);
- }
- }
-
- private <T> boolean canProcess(T instance)
- {
- final boolean canProcess;
- Class<?> instanceClass = instance.getClass();
-
- if (instanceClass.isAnonymousClass() ||
- (instanceClass.isMemberClass() && Modifier.isStatic(instanceClass.getModifiers()) == false))
- {
- canProcess = false;
- LOG.debug("Class '{}' will not be processed for CDI injection because it is anonymous or non-static member class",
- instanceClass);
- }
- else
- {
- canProcess = true;
- LOG.debug("Going to process class '{}' for CDI injection", instanceClass);
- }
-
- return canProcess;
+ container.getNonContextualManager().inject(instance);
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/d0d1d44d/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
index ea6c7db..c921706 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
@@ -16,8 +16,12 @@
*/
package org.apache.wicket.cdi;
+import java.lang.reflect.Modifier;
+
import org.apache.wicket.Component;
import org.apache.wicket.application.IComponentInstantiationListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Injects components with CDI dependencies
@@ -27,6 +31,8 @@ import org.apache.wicket.application.IComponentInstantiationListener;
*/
class ComponentInjector extends AbstractInjector implements IComponentInstantiationListener
{
+ private static final Logger LOG = LoggerFactory.getLogger(ComponentInjector.class);
+
/**
* Constructor
*
@@ -40,6 +46,16 @@ class ComponentInjector extends AbstractInjector implements IComponentInstantiat
@Override
public void onInstantiation(Component component)
{
- inject(component);
+ Class<? extends Component> componentClass = component.getClass();
+
+ if (componentClass.isAnonymousClass() ||
+ (componentClass.isMemberClass() && Modifier.isStatic(componentClass.getModifiers()) == false))
+ {
+ LOG.debug("Skipping non-static inner class '{}' ", componentClass);
+ }
+ else
+ {
+ inject(component);
+ }
}
}
[2/3] git commit: Revert "WICKET-5226 CDI integration fails in
Glassfish 4.0 with WELD-000070"
Posted by pa...@apache.org.
Revert "WICKET-5226 CDI integration fails in Glassfish 4.0 with WELD-000070"
This reverts commit cdb9c0d847c1ced195caeb9034378782840d3988.
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/5490d3fb
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/5490d3fb
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/5490d3fb
Branch: refs/heads/wicket-6.x
Commit: 5490d3fb0588d3d5f08b0d6824e4e058379845ed
Parents: d0d1d44
Author: Emond Papegaaij <em...@topicus.nl>
Authored: Fri Jul 5 16:56:07 2013 +0200
Committer: Emond Papegaaij <em...@topicus.nl>
Committed: Fri Jul 5 16:57:49 2013 +0200
----------------------------------------------------------------------
.../apache/wicket/cdi/ComponentInjector.java | 3 +--
.../wicket/cdi/ComponentInjectorTest.java | 21 --------------------
2 files changed, 1 insertion(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/5490d3fb/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
index c921706..0316004 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
@@ -48,8 +48,7 @@ class ComponentInjector extends AbstractInjector implements IComponentInstantiat
{
Class<? extends Component> componentClass = component.getClass();
- if (componentClass.isAnonymousClass() ||
- (componentClass.isMemberClass() && Modifier.isStatic(componentClass.getModifiers()) == false))
+ if (componentClass.isMemberClass() && Modifier.isStatic(componentClass.getModifiers()) == false)
{
LOG.debug("Skipping non-static inner class '{}' ", componentClass);
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/5490d3fb/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java
index 4be6976..55d00cd 100644
--- a/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java
+++ b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java
@@ -107,27 +107,6 @@ public class ComponentInjectorTest extends Assert
assertEquals(expectedValue, component.dependency);
}
- /**
- * https://issues.apache.org/jira/browse/WICKET-5226
- */
- @Test
- public void anonymousClass()
- {
- BeanManager beanManager = mock(BeanManager.class);
- INonContextualManager nonContextualManager = mock(INonContextualManager.class);
-
- CdiContainer cdiContainer = new CdiContainer(beanManager, nonContextualManager);
- ComponentInjector injector = new ComponentInjector(cdiContainer);
-
- WebComponent component = new WebComponent("someId") {
- // anonymous class
- };
-
- injector.onInstantiation(component);
-
- verify(nonContextualManager, never()).inject(any());
- }
-
private class TestNonStaticComponent extends WebComponent
{
@Inject
[3/3] git commit: Revert "WICKET-5226 CDI integration fails in
Glassfish 4.0 with WELD-000070"
Posted by pa...@apache.org.
Revert "WICKET-5226 CDI integration fails in Glassfish 4.0 with WELD-000070"
This reverts commit eb6ee7eda4603a19c8cc4c10b87deffad6077e8f.
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/0fa7cb72
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/0fa7cb72
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/0fa7cb72
Branch: refs/heads/wicket-6.x
Commit: 0fa7cb72afc7325e25a3e6de2bfbddcd917106a1
Parents: 5490d3f
Author: Emond Papegaaij <em...@topicus.nl>
Authored: Fri Jul 5 16:56:20 2013 +0200
Committer: Emond Papegaaij <em...@topicus.nl>
Committed: Fri Jul 5 16:57:49 2013 +0200
----------------------------------------------------------------------
wicket-cdi/pom.xml | 6 -
.../apache/wicket/cdi/ComponentInjector.java | 18 +--
.../wicket/cdi/ComponentInjectorTest.java | 131 -------------------
.../wicket/examples/cdi/ConversationPage2.java | 23 ++--
4 files changed, 10 insertions(+), 168 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/0fa7cb72/wicket-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-cdi/pom.xml b/wicket-cdi/pom.xml
index 7cd2752..d2f4f2e 100644
--- a/wicket-cdi/pom.xml
+++ b/wicket-cdi/pom.xml
@@ -52,12 +52,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>javax.el-api</artifactId>
- <version>2.2.4</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<pluginManagement>
http://git-wip-us.apache.org/repos/asf/wicket/blob/0fa7cb72/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
index 0316004..bc302ef 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
@@ -16,12 +16,8 @@
*/
package org.apache.wicket.cdi;
-import java.lang.reflect.Modifier;
-
import org.apache.wicket.Component;
import org.apache.wicket.application.IComponentInstantiationListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Injects components with CDI dependencies
@@ -31,8 +27,6 @@ import org.slf4j.LoggerFactory;
*/
class ComponentInjector extends AbstractInjector implements IComponentInstantiationListener
{
- private static final Logger LOG = LoggerFactory.getLogger(ComponentInjector.class);
-
/**
* Constructor
*
@@ -46,15 +40,7 @@ class ComponentInjector extends AbstractInjector implements IComponentInstantiat
@Override
public void onInstantiation(Component component)
{
- Class<? extends Component> componentClass = component.getClass();
-
- if (componentClass.isMemberClass() && Modifier.isStatic(componentClass.getModifiers()) == false)
- {
- LOG.debug("Skipping non-static inner class '{}' ", componentClass);
- }
- else
- {
- inject(component);
- }
+ inject(component);
}
+
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/0fa7cb72/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java b/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java
deleted file mode 100644
index 55d00cd..0000000
--- a/wicket-cdi/src/test/java/org/apache/wicket/cdi/ComponentInjectorTest.java
+++ /dev/null
@@ -1,131 +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.mockito.Mockito.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-
-import org.apache.wicket.markup.html.WebComponent;
-import org.apache.wicket.util.tester.WicketTester;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * Tests for ComponentInjector
- */
-public class ComponentInjectorTest extends Assert
-{
- private WicketTester tester;
-
- @Before
- public void before()
- {
- // starts an application so we can instantiate components
- tester = new WicketTester();
- }
-
- @After
- public void after()
- {
- tester.destroy();
- tester = null;
- }
-
- /**
- * https://issues.apache.org/jira/browse/WICKET-5226
- */
- @Test
- public void innerNonStaticClass()
- {
- BeanManager beanManager = mock(BeanManager.class);
- INonContextualManager nonContextualManager = mock(INonContextualManager.class);
- CdiContainer cdiContainer = new CdiContainer(beanManager, nonContextualManager);
- ComponentInjector injector = new ComponentInjector(cdiContainer);
-
- TestNonStaticComponent component = new TestNonStaticComponent("someId");
- assertNull(component.dependency);
-
- injector.onInstantiation(component);
-
- verify(nonContextualManager, never()).inject(any());
- }
-
- /**
- * https://issues.apache.org/jira/browse/WICKET-5226
- */
- @Test
- public void innerStaticClass()
- {
- BeanManager beanManager = mock(BeanManager.class);
- INonContextualManager nonContextualManager = mock(INonContextualManager.class);
- final String expectedValue = "injected";
-
- doAnswer(new Answer<Void>()
- {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable
- {
- TestStaticComponent component = (TestStaticComponent) invocation.getArguments()[0];
- component.dependency = expectedValue;
-
- return null;
- }
- }).when(nonContextualManager).inject(any(TestStaticComponent.class));
-
- CdiContainer cdiContainer = new CdiContainer(beanManager, nonContextualManager);
- ComponentInjector injector = new ComponentInjector(cdiContainer);
-
- TestStaticComponent component = new TestStaticComponent("someId");
- assertNull(component.dependency);
-
- injector.onInstantiation(component);
-
- assertEquals(expectedValue, component.dependency);
- }
-
- private class TestNonStaticComponent extends WebComponent
- {
- @Inject
- private String dependency;
-
- public TestNonStaticComponent(String id)
- {
- super(id);
- }
- }
-
- private static class TestStaticComponent extends WebComponent
- {
- @Inject
- private String dependency;
-
- public TestStaticComponent(String id)
- {
- super(id);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/0fa7cb72/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/ConversationPage2.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/ConversationPage2.java b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/ConversationPage2.java
index df175f8..89b9e6a 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/ConversationPage2.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/ConversationPage2.java
@@ -32,22 +32,15 @@ public class ConversationPage2 extends CdiExamplePage
{
add(new Label("count", new PropertyModel(this, "counter.count")));
- add(new IncrementLink("increment"));
-
- add(new BookmarkablePageLink<Void>("next", ConversationPage3.class));
- }
-
- private class IncrementLink extends Link<Void> {
-
- public IncrementLink(String id)
+ add(new Link<Void>("increment")
{
- super(id);
- }
+ @Override
+ public void onClick()
+ {
+ counter.increment();
+ }
+ });
- @Override
- public void onClick()
- {
- counter.increment();
- }
+ add(new BookmarkablePageLink<Void>("next", ConversationPage3.class));
}
}