Package se.jbee.inject

Examples of se.jbee.inject.Repository.serve()


      if ( repository == null ) {
        // since each thread is just accessing its own repo there cannot be a repo set for the running thread after we checked for null
        repository = repositoryScope.init();
        threadRepository.set( repository );
      }
      return repository.serve( demand, injectable );
    }

    @Override
    public Repository init() {
      return this;
View Full Code Here


    Demand<B> db = demand( resource( B.class ), dependency( B.class ), 2, 2 );
    A a = new A();
    B b = new B();
    Injectable<A> ia = new ConstantInjectable<A>( a );
    Injectable<B> ib = new ConstantInjectable<B>( b );
    assertThat( r.serve( da, ia ), sameInstance( a ) );
    assertThat( r.serve( da, null ), sameInstance( a ) ); // the null Injectable shouldn't be called now
    assertThat( r.serve( db, ib ), sameInstance( b ) );
    assertThat( r.serve( db, null ), sameInstance( b ) ); // the null Injectable shouldn't be called now
  }
}
View Full Code Here

    A a = new A();
    B b = new B();
    Injectable<A> ia = new ConstantInjectable<A>( a );
    Injectable<B> ib = new ConstantInjectable<B>( b );
    assertThat( r.serve( da, ia ), sameInstance( a ) );
    assertThat( r.serve( da, null ), sameInstance( a ) ); // the null Injectable shouldn't be called now
    assertThat( r.serve( db, ib ), sameInstance( b ) );
    assertThat( r.serve( db, null ), sameInstance( b ) ); // the null Injectable shouldn't be called now
  }
}
View Full Code Here

    B b = new B();
    Injectable<A> ia = new ConstantInjectable<A>( a );
    Injectable<B> ib = new ConstantInjectable<B>( b );
    assertThat( r.serve( da, ia ), sameInstance( a ) );
    assertThat( r.serve( da, null ), sameInstance( a ) ); // the null Injectable shouldn't be called now
    assertThat( r.serve( db, ib ), sameInstance( b ) );
    assertThat( r.serve( db, null ), sameInstance( b ) ); // the null Injectable shouldn't be called now
  }
}
View Full Code Here

    Injectable<A> ia = new ConstantInjectable<A>( a );
    Injectable<B> ib = new ConstantInjectable<B>( b );
    assertThat( r.serve( da, ia ), sameInstance( a ) );
    assertThat( r.serve( da, null ), sameInstance( a ) ); // the null Injectable shouldn't be called now
    assertThat( r.serve( db, ib ), sameInstance( b ) );
    assertThat( r.serve( db, null ), sameInstance( b ) ); // the null Injectable shouldn't be called now
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.