<dependencies>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se</artifactId>
<version>XXX</version>
</dependency>
</dependencies>
groovy
dependencies {
implementation 'org.jboss.weld.se:weld-se:XXX'
}
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
public class MyApp {
private static WeldContainer container;
public static void main(String[] args) {
Weld weld = new Weld();
container = weld.initialize();
weld.shutdown();
}
}
import javax.inject.Inject;
public class MyService {
@Inject
private MyDependency dependency;
// ...
}
import javax.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class MyBean {
// ...
}
import javax.enterprise.event.Observes;
public class MyEventListener {
public void handleEvent(@Observes MyEvent event) {
}
}
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
@Interceptor
@MyInterceptorBinding
public class MyInterceptor {
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
Object result = context.proceed();
return result;
}
}
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
public class MyDependencyProducer {
@Inject
private SomeConfig config;
@Produces
public MyDependency createDependency() {
if (config.isEnabled()) {
return new MyDependencyImpl1();
} else {
return new MyDependencyImpl2();
}
}
}