/** Shuts down all the containers initialized by this builder. */ public void shutdown() { if (!initializedContainers.isEmpty()) { for (WeldContainer container : initializedContainers.values()) { container.shutdown(); } } }
@Override public void run() { for (String id : getRunningContainerIds()) { WeldContainer container = instance(id); if (container != null) { container.shutdown(); // At this time the logger service may not be available - print some basic info to the // standard output System.out.println(String.format("Weld SE container %s shut down by shutdown hook", id)); } } }
public static void main(String[] args) { // MyFactory m = MyFactory.getInstance(); // MyService service = m.getMyServiceImpl(); Weld weld = new Weld(); WeldContainer container = weld.initialize(); MyService service = container.select(MyService.class).get(); System.out.println(service.getValue()); Scanner s = new Scanner(System.in); s.nextInt(); container.shutdown(); }
@Override public void close() { shutdown(); }