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
5 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
tests/src/test/java/org/jboss/weld/tests/extensions/Capercaillie.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,11 @@ | ||
package org.jboss.weld.tests.extensions; | ||
|
||
public class Capercaillie | ||
{ | ||
|
||
public Capercaillie(String name) | ||
{ | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
} |
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
30 changes: 30 additions & 0 deletions
30
tests/src/test/java/org/jboss/weld/tests/extensions/Woodland.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,30 @@ | ||
package org.jboss.weld.tests.extensions; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.enterprise.inject.Produces; | ||
|
||
public class Woodland | ||
{ | ||
|
||
private static boolean postConstructCalled; | ||
|
||
@Produces | ||
private Capercaillie capercaillie = new Capercaillie("bob"); | ||
|
||
@PostConstruct | ||
public void postConstruct() | ||
{ | ||
postConstructCalled = true; | ||
} | ||
|
||
public static boolean isPostConstructCalled() | ||
{ | ||
return postConstructCalled; | ||
} | ||
|
||
public static void reset() | ||
{ | ||
postConstructCalled = false; | ||
} | ||
|
||
} |
99 changes: 99 additions & 0 deletions
99
tests/src/test/java/org/jboss/weld/tests/extensions/WoodlandExtension.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,99 @@ | ||
package org.jboss.weld.tests.extensions; | ||
|
||
import java.util.Set; | ||
|
||
import javax.enterprise.context.spi.CreationalContext; | ||
import javax.enterprise.event.Observes; | ||
import javax.enterprise.inject.spi.BeforeShutdown; | ||
import javax.enterprise.inject.spi.Extension; | ||
import javax.enterprise.inject.spi.InjectionPoint; | ||
import javax.enterprise.inject.spi.InjectionTarget; | ||
import javax.enterprise.inject.spi.ProcessInjectionTarget; | ||
|
||
public class WoodlandExtension implements Extension | ||
{ | ||
|
||
private static boolean injectCalled; | ||
private static boolean postConstructCalled; | ||
private static boolean preDestroyCalled; | ||
private static boolean produceCalled; | ||
|
||
public void cleanup(@Observes BeforeShutdown shutdown) | ||
{ | ||
reset(); | ||
Woodland.reset(); | ||
} | ||
|
||
public void enhanceWoodland(final @Observes ProcessInjectionTarget<Woodland> processWoodland) | ||
{ | ||
final InjectionTarget<Woodland> it = processWoodland.getInjectionTarget(); | ||
processWoodland.setInjectionTarget(new InjectionTarget<Woodland>() | ||
{ | ||
|
||
public void inject(Woodland instance, CreationalContext<Woodland> ctx) | ||
{ | ||
injectCalled = true; | ||
it.inject(instance, ctx); | ||
} | ||
|
||
public void postConstruct(Woodland instance) | ||
{ | ||
postConstructCalled = true; | ||
it.postConstruct(instance); | ||
} | ||
|
||
public void preDestroy(Woodland instance) | ||
{ | ||
preDestroyCalled = true; | ||
it.preDestroy(instance); | ||
} | ||
|
||
public void dispose(Woodland instance) | ||
{ | ||
// No-op for class bean | ||
|
||
} | ||
|
||
public Set<InjectionPoint> getInjectionPoints() | ||
{ | ||
return it.getInjectionPoints(); | ||
} | ||
|
||
public Woodland produce(CreationalContext<Woodland> ctx) | ||
{ | ||
produceCalled = true; | ||
return it.produce(ctx); | ||
} | ||
|
||
}); | ||
} | ||
|
||
public static void reset() | ||
{ | ||
injectCalled = false; | ||
postConstructCalled = false; | ||
preDestroyCalled = false; | ||
preDestroyCalled = false; | ||
} | ||
|
||
public static boolean isInjectCalled() | ||
{ | ||
return injectCalled; | ||
} | ||
|
||
public static boolean isPostConstructCalled() | ||
{ | ||
return postConstructCalled; | ||
} | ||
|
||
public static boolean isPreDestroyCalled() | ||
{ | ||
return preDestroyCalled; | ||
} | ||
|
||
public static boolean isProduceCalled() | ||
{ | ||
return produceCalled; | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
.../src/test/resources/org/jboss/weld/tests/extensions/javax.enterprise.inject.spi.Extension
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
org.jboss.weld.tests.extensions.SimpleExtension | ||
org.jboss.weld.tests.extensions.ExtensionObserver | ||
org.jboss.weld.tests.extensions.ExtensionObserver | ||
org.jboss.weld.tests.extensions.WoodlandExtension |