Weld SVN: r5639 - in core/trunk: impl/src/main/java/org/jboss/weld/resolution and 5 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2010-01-27 09:06:01 -0500 (Wed, 27 Jan 2010)
New Revision: 5639
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/BasicDecoratorResolutionTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/Complex.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/ComplexBean.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/ComplexDecorator.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/DecoratorResolutionTestsHelper.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/Simple.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SimpleBean.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SimpleDecorator.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SomeBean.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/resolution/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/resolution/beans-basic.xml
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.java
Log:
WELD-291
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-01-27 13:19:32 UTC (rev 5638)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -263,7 +263,7 @@
{
throw new DeploymentException(INJECTION_POINT_HAS_UNSATISFIED_DEPENDENCIES, ij, Arrays.toString(bindings));
}
- if (resolvedBeans.size() > 1)
+ if (resolvedBeans.size() > 1 && !ij.isDelegate())
{
throw new DeploymentException(INJECTION_POINT_HAS_AMBIGUOUS_DEPENDENCIES, ij, Arrays.toString(bindings) + "; Possible dependencies: " + resolvedBeans);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java 2010-01-27 13:19:32 UTC (rev 5638)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -43,7 +43,9 @@
@Override
protected boolean matches(Resolvable resolvable, Decorator<?> bean)
{
- return Reflections.matches(Collections.singleton(bean.getDelegateType()), resolvable.getTypeClosure()) && Beans.containsAllBindings(bean.getDelegateQualifiers(), resolvable.getQualifiers(), getBeanManager()) && getBeanManager().getEnabledDecoratorClasses().contains(bean.getBeanClass());
+ return Reflections.matches(Collections.singleton(bean.getDelegateType()), resolvable.getTypeClosure())
+ && Beans.containsAllBindings(bean.getDelegateQualifiers(), resolvable.getQualifiers(), getBeanManager())
+ && getBeanManager().getEnabledDecoratorClasses().contains(bean.getBeanClass());
}
@Override
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.java 2010-01-27 13:19:32 UTC (rev 5638)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -28,7 +28,7 @@
public class InterceptorAndDecoratorTest extends AbstractWeldTest
{
- @Test(description="WELD-314", groups = "broken")
+ @Test(description="WELD-314")
public void test()
{
ServiceImpl.invocationCount = 0;
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/BasicDecoratorResolutionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/BasicDecoratorResolutionTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/BasicDecoratorResolutionTest.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.util.AnnotationLiteral;
+
+import java.util.*;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Artifact
+@BeansXml("beans-basic.xml")
+public class BasicDecoratorResolutionTest extends AbstractWeldTest
+{
+
+ @Test
+ public void testBasicDecoratorInvocation()
+ {
+ SimpleBean simpleBean = getReference(SimpleBean.class, new AnnotationLiteral<Simple>(){});
+ String result = simpleBean.hello("world");
+ assert "simple-Hello, world-simple".equals(result);
+ }
+
+ @Test
+ public void testComplexDecoratorInvocation()
+ {
+ ComplexBean complexBean = getReference(ComplexBean.class, new AnnotationLiteral<Complex>(){});
+ String result = complexBean.hello("world");
+ assert "simple-complex-Sophisticated Hello, world-complex-simple".equals(result);
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/Complex.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/Complex.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/Complex.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+import javax.inject.Qualifier;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Qualifier
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE, ElementType.FIELD})
+@Documented
+public @interface Complex
+{
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/ComplexBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/ComplexBean.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/ComplexBean.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Complex
+public class ComplexBean implements SomeBean
+{
+ public String hello(String name)
+ {
+ return "Sophisticated Hello, " + name;
+ }
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/ComplexDecorator.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/ComplexDecorator.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/ComplexDecorator.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Decorator
+public class ComplexDecorator implements SomeBean
+{
+ @Inject @Delegate @Any ComplexBean delegate;
+
+ public String hello(String name)
+ {
+ return "complex-" +delegate.hello(name) +"-complex";
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/DecoratorResolutionTestsHelper.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/DecoratorResolutionTestsHelper.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/DecoratorResolutionTestsHelper.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+import javax.enterprise.inject.spi.Decorator;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class DecoratorResolutionTestsHelper
+{
+ public static boolean decoratorClassesMatch(List<Decorator<?>> decoratorList, Collection<Class<?>> expectedDecoratorClasses)
+ {
+ if (decoratorList.size() != expectedDecoratorClasses.size())
+ return false;
+ Collection<Class<?>> expectedDecoratedClassesCopy = new ArrayList<Class<?>>(expectedDecoratorClasses);
+ for (Decorator<?> decorator: decoratorList)
+ {
+ if (!expectedDecoratedClassesCopy.remove(decorator.getBeanClass()))
+ return false;
+ }
+ return expectedDecoratedClassesCopy.size() == 0;
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/Simple.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/Simple.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/Simple.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+import javax.inject.Qualifier;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Qualifier
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE, ElementType.FIELD})
+@Documented
+public @interface Simple
+{
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SimpleBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SimpleBean.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SimpleBean.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Simple
+public class SimpleBean implements SomeBean
+{
+ public String hello(String name)
+ {
+ return "Hello, " + name;
+ }
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SimpleDecorator.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SimpleDecorator.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SimpleDecorator.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Decorator
+public class SimpleDecorator implements SomeBean
+{
+ @Inject @Delegate @Any SomeBean delegate;
+
+ public String hello(String name)
+ {
+ return "simple-" +delegate.hello(name) +"-simple";
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SomeBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SomeBean.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/resolution/SomeBean.java 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.tests.decorators.resolution;
+
+/**
+ * @author Marius Bogoevici
+ */
+public interface SomeBean
+{
+ String hello(String name);
+}
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/resolution/beans-basic.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/resolution/beans-basic.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/resolution/beans-basic.xml 2010-01-27 14:06:01 UTC (rev 5639)
@@ -0,0 +1,23 @@
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2010, 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.
+ -->
+
+<beans>
+ <decorators>
+ <decorator>org.jboss.weld.tests.decorators.resolution.SimpleDecorator</decorator>
+ <decorator>org.jboss.weld.tests.decorators.resolution.ComplexDecorator</decorator>
+ </decorators>
+</beans>
14 years, 11 months
Weld SVN: r5638 - in core/trunk: tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml and 1 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-01-27 08:19:32 -0500 (Wed, 27 Jan 2010)
New Revision: 5638
Added:
core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/bootstrap/xml/nonPrettyPrinted.xml
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/util/dom/NodeListIterator.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml/BeansXmlTest.java
Log:
WELD-362
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/dom/NodeListIterator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/dom/NodeListIterator.java 2010-01-27 06:18:35 UTC (rev 5637)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/dom/NodeListIterator.java 2010-01-27 13:19:32 UTC (rev 5638)
@@ -38,13 +38,12 @@
public boolean hasNext()
{
- return index < nodeList.getLength() - 1;
+ return index < nodeList.getLength();
}
public Node next()
{
- index++;
- return nodeList.item(index);
+ return nodeList.item(index++);
}
public void remove()
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml/BeansXmlTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml/BeansXmlTest.java 2010-01-27 06:18:35 UTC (rev 5637)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/bootstrap/xml/BeansXmlTest.java 2010-01-27 13:19:32 UTC (rev 5638)
@@ -162,6 +162,19 @@
public void testCannotGetDocumentBuilder()
{
}
+ /*
+ * https://jira.jboss.org/jira/browse/WELD-362
+ */
+ @Test
+ public void testNonPrettyPrintedXML()
+ {
+ List<Class<?>> beans = Arrays.asList(Alt.class, Dec.class, Int.class, IntBind.class, Plain.class);
+ List<URL> beansXmls = Arrays.asList(getClass().getResource("nonPrettyPrinted.xml"));
+ TestContainer container = new TestContainer(new MockEELifecycle(), beans, beansXmls).startContainer().ensureRequestActive();
+ assert container.getBeanManager().getEnabledAlternativeClasses().size() == 1;
+ assert container.getBeanManager().getEnabledAlternativeClasses().iterator().next() == Alt.class;
+ container.stopContainer();
+ }
@Test
public void testCannotLoadFile() throws MalformedURLException
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/bootstrap/xml/nonPrettyPrinted.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/bootstrap/xml/nonPrettyPrinted.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/bootstrap/xml/nonPrettyPrinted.xml 2010-01-27 13:19:32 UTC (rev 5638)
@@ -0,0 +1 @@
+<beans><alternatives><class>org.jboss.weld.tests.unit.bootstrap.xml.Alt</class></alternatives></beans>
\ No newline at end of file
14 years, 11 months
Weld SVN: r5637 - in core/trunk/impl/src/main/java/org/jboss/weld: bean/proxy and 2 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2010-01-27 01:18:35 -0500 (Wed, 27 Jan 2010)
New Revision: 5637
Added:
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecorationHelper.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Decorators.java
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/CustomDecoratorWrapper.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
Log:
rework decoration process, elliminate recursivity, separate handling of delegate and non-delegate references inside getInjectableReference
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., and individual contributors
+ * Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -56,7 +56,7 @@
import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
import org.jboss.interceptor.util.InterceptionUtils;
import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
-import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
+import org.jboss.weld.bean.proxy.DecorationHelper;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.context.SerializableContextualImpl;
import org.jboss.weld.context.SerializableContextualInstanceImpl;
@@ -140,8 +140,6 @@
// Decorators
private List<Decorator<?>> decorators;
private Class<T> proxyClassForDecorators;
- private final ThreadLocal<Integer> decoratorStackPosition;
- private final ThreadLocal<T> decoratedActualInstance = new ThreadLocal<T>();
// Interceptors
private boolean hasSerializationOrInvocationInterceptorMethods;
@@ -165,16 +163,6 @@
{
super(idSuffix, beanManager);
this.annotatedItem = type;
- this.decoratorStackPosition = new ThreadLocal<Integer>()
- {
-
- @Override
- protected Integer initialValue()
- {
- return 0;
- }
-
- };
initStereotypes();
initAlternative();
initInitializerMethods();
@@ -230,65 +218,18 @@
protected T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
{
- List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances = new ArrayList<SerializableContextualInstance<Decorator<Object>, Object>>();
- InjectionPoint ip = originalInjectionPoint;
- boolean outside = decoratorStackPosition.get().intValue() == 0;
- if (outside)
- {
- decoratedActualInstance.set(instance);
- }
+ T proxy = null;
+ DecorationHelper<T> decorationHelper = new DecorationHelper(instance, proxyClassForDecorators, beanManager, decorators);
- try
- {
- int i = decoratorStackPosition.get();
- while (i < decorators.size())
- {
- Decorator<?> decorator = decorators.get(i);
- decoratorStackPosition.set(++i);
+ DecorationHelper.getHelperStack().push(decorationHelper);
+ proxy = decorationHelper.getNextDelegate(originalInjectionPoint, creationalContext);
+ decorationHelper = (DecorationHelper<T>) DecorationHelper.getHelperStack().pop();
- Object decoratorInstance = getBeanManager().getReference(ip, decorator, creationalContext);
- decoratorInstances.add(new SerializableContextualInstanceImpl<Decorator<Object>, Object>((Decorator<Object>) decorator, decoratorInstance, null));
-
- ip = Beans.getDelegateInjectionPoint(decorator);
- if (ip == null)
- {
- throw new ForbiddenStateException(NON_CONTAINER_DECORATOR, decorator);
- }
- }
- }
- finally
+ if (proxy == null)
{
- if (outside)
- {
- decoratorStackPosition.remove();
- }
+ throw new WeldException(PROXY_INSTANTIATION_FAILED, this);
}
- try
- {
- T proxy = SecureReflections.newInstance(proxyClassForDecorators);
- // temporary fix for decorators - make sure that the instance wrapped
- // by the decorators
- // is the contextual instance
- // TODO - correct the decoration algorithm to avoid the creation of new
- // target class instances
- Proxies.attachMethodHandler(proxy, new DecoratorProxyMethodHandler(decoratorInstances, decoratedActualInstance.get()));
- return proxy;
- }
- catch (InstantiationException e)
- {
- throw new WeldException(PROXY_INSTANTIATION_FAILED, e, this);
- }
- catch (IllegalAccessException e)
- {
- throw new WeldException(PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, this);
- }
- finally
- {
- if (outside)
- {
- decoratedActualInstance.set(null);
- }
- }
+ return proxy;
}
public List<Decorator<?>> getDecorators()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/CustomDecoratorWrapper.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/CustomDecoratorWrapper.java 2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/CustomDecoratorWrapper.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -25,7 +25,7 @@
import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resources.ClassTransformer;
-import org.jboss.weld.util.Deployers;
+import org.jboss.weld.util.Decorators;
/**
* A wrapper for a decorated instance. Allows to enhance custom decorators with metadata
@@ -49,7 +49,7 @@
{
this.delegate = delegate;
this.weldClass = beanManager.getServices().get(ClassTransformer.class).loadClass((Class<T>) delegate.getBeanClass());
- this.decoratedMethodSignatures = Deployers.getDecoratedMethodSignatures(beanManager, delegate.getDecoratedTypes());
+ this.decoratedMethodSignatures = Decorators.getDecoratedMethodSignatures(beanManager, delegate.getDecoratedTypes());
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java 2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -52,7 +52,7 @@
import org.jboss.weld.introspector.jlr.WeldConstructorImpl;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resources.ClassTransformer;
-import org.jboss.weld.util.Deployers;
+import org.jboss.weld.util.Decorators;
import org.jboss.weld.util.Proxies;
import org.jboss.weld.util.reflection.Reflections;
@@ -135,7 +135,7 @@
this.decoratedTypes.addAll(getWeldAnnotated().getInterfaceClosure());
this.decoratedTypes.remove(Serializable.class);
- this.decoratedMethodSignatures = Deployers.getDecoratedMethodSignatures(getBeanManager(), this.decoratedTypes);
+ this.decoratedMethodSignatures = Decorators.getDecoratedMethodSignatures(getBeanManager(), this.decoratedTypes);
}
protected void initDelegateInjectionPoint()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -217,36 +217,37 @@
public T produce(final CreationalContext<T> ctx)
{
- final T instance = bean.createInstance(ctx);
+ T instance;
if (!bean.hasDecorators())
{
// This should be safe, but needs verification PLM
// Without this, the chaining of decorators will fail as the
// incomplete instance will be resolved
+ instance = bean.createInstance(ctx);
ctx.push(instance);
}
-
- T decoratedInstance = new FixInjectionPoint<T>(bean)
+ else
{
-
- @Override
- protected T work()
+ instance = new FixInjectionPoint<T>(bean)
{
- if (bean.hasDecorators())
+ @Override
+ protected T work()
{
- return bean.applyDecorators(instance, ctx, getOriginalInjectionPoint());
+ // for decorated beans, creation should use the fixed injection point
+ // thus ensuring that the innermost decorator is provided as InjectionPoint
+ T undecoratedInstance = bean.createInstance(ctx);
+ return bean.applyDecorators(undecoratedInstance, ctx, getOriginalInjectionPoint());
}
- return instance;
- }
- }.run();
+ }.run();
+ }
if (bean.isInterceptionCandidate() && (bean.hasCdiBoundInterceptors() || bean.hasDirectlyDefinedInterceptors()))
{
- return bean.applyInterceptors(decoratedInstance, ctx);
+ return bean.applyInterceptors(instance, ctx);
}
else
{
- return decoratedInstance;
+ return instance;
}
}
}
Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecorationHelper.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecorationHelper.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecorationHelper.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+package org.jboss.weld.bean.proxy;
+
+import static org.jboss.weld.logging.messages.BeanMessage.PROXY_INSTANTIATION_BEAN_ACCESS_FAILED;
+import static org.jboss.weld.logging.messages.BeanMessage.PROXY_INSTANTIATION_FAILED;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Stack;
+
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
+import org.jboss.weld.exceptions.WeldException;
+import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.util.Proxies;
+import org.jboss.weld.util.reflection.SecureReflections;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class DecorationHelper<T>
+{
+ private static ThreadLocal<Stack<DecorationHelper<?>>> helperStackHolder = new ThreadLocal<Stack<DecorationHelper<?>>>()
+ {
+ @Override protected Stack<DecorationHelper<?>> initialValue()
+ {
+ return new Stack<DecorationHelper<?>>();
+ }
+ };
+
+ private Class<T> proxyClassForDecorator;
+
+ private T originalInstance;
+
+ private T previousDelegate;
+
+ private int counter;
+
+ private BeanManagerImpl beanManager;
+
+ List<Decorator<?>> decorators;
+
+ public DecorationHelper(T originalInstance, Class<T> proxyClassForDecorator, BeanManagerImpl beanManager, List<Decorator<?>> decorators)
+ {
+ this.originalInstance = originalInstance;
+ this.beanManager = beanManager;
+ this.decorators = new LinkedList<Decorator<?>>(decorators);
+ this.proxyClassForDecorator = proxyClassForDecorator;
+ counter = 0;
+ }
+
+ public static Stack<DecorationHelper<?>> getHelperStack()
+ {
+ return helperStackHolder.get();
+ }
+
+ public DecoratorProxyMethodHandler createMethodHandler(InjectionPoint injectionPoint, CreationalContext<?> creationalContext, Decorator<Object> decorator)
+ {
+ Object decoratorInstance = beanManager.getReference(injectionPoint, decorator, creationalContext);
+ SerializableContextualInstanceImpl<Decorator<Object>, Object> serializableContextualInstance = new SerializableContextualInstanceImpl<Decorator<Object>, Object>(decorator, decoratorInstance, null);
+ return new DecoratorProxyMethodHandler(serializableContextualInstance, previousDelegate);
+ }
+
+ public T getNextDelegate(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
+ {
+ if (counter == decorators.size())
+ {
+ previousDelegate = originalInstance;
+ return originalInstance;
+ }
+ else
+ {
+ try
+ {
+ T proxy = SecureReflections.newInstance(proxyClassForDecorator);
+ Proxies.attachMethodHandler(proxy, createMethodHandler(injectionPoint, creationalContext, (Decorator<Object>) decorators.get(counter++)));
+ previousDelegate = proxy;
+ return proxy;
+ }
+ catch (InstantiationException e)
+ {
+ throw new WeldException(PROXY_INSTANTIATION_FAILED, e, this);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new WeldException(PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, this);
+ }
+
+ }
+ }
+
+}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java 2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -1,15 +1,15 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * Copyright 2010, 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,
+ * 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.
@@ -18,11 +18,13 @@
import static org.jboss.weld.logging.messages.BeanMessage.UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR;
+import javax.enterprise.inject.spi.Decorator;
+import javax.inject.Inject;
+
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.List;
-import javax.enterprise.inject.spi.Decorator;
-
import org.jboss.interceptor.util.proxy.TargetInstanceProxyMethodHandler;
import org.jboss.weld.bean.WeldDecorator;
import org.jboss.weld.exceptions.ForbiddenStateException;
@@ -34,32 +36,33 @@
/**
* Method handler for decorated beans
- *
+ *
* @author Pete Muir
- *
+ * @author Marius Bogoevici
+ *
*/
public class DecoratorProxyMethodHandler extends TargetInstanceProxyMethodHandler
{
private static final long serialVersionUID = 4577632640130385060L;
- private final List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances;
+ private final SerializableContextualInstance<Decorator<Object>, Object> decoratorInstance;
/**
* Constructor
- *
+ *
* @param removeMethods
- *
+ *
* @param proxy The generic proxy
*/
- public DecoratorProxyMethodHandler(List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances, Object instance)
+ public DecoratorProxyMethodHandler(SerializableContextualInstance<Decorator<Object>, Object> decoratorInstance, Object delegateInstance)
{
- super (instance, instance.getClass());
- this.decoratorInstances = decoratorInstances;
+ super (delegateInstance, delegateInstance.getClass());
+ this.decoratorInstance = decoratorInstance;
}
-
+
/**
- *
- *
+ *
+ *
* @param self the proxy instance.
* @param method the overridden method declared in the super class or
* interface.
@@ -71,32 +74,34 @@
* parameter type is a primitive type, the type of the array
* element is a wrapper class.
* @return the resulting value of the method invocation.
- *
+ *
* @throws Throwable if the method invocation fails.
*/
@Override
protected Object doInvoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
{
+
MethodSignature methodSignature = new MethodSignatureImpl(method);
- for (SerializableContextualInstance<Decorator<Object>, Object> beanInstance : decoratorInstances)
+
+ SerializableContextualInstance<Decorator<Object>, Object> beanInstance = decoratorInstance;
+ if (beanInstance.getContextual().get() instanceof WeldDecorator<?>)
{
- if (beanInstance.getContextual().get() instanceof WeldDecorator<?>)
+ WeldDecorator<?> decorator = (WeldDecorator<?>) beanInstance.getContextual().get();
+ if (decorator.getDecoratedMethodSignatures().contains(methodSignature)
+ && !method.isAnnotationPresent(Inject.class))
{
- WeldDecorator<?> decorator = (WeldDecorator<?>) beanInstance.getContextual().get();
- if (decorator.getDecoratedMethodSignatures().contains(methodSignature))
+ WeldMethod<?, ?> decoratorMethod = decorator.getWeldAnnotated().getWeldMethod(methodSignature);
+ if (decoratorMethod != null)
{
- WeldMethod<?, ?> decoratorMethod = decorator.getWeldAnnotated().getWeldMethod(methodSignature);
- if (decoratorMethod != null)
- {
- return decoratorMethod.invokeOnInstance(beanInstance.getInstance(), args);
- }
+ return decoratorMethod.invokeOnInstance(beanInstance.getInstance(), args);
}
}
- else
- {
- throw new ForbiddenStateException(UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR, beanInstance.getContextual().get());
- }
}
+ else
+ {
+ throw new ForbiddenStateException(UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR, beanInstance.getContextual().get());
+ }
+
return SecureReflections.invoke(getTargetInstance(), method, args);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -76,6 +76,7 @@
import org.jboss.weld.bean.builtin.AbstractBuiltInBean;
import org.jboss.weld.bean.builtin.ExtensionBean;
import org.jboss.weld.bean.proxy.ClientProxyProvider;
+import org.jboss.weld.bean.proxy.DecorationHelper;
import org.jboss.weld.bootstrap.Validator;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.events.AbstractProcessInjectionTarget;
@@ -866,9 +867,16 @@
public Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
{
+ if (!injectionPoint.isDelegate())
+ {
WeldAnnotated<?, ?> element = ResolvableWeldClass.of(injectionPoint.getType(), injectionPoint.getQualifiers().toArray(new Annotation[0]), this);
Bean<?> resolvedBean = getBean(element, element.getBindingsAsArray());
return getReference(injectionPoint, resolvedBean, creationalContext);
+ }
+ else
+ {
+ return DecorationHelper.getHelperStack().peek().getNextDelegate(injectionPoint, creationalContext);
+ }
}
public <T> Bean<T> getBean(WeldAnnotated<T, ?> element, Annotation... bindings)
Copied: core/trunk/impl/src/main/java/org/jboss/weld/util/Decorators.java (from rev 5635, core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Decorators.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Decorators.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc., 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.
+ */
+
+package org.jboss.weld.util;
+
+import org.jboss.weld.exceptions.ForbiddenStateException;
+import org.jboss.weld.introspector.MethodSignature;
+import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.introspector.WeldMethod;
+import org.jboss.weld.manager.BeanManagerImpl;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.jboss.weld.logging.messages.BeanMessage.UNABLE_TO_PROCESS;
+
+import javax.inject.Inject;
+
+/**
+ * Helper class for {@link javax.enterprise.inject.spi.Decorator} inspections.
+ *
+ * @author Marius Bogoevici
+ */
+public class Decorators
+{
+ public static Set<MethodSignature> getDecoratedMethodSignatures(BeanManagerImpl beanManager, Set<Type> decoratedTypes)
+ {
+ Set<MethodSignature> methodSignatures = new HashSet<MethodSignature>();
+ for (Type type: decoratedTypes)
+ {
+ WeldClass<?> weldClass = getWeldClassOfDecoratedType(beanManager, type);
+ for (WeldMethod<?, ?> method : weldClass.getWeldMethods())
+ {
+ if (!methodSignatures.contains(method.getSignature()))
+ {
+ methodSignatures.add(method.getSignature());
+ }
+ }
+ }
+ return methodSignatures;
+ }
+
+ public static WeldClass<?> getWeldClassOfDecoratedType(BeanManagerImpl beanManager, Type type)
+ {
+ if (type instanceof Class<?>)
+ {
+ return (WeldClass<?>) beanManager.createAnnotatedType((Class<?>) type);
+ }
+ if (type instanceof ParameterizedType && (((ParameterizedType) type).getRawType() instanceof Class))
+ {
+ return (WeldClass<?>) beanManager.createAnnotatedType((Class<?>) ((ParameterizedType) type).getRawType());
+ }
+ throw new ForbiddenStateException(UNABLE_TO_PROCESS, type);
+ }
+}
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java 2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java 2010-01-27 06:18:35 UTC (rev 5637)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., 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.
- */
-
-package org.jboss.weld.util;
-
-import org.jboss.weld.exceptions.ForbiddenStateException;
-import org.jboss.weld.introspector.MethodSignature;
-import org.jboss.weld.introspector.WeldClass;
-import org.jboss.weld.introspector.WeldMethod;
-import org.jboss.weld.manager.BeanManagerImpl;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.jboss.weld.logging.messages.BeanMessage.UNABLE_TO_PROCESS;
-
-/**
- * Helper class for {@link org.jboss.deployers.spi.deployer.Deployer} inspections.
- *
- * @author Marius Bogoevici
- */
-public class Deployers
-{
- public static Set<MethodSignature> getDecoratedMethodSignatures(BeanManagerImpl beanManager, Set<Type> decoratedTypes)
- {
- Set<MethodSignature> methodSignatures = new HashSet<MethodSignature>();
- for (Type type: decoratedTypes)
- {
- WeldClass<?> weldClass = getWeldClassOfDecoratedType(beanManager, type);
- for (WeldMethod<?, ?> method : weldClass.getWeldMethods())
- {
- if (!methodSignatures.contains(method.getSignature()))
- {
- methodSignatures.add(method.getSignature());
- }
- }
- }
- return methodSignatures;
- }
-
- public static WeldClass<?> getWeldClassOfDecoratedType(BeanManagerImpl beanManager, Type type)
- {
- if (type instanceof Class<?>)
- {
- return (WeldClass<?>) beanManager.createAnnotatedType((Class<?>) type);
- }
- if (type instanceof ParameterizedType && (((ParameterizedType) type).getRawType() instanceof Class))
- {
- return (WeldClass<?>) beanManager.createAnnotatedType((Class<?>) ((ParameterizedType) type).getRawType());
- }
- throw new ForbiddenStateException(UNABLE_TO_PROCESS, type);
- }
-}
14 years, 11 months
Weld SVN: r5636 - in core/trunk/impl/src/main/java/org/jboss/weld: event and 1 other directory.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-01-26 18:36:10 -0500 (Tue, 26 Jan 2010)
New Revision: 5636
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractContainerEvent.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDefinitionContainerEvent.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDeploymentContainerEvent.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeShutdownImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java
Log:
WELD-402
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractContainerEvent.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractContainerEvent.java 2010-01-26 18:49:28 UTC (rev 5635)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractContainerEvent.java 2010-01-26 23:36:10 UTC (rev 5636)
@@ -27,7 +27,6 @@
import org.jboss.weld.bootstrap.BeanDeployment;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.exceptions.DeploymentException;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.util.reflection.ParameterizedTypeImpl;
@@ -93,10 +92,6 @@
{
getErrors().add(e);
}
- if (!getErrors().isEmpty())
- {
- throw new DeploymentException(getErrors());
- }
}
protected Type getRawType()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDefinitionContainerEvent.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDefinitionContainerEvent.java 2010-01-26 18:49:28 UTC (rev 5635)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDefinitionContainerEvent.java 2010-01-26 23:36:10 UTC (rev 5636)
@@ -17,7 +17,10 @@
package org.jboss.weld.bootstrap.events;
import java.lang.reflect.Type;
+import java.util.Map;
+import org.jboss.weld.bootstrap.BeanDeployment;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.exceptions.DefinitionException;
import org.jboss.weld.manager.BeanManagerImpl;
@@ -43,4 +46,14 @@
}
}
+ @Override
+ protected void fire(Map<BeanDeploymentArchive, BeanDeployment> beanDeployments)
+ {
+ super.fire(beanDeployments);
+ if (!getErrors().isEmpty())
+ {
+ throw new DefinitionException(getErrors());
+ }
+ }
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDeploymentContainerEvent.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDeploymentContainerEvent.java 2010-01-26 18:49:28 UTC (rev 5635)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDeploymentContainerEvent.java 2010-01-26 23:36:10 UTC (rev 5636)
@@ -17,7 +17,10 @@
package org.jboss.weld.bootstrap.events;
import java.lang.reflect.Type;
+import java.util.Map;
+import org.jboss.weld.bootstrap.BeanDeployment;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.exceptions.DeploymentException;
import org.jboss.weld.manager.BeanManagerImpl;
@@ -43,4 +46,14 @@
}
}
+ @Override
+ protected void fire(Map<BeanDeploymentArchive, BeanDeployment> beanDeployments)
+ {
+ super.fire(beanDeployments);
+ if (!getErrors().isEmpty())
+ {
+ throw new DeploymentException(getErrors());
+ }
+ }
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeShutdownImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeShutdownImpl.java 2010-01-26 18:49:28 UTC (rev 5635)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeShutdownImpl.java 2010-01-26 23:36:10 UTC (rev 5636)
@@ -16,6 +16,8 @@
*/
package org.jboss.weld.bootstrap.events;
+import static org.jboss.weld.logging.Category.BOOTSTRAP;
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
import static org.jboss.weld.util.reflection.Reflections.EMPTY_TYPES;
import java.util.Map;
@@ -25,6 +27,8 @@
import org.jboss.weld.bootstrap.BeanDeployment;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.manager.BeanManagerImpl;
+import org.slf4j.Logger;
+import org.slf4j.ext.XLogger;
/**
* @author pmuir
@@ -33,6 +37,9 @@
public class BeforeShutdownImpl extends AbstractContainerEvent implements BeforeShutdown
{
+ private static final XLogger xLog = loggerFactory().getXLogger(BOOTSTRAP);
+ private static final Logger log = loggerFactory().getLogger(BOOTSTRAP);
+
public static void fire(BeanManagerImpl beanManager, Map<BeanDeploymentArchive, BeanDeployment> beanDeployments)
{
if (beanDeployments == null)
@@ -50,5 +57,19 @@
{
super(beanManager, BeforeShutdown.class, EMPTY_TYPES);
}
+
+ @Override
+ protected void fire(Map<BeanDeploymentArchive, BeanDeployment> beanDeployments)
+ {
+ super.fire(beanDeployments);
+ if (!getErrors().isEmpty())
+ {
+ log.error("Exception(s) thrown during observer of BeforeShutdown");
+ for (Throwable t: getErrors())
+ {
+ log.error("", t);
+ }
+ }
+ }
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java 2010-01-26 18:49:28 UTC (rev 5635)
+++ core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java 2010-01-26 23:36:10 UTC (rev 5636)
@@ -243,15 +243,15 @@
protected boolean ignore(T event)
{
Class<?> eventType = event.getClass();
- if (AbstractContainerEvent.class.isAssignableFrom(eventType))
+ // This is a container lifeycle event, ensure we are firing to an extension
+ if (AbstractContainerEvent.class.isAssignableFrom(eventType) && !Extension.class.isAssignableFrom(getBeanClass()))
{
- // This is a container lifeycle event, ensure we are firing to an extension
- if (!Extension.class.isAssignableFrom(getBeanClass()))
- {
- return true;
- }
+ return true;
}
- return false;
+ else
+ {
+ return false;
+ }
}
@Override
14 years, 11 months
Weld SVN: r5635 - in core/trunk/tests/src/test/java/org/jboss/weld/tests: resources and 1 other directory.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-01-26 13:49:28 -0500 (Tue, 26 Jan 2010)
New Revision: 5635
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/
core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/ResourceTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/UTConsumer.java
Log:
WELDINT-35
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/ResourceTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/ResourceTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/ResourceTest.java 2010-01-26 18:49:28 UTC (rev 5635)
@@ -0,0 +1,20 @@
+package org.jboss.weld.tests.resources;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+@Artifact
+@IntegrationTest
+public class ResourceTest extends AbstractWeldTest
+{
+
+ @Test(description="WELD-385")
+ public void testUTInjectedByResource()
+ {
+ assert getReference(UTConsumer.class).getUserTransaction() != null;
+ }
+
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/ResourceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/UTConsumer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/UTConsumer.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/UTConsumer.java 2010-01-26 18:49:28 UTC (rev 5635)
@@ -0,0 +1,17 @@
+package org.jboss.weld.tests.resources;
+
+import javax.annotation.Resource;
+import javax.transaction.UserTransaction;
+
+public class UTConsumer
+{
+
+ @Resource
+ UserTransaction userTransaction;
+
+ public UserTransaction getUserTransaction()
+ {
+ return userTransaction;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/resources/UTConsumer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
14 years, 11 months
Weld SVN: r5634 - api/trunk/weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-01-26 13:20:21 -0500 (Tue, 26 Jan 2010)
New Revision: 5634
Modified:
api/trunk/weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/AbstractResourceServices.java
Log:
minor
Modified: api/trunk/weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/AbstractResourceServices.java
===================================================================
--- api/trunk/weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/AbstractResourceServices.java 2010-01-26 16:09:57 UTC (rev 5633)
+++ api/trunk/weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/AbstractResourceServices.java 2010-01-26 18:20:21 UTC (rev 5634)
@@ -31,9 +31,6 @@
{
private static final String RESOURCE_LOOKUP_PREFIX = "java:comp/env";
- /* (non-Javadoc)
- * @see org.jboss.weld.resources.spi.helpers.ResourceServices#resolveResource(javax.inject.manager.InjectionPoint)
- */
public Object resolveResource(InjectionPoint injectionPoint)
{
if (!injectionPoint.getAnnotated().isAnnotationPresent(Resource.class))
14 years, 11 months
Weld SVN: r5633 - in core/trunk/tests/src/test: java/org/jboss/weld/tests/producer/field/named and 4 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-01-26 11:09:57 -0500 (Tue, 26 Jan 2010)
New Revision: 5633
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/
core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NewUserAction.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/User.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/faces-config.xml
core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/view.xhtml
core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/web.xml
Log:
verify bug report in forum post
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java 2010-01-26 16:09:57 UTC (rev 5633)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.
+ */
+
+package org.jboss.weld.tests.producer.field.named;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+
+/**
+ * <p>Check what happens when session.invalidate() is called.</p>
+ *
+ * @author Pete Muir
+ *
+ */
+@Artifact(addCurrentPackage=false)
+(a)Classes({User.class, NewUserAction.class})
+@IntegrationTest(runLocally=true)
+@Resources({
+ @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
+ @Resource(destination="view.xhtml", source="view.xhtml"),
+ @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
+})
+public class NamedProducerTest extends AbstractWeldTest
+{
+ @Test(description = "forum post")
+ public void testNamedProducerWorks() throws Exception
+ {
+ WebClient client = new WebClient();
+ client.setThrowExceptionOnFailingStatusCode(false);
+
+ HtmlPage page = client.getPage(getPath("/view.jsf"));
+ // Check the page rendered ok
+ assert getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton") != null;
+ }
+
+ protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
+ {
+ Set<T> result = new HashSet<T>();
+
+ for (HtmlElement element : rootElement.getAllHtmlChildElements())
+ {
+ result.addAll(getElements(element, elementClass));
+ }
+
+ if (elementClass.isInstance(rootElement))
+ {
+ result.add(elementClass.cast(rootElement));
+ }
+ return result;
+
+ }
+
+ protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id)
+ {
+
+ Set<T> inputs = getElements(page.getBody(), elementClass);
+ for (T input : inputs)
+ {
+ if (input.getId().contains(id))
+ {
+ return input;
+ }
+ }
+ return null;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NewUserAction.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NewUserAction.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NewUserAction.java 2010-01-26 16:09:57 UTC (rev 5633)
@@ -0,0 +1,20 @@
+package org.jboss.weld.tests.producer.field.named;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+@RequestScoped
+@Named
+public class NewUserAction
+{
+
+ @Produces
+ @Named("newUser")
+ private User newUser = new User();
+
+ public void persist()
+ {
+ System.out.println("new user's name: " + newUser.getName());
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NewUserAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/User.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/User.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/User.java 2010-01-26 16:09:57 UTC (rev 5633)
@@ -0,0 +1,16 @@
+package org.jboss.weld.tests.producer.field.named;
+
+public class User
+{
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/User.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/faces-config.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/faces-config.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/faces-config.xml 2010-01-26 16:09:57 UTC (rev 5633)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<faces-config version="2.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-facesconfig_2_0.xsd">
+
+</faces-config>
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/view.xhtml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/view.xhtml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/view.xhtml 2010-01-26 16:09:57 UTC (rev 5633)
@@ -0,0 +1,16 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html">
+ <h:head>
+ <title>Facelet Title</title>
+ </h:head>
+ <h:body>
+ Hello from Facelets
+ <h:form id="form">
+ <h:panelGrid columns="2">
+ <h:outputLabel value="Name:" />
+ <h:inputText value="#{newUser.name}" id="userNameInput" />
+ <h:commandButton action="#{newUserAction.persist}" value="Save" id="saveButton" />
+ </h:panelGrid>
+ </h:form>
+ </h:body>
+</html>
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/view.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/web.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/web.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/web.xml 2010-01-26 16:09:57 UTC (rev 5633)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" 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_2_5.xsd">
+ <display-name>Weld Core Tests</display-name>
+
+ <!-- JSF -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 11 months
Weld SVN: r5632 - in core/trunk: impl/src/main/java/org/jboss/weld/bean and 1 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2010-01-26 10:15:11 -0500 (Tue, 26 Jan 2010)
New Revision: 5632
Modified:
core/trunk/bom/pom.xml
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml
Log:
WELD-400, WELD-325
Modified: core/trunk/bom/pom.xml
===================================================================
--- core/trunk/bom/pom.xml 2010-01-26 04:04:23 UTC (rev 5631)
+++ core/trunk/bom/pom.xml 2010-01-26 15:15:11 UTC (rev 5632)
@@ -76,7 +76,7 @@
<javassist.version>3.11.0.GA</javassist.version>
<cdi.tck.version>1.0.1-CR1</cdi.tck.version>
<atinject.tck.version>1.0.0-PFD-3</atinject.tck.version>
- <jboss.interceptor.version>1.0.0-CR8</jboss.interceptor.version>
+ <jboss.interceptor.version>1.0.0-CR9</jboss.interceptor.version>
<slf4j.version>1.5.10</slf4j.version>
<cal10n.version>0.7.2</cal10n.version>
</properties>
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-01-26 04:04:23 UTC (rev 5631)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-01-26 15:15:11 UTC (rev 5632)
@@ -52,7 +52,8 @@
import org.jboss.interceptor.model.InterceptionModel;
import org.jboss.interceptor.model.InterceptionModelBuilder;
-import org.jboss.interceptor.model.InterceptorClassMetadataImpl;
+import org.jboss.interceptor.model.InterceptorClassMetadata;
+import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
import org.jboss.interceptor.util.InterceptionUtils;
import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
@@ -626,7 +627,7 @@
}
}
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
- InterceptorClassMetadataImpl interceptorClassMetadata = new InterceptorClassMetadataImpl(getType());
+ InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getType(), true);
hasSerializationOrInvocationInterceptorMethods = !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_INVOKE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.AROUND_TIMEOUT).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.PRE_PASSIVATE).isEmpty() || !interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.POST_ACTIVATE).isEmpty();
if (interceptionModel.getAllInterceptors().size() > 0 || hasSerializationOrInvocationInterceptorMethods)
beanManager.getClassDeclaredInterceptorsRegistry().registerInterceptionModel(getType(), builder.build());
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-01-26 04:04:23 UTC (rev 5631)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-01-26 15:15:11 UTC (rev 5632)
@@ -41,6 +41,7 @@
import javax.enterprise.inject.spi.Interceptor;
import javax.enterprise.inject.spi.PassivationCapable;
+import javassist.util.proxy.MethodHandler;
import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
import org.jboss.interceptor.registry.InterceptorRegistry;
@@ -63,6 +64,7 @@
import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
import org.jboss.weld.util.AnnotatedTypes;
import org.jboss.weld.util.Beans;
+import org.jboss.weld.util.CleanableMethodHandler;
import org.jboss.weld.util.reflection.Reflections;
import org.slf4j.cal10n.LocLogger;
import org.slf4j.ext.XLogger;
@@ -575,7 +577,11 @@
interceptionHandlerFactories.add(new CdiInterceptorHandlerFactory<T>(creationalContext, beanManager));
}
if (interceptionRegistries.size() > 0)
- instance = new InterceptorProxyCreatorImpl(interceptionRegistries, interceptionHandlerFactories).createProxyFromInstance(instance, getType());
+ {
+ InterceptorProxyCreatorImpl interceptorProxyCreator = new InterceptorProxyCreatorImpl(interceptionRegistries, interceptionHandlerFactories);
+ MethodHandler methodHandler = new CleanableMethodHandler(interceptorProxyCreator.getMethodHandler(instance, getType()));
+ instance = interceptorProxyCreator.createProxyInstance(InterceptorProxyCreatorImpl.createProxyClassWithHandler(getType(), methodHandler), methodHandler);
+ }
}
catch (Exception e)
Modified: core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml
===================================================================
--- core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml 2010-01-26 04:04:23 UTC (rev 5631)
+++ core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml 2010-01-26 15:15:11 UTC (rev 5632)
@@ -59,6 +59,13 @@
<exclude name="testObserverMethodOnEnterpriseBeanNotBusinessMethodOrStaticFails" />
</methods>
</class>
+
+ <!-- WELD-325 fixed, pending on CDITCK-102 -->.
+ <class name="org.jboss.jsr299.tck.tests.context.dependent.DependentContextTest">
+ <methods>
+ <exclude name="testDependentScopedInterceptorsAreDependentObjectsOfBean"/>
+ </methods>
+ </class>
<!-- Issues in JBoss AS -->
14 years, 11 months
Weld SVN: r5631 - cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2010-01-25 23:04:23 -0500 (Mon, 25 Jan 2010)
New Revision: 5631
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/TransactionalInterceptor.java
Log:
CDITCK-102
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/TransactionalInterceptor.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/TransactionalInterceptor.java 2010-01-26 03:49:45 UTC (rev 5630)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/TransactionalInterceptor.java 2010-01-26 04:04:23 UTC (rev 5631)
@@ -34,8 +34,9 @@
return ctx.proceed();
}
- @PreDestroy public void destroy()
+ @PreDestroy public void destroy(InvocationContext ctx) throws Exception
{
destroyed = true;
+ ctx.proceed();
}
}
14 years, 11 months
Weld SVN: r5630 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2010-01-25 22:49:45 -0500 (Mon, 25 Jan 2010)
New Revision: 5630
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/TransactionalInterceptor.java
Log:
CDITCK-102
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/TransactionalInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/TransactionalInterceptor.java 2010-01-25 22:34:32 UTC (rev 5629)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/TransactionalInterceptor.java 2010-01-26 03:49:45 UTC (rev 5630)
@@ -34,8 +34,9 @@
return ctx.proceed();
}
- @PreDestroy public void destroy()
+ @PreDestroy public void destroy(InvocationContext ctx) throws Exception
{
destroyed = true;
+ ctx.proceed();
}
}
14 years, 11 months