Skip to content

Instantly share code, notes, and snippets.

@xandreafonso
Last active April 6, 2017 12:10
Show Gist options
  • Save xandreafonso/7aa0ff916d757bb308acbaeba728ff43 to your computer and use it in GitHub Desktop.
Save xandreafonso/7aa0ff916d757bb308acbaeba728ff43 to your computer and use it in GitHub Desktop.
CDI em ambiente desktop
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>2.4.0.Final</version>
</dependency>
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
public class WeldSe {
public static void main(String[] args) {
Weld weld = new Weld();
WeldContainer weldContainer = weld.initialize();
Instance<Object> instance = weldContainer.instance();
WeldSe weldSe = instance.select(WeldSe.class).get();
weldSe.run();
weldContainer.shutdown();
}
@Inject @Parameters
private List<String> args;
@Inject
private AnyService anyService;
public void run() {
anyService.doWork(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment