File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed 
java/org/soujava/demos/mongodb/config Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 1+ package  org .soujava .demos .mongodb .config ;
2+ 
3+ import  io .cucumber .core .backend .ObjectFactory ;
4+ import  org .jboss .weld .environment .se .Weld ;
5+ import  org .jboss .weld .environment .se .WeldContainer ;
6+ 
7+ import  java .util .HashMap ;
8+ import  java .util .Map ;
9+ 
10+ public  class  WeldCucumberObjectFactory  implements  ObjectFactory  {
11+ 
12+     private  Weld  weld ;
13+     private  WeldContainer  container ;
14+     private  final  Map <Class <?>, Object > instances  = new  HashMap <>();
15+ 
16+     @ Override 
17+     public  void  start () {
18+         weld  = new  Weld ();
19+         container  = weld .initialize ();
20+     }
21+ 
22+     @ Override 
23+     public  void  stop () {
24+         if  (weld  != null ) {
25+             weld .shutdown ();
26+         }
27+         instances .clear ();
28+     }
29+ 
30+     @ Override 
31+     public  boolean  addClass (Class <?> stepClass ) {
32+         return  true ; // accept all step classes 
33+     }
34+ 
35+     @ Override 
36+     public  <T > T  getInstance (Class <T > type ) {
37+         return  (T ) instances .computeIfAbsent (type , c  -> container .select (type ).get ());
38+     }
39+ }
Load Diff This file was deleted. 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments