私はjavaSEでweldの非常に単純な実装をセットアップしようとしています。
私は拡張クラスを持っています:
public class MyExtension implements Extension {
void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd) {
System.out.println("Starting scan...");
}
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> annotatedType, BeanManager beanManager) {
System.out.println("Scanning type: " + annotatedType.getAnnotatedType().getJavaClass().getName());
}
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd) {
System.out.println("Finished the scanning process");
}
public void main(@Observes ContainerInitialized event) {
System.out.println("Starting application");
new Test();
}
}
次に、注入したい単純なクラスがあります。
public class SimpleClass {
public void doSomething() {
System.out.println("Consider it done");
}
}
そして最後に、私がそれを注入したいクラス:
public class Test {
@Inject
private SimpleClass simple;
@PostConstruct
public void initialize() {
simple.doSomething();
}
@PreDestroy
public void stop() {
System.out.println("Stopping");
}
}
結果の出力は次のとおりです。
80 [main] INFO org.jboss.weld.Version - WELD-000900 1.1.10 (Final)
272 [main] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
Starting scan...
Scanning type: test.Test
Scanning type: test.SimpleClass
Scanning type: test.MyExtension
640 [main] WARN org.jboss.weld.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
640 [main] WARN org.jboss.weld.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
Finished the scanning process
Starting application
Test()が構築され、期待されるテキストを出力するpostconstructメソッドが呼び出されるときに、単純なクラスが注入されることを期待します。
私は正確に何を間違っているのですか?