Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
163 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/LogFacatory.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,23 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package org.jboss.weld.tests.decorators.stackoverflow; | ||
|
||
import javax.enterprise.inject.Produces; | ||
import javax.enterprise.inject.spi.InjectionPoint; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Factory class that produces Logger for a given be to injected class | ||
* | ||
* @author wayne | ||
*/ | ||
public class LogFacatory { | ||
@Produces | ||
public Logger getLogger(InjectionPoint ip){ | ||
return LoggerFactory.getLogger(ip.getMember().getDeclaringClass()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/PaymentService.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,16 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package org.jboss.weld.tests.decorators.stackoverflow; | ||
|
||
import java.math.BigDecimal; | ||
|
||
/** | ||
* | ||
* @author wayne | ||
*/ | ||
public interface PaymentService { | ||
boolean pay(String account, BigDecimal amount); | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/SecurePaymentService.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,39 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package org.jboss.weld.tests.decorators.stackoverflow; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import javax.decorator.Decorator; | ||
import javax.decorator.Delegate; | ||
import javax.inject.Inject; | ||
|
||
import org.slf4j.Logger; | ||
|
||
/** | ||
* Secure PaymentService implemented by decator | ||
* | ||
* @author wayne | ||
*/ | ||
@Decorator | ||
class SecurePaymentService implements PaymentService | ||
{ | ||
@Inject | ||
private Logger logger; | ||
|
||
@Inject | ||
@Delegate | ||
@SimpleService | ||
private PaymentService paymentService; | ||
|
||
public boolean pay(String account, BigDecimal amount) | ||
{ | ||
logger.info("I'm a secure payment service"); | ||
|
||
return paymentService.pay(account, amount); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/SimplePaymentService.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,32 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package org.jboss.weld.tests.decorators.stackoverflow; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
import org.slf4j.Logger; | ||
|
||
/** | ||
* | ||
* @author wayne | ||
*/ | ||
@SimpleService | ||
@ApplicationScoped | ||
public class SimplePaymentService implements PaymentService | ||
{ | ||
@Inject | ||
Logger logger; | ||
|
||
public boolean pay(String account, BigDecimal amount) | ||
{ | ||
logger.info("Pay ${} for {}.", amount, account); | ||
|
||
return true; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/SimpleService.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,23 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package org.jboss.weld.tests.decorators.stackoverflow; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import javax.inject.Qualifier; | ||
|
||
/** | ||
* | ||
* @author wayne | ||
*/ | ||
@Qualifier | ||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface SimpleService { | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/StackOverFlowTest.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,23 @@ | ||
package org.jboss.weld.tests.decorators.stackoverflow; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import javax.enterprise.util.AnnotationLiteral; | ||
|
||
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; | ||
|
||
@Artifact | ||
@BeansXml("beans.xml") | ||
public class StackOverFlowTest extends AbstractWeldTest | ||
{ | ||
|
||
@Test(description="WELD-296", groups="broken") | ||
public void test() | ||
{ | ||
getCurrentManager().getInstanceByType(PaymentService.class, new AnnotationLiteral<SimpleService>() {}).pay("Pete", new BigDecimal(100)); | ||
} | ||
|
||
} |
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
7 changes: 7 additions & 0 deletions
7
tests/src/test/resources/org/jboss/weld/tests/decorators/stackoverflow/beans.xml
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<beans> | ||
<decorators> | ||
<class>org.jboss.weld.tests.decorators.stackoverflow.SecurePaymentService</class> | ||
</decorators> | ||
</beans> |