Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-460 this also fixed adding multiple ejb's with the same java typ…
…e through BeforeBeanDiscovery.addAnnotatedType()
- Loading branch information
1 parent
37c4d89
commit f0a1522
Showing
12 changed files
with
337 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...est/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeEjbExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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.extensions.annotatedType.ejb; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Method; | ||
|
||
import javax.enterprise.event.Observes; | ||
import javax.enterprise.inject.Produces; | ||
import javax.enterprise.inject.spi.BeforeBeanDiscovery; | ||
import javax.enterprise.inject.spi.Extension; | ||
import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
import javax.enterprise.util.AnnotationLiteral; | ||
|
||
import org.jboss.weld.tests.util.annotated.TestAnnotatedTypeBuilder; | ||
|
||
public class AnnotatedTypeEjbExtension implements Extension | ||
{ | ||
/** | ||
* Adds two ejb beans | ||
*/ | ||
public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery beforeBeanDiscovery) | ||
{ | ||
TestAnnotatedTypeBuilder<Lathe> builder = new TestAnnotatedTypeBuilder<Lathe>(Lathe.class); | ||
builder.addToClass(new AnnotationLiteral<SmallLathe>() { }); | ||
beforeBeanDiscovery.addAnnotatedType(builder.create()); | ||
builder = new TestAnnotatedTypeBuilder<Lathe>(Lathe.class); | ||
builder.addToClass(new AnnotationLiteral<BigLathe>() { }); | ||
beforeBeanDiscovery.addAnnotatedType(builder.create()); | ||
} | ||
/** | ||
* Adds annotations to an EJB | ||
*/ | ||
public void overrideLatheAnnotations(@Observes ProcessAnnotatedType<Lathe> event) throws SecurityException, NoSuchMethodException | ||
{ | ||
TestAnnotatedTypeBuilder<Lathe> builder = new TestAnnotatedTypeBuilder<Lathe>(Lathe.class); | ||
for(Annotation a : event.getAnnotatedType().getAnnotations()) | ||
{ | ||
builder.addToClass(a); | ||
} | ||
Method method = Lathe.class.getMethod("doWork"); | ||
builder.addToMethod(method, new AnnotationLiteral<ConveyorShaft>() {}); | ||
builder.addToMethod(method, new AnnotationLiteral<Produces>() {}); | ||
event.setAnnotatedType(builder.create()); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
.../java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeSessionBeanTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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.extensions.annotatedType.ejb; | ||
|
||
import javax.enterprise.util.AnnotationLiteral; | ||
|
||
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.Packaging; | ||
import org.jboss.testharness.impl.packaging.PackagingType; | ||
import org.jboss.testharness.impl.packaging.jsr299.Extension; | ||
import org.jboss.weld.test.AbstractWeldTest; | ||
import org.testng.annotations.Test; | ||
/** | ||
* Tests that it is possible to override ejb annotations through the SPI | ||
* @author Stuart Douglas <stuart@baileyroberts.com.au> | ||
* | ||
*/ | ||
@Artifact | ||
@Packaging(PackagingType.EAR) | ||
@IntegrationTest | ||
@Extension("javax.enterprise.inject.spi.Extension") | ||
@Classes(packages = { "org.jboss.weld.tests.util.annotated" }) | ||
public class AnnotatedTypeSessionBeanTest extends AbstractWeldTest | ||
{ | ||
@Test | ||
public void testOverridingEjbAnnotations() | ||
{ | ||
Shaft conveyerShaft = getReference(Shaft.class, new AnnotationLiteral<ConveyorShaft>() { }); | ||
assert conveyerShaft != null; | ||
} | ||
|
||
@Test | ||
public void testAddingBultipleBeansPerEjbClass() | ||
{ | ||
LatheLocal bigLathe = getReference(LatheLocal.class, new AnnotationLiteral<BigLathe>() { }); | ||
assert bigLathe != null; | ||
LatheLocal smallLathe = getReference(LatheLocal.class, new AnnotationLiteral<SmallLathe>() { }); | ||
assert smallLathe != null; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/BigLathe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.extensions.annotatedType.ejb; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import javax.inject.Qualifier; | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface BigLathe | ||
{ | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/ConveyorShaft.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.extensions.annotatedType.ejb; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import javax.inject.Qualifier; | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ConveyorShaft | ||
{ | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Lathe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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.extensions.annotatedType.ejb; | ||
|
||
import javax.ejb.Stateless; | ||
|
||
@Stateless | ||
public class Lathe implements LatheLocal | ||
{ | ||
public Shaft doWork() | ||
{ | ||
return new Shaft(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/LatheLocal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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.extensions.annotatedType.ejb; | ||
|
||
import javax.ejb.Local; | ||
|
||
@Local | ||
public interface LatheLocal | ||
{ | ||
|
||
public Shaft doWork(); | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Shaft.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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.extensions.annotatedType.ejb; | ||
|
||
public class Shaft | ||
{ | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/SmallLathe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.extensions.annotatedType.ejb; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import javax.inject.Qualifier; | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface SmallLathe | ||
{ | ||
|
||
} |
Oops, something went wrong.