Package javax.enterprise.inject.spi

Examples of javax.enterprise.inject.spi.Bean.create()


            assertNotNull( o2 );           
            testEntry(o2, "jar2");
           
            beans = container.getBeanManager().getBeans( KProjectTestClass.class, new KPTestLiteral( "jar3" ) );
            bean = (Bean) beans.toArray()[0];
            KProjectTestClass o3 = (KProjectTestClass) bean.create( container.getBeanManager().createCreationalContext( null ) );
            assertNotNull( o3 );           
            testEntry(o3, "jar3");

            beans = container.getBeanManager().getBeans( KProjectTestClass.class, new KPTestLiteral( "fol4" ) );
            bean = (Bean) beans.toArray()[0];
View Full Code Here


            assertNotNull( o3 );           
            testEntry(o3, "jar3");

            beans = container.getBeanManager().getBeans( KProjectTestClass.class, new KPTestLiteral( "fol4" ) );
            bean = (Bean) beans.toArray()[0];
            KProjectTestClass o4 = (KProjectTestClass) bean.create( container.getBeanManager().createCreationalContext( null ) );
            assertNotNull( o4 );           
            testEntry(o4, "fol4");
           
            weld.shutdown();
        } finally {
View Full Code Here

   @Test
   public void testSimpleInterceptor()
   {
      Bean bean = beanManager.getBeans(SimpleBeanImpl.class).iterator().next();
      CreationalContext creationalContext = beanManager.createCreationalContext(bean);
      SimpleBeanImpl simpleBean = (SimpleBeanImpl) bean.create(creationalContext);
      String result = simpleBean.doSomething();
      assert "decorated-Hello!-decorated".equals(result);
      bean.destroy(simpleBean, creationalContext);
      assert SimpleInterceptor.aroundInvokeCalled;
      assert !SimpleInterceptor.postConstructCalled;
View Full Code Here

   @Test
   public void testSimpleInterceptorWithStereotype()
   {
      Bean bean = beanManager.getBeans(SimpleBeanWithStereotype.class).iterator().next();
      CreationalContext creationalContext = beanManager.createCreationalContext(bean);
      SimpleBeanWithStereotype simpleBean = (SimpleBeanWithStereotype) bean.create(creationalContext);
      String result = simpleBean.doSomething();
      assert "Hello!".equals(result);
      bean.destroy(simpleBean, creationalContext);
      assert SimpleInterceptor.aroundInvokeCalled;
      assert SimpleInterceptor.postConstructCalled;
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    public void testLifecycleInterceptor() {
        Bean bean = beanManager.getBeans(Marathon.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Marathon m = (Marathon) bean.create(creationalContext);

        Assert.assertTrue(LifecycleInterceptor.isPostConstructCalled());
        Assert.assertEquals(42, m.getLength());
        bean.destroy(m, creationalContext);
        Assert.assertTrue(LifecycleInterceptor.isPreDestroyCalled());
View Full Code Here

        Bean bean = beanManager.getBeans(Ball.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);

        PassivationActivationInterceptor.initialMessage = "Goal!";

        Ball ball = (Ball) bean.create(creationalContext);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        new ObjectOutputStream(byteArrayOutputStream).writeObject(ball);

        PassivationActivationInterceptor oldInterceptor = PassivationActivationInterceptor.instance;
View Full Code Here

    @Test
    public void testSimpleInterceptor() {
        reset();
        Bean bean = beanManager.getBeans(Ball.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Ball ball = (Ball) bean.create(creationalContext);
        ball.shoot();
        assert Defender.defended;
        assert Ball.played;
        assert !Goalkeeper.caught;
        assert Ball.aroundInvoke;
View Full Code Here

    @Test
    public void testSimpleInterceptor2() {
        reset();
        Bean bean = beanManager.getBeans(Ball.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Ball ball = (Ball) bean.create(creationalContext);
        ball.pass();
        assert Defender.defended;
        assert Ball.played;
        assert Goalkeeper.caught;
        assert Ball.aroundInvoke;
View Full Code Here

    @Test
    public void testSimpleInterceptor3() {
        reset();
        Bean bean = beanManager.getBeans(Ball.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Ball ball = (Ball) bean.create(creationalContext);
        ball.lob();
        assert !Defender.defended;
        assert Ball.played;
        assert Goalkeeper.caught;
        assert Ball.aroundInvoke;
View Full Code Here

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testLifecycleInterceptor() {

        Bean bean = beanManager.getBeans(Marathon.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Marathon marathon = (Marathon) bean.create(creationalContext);

        assertTrue(LifecycleInterceptor.isPostConstructCalled());
        assertEquals(42, marathon.getLength());
        bean.destroy(marathon, creationalContext);
        assertTrue(LifecycleInterceptor.isPreDestroyCalled());
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.