Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.StatefulBean


        EjbJar ejbJar = new EjbJar();
        StatelessBean stateless = new StatelessBean(FooStateless.class);
        stateless.setHomeAndRemote(FooStatelessHome.class, FooStatelessRemote.class);
        stateless.setHomeAndLocal(FooStatelessLocalHome.class, FooStatelessLocal.class);
        ejbJar.addEnterpriseBean(stateless);
        StatefulBean stateful = new StatefulBean(FooStateful.class);
        stateful.setHomeAndRemote(FooStatefulHome.class, FooStatefulRemote.class);
        stateful.setHomeAndLocal(FooStatefulLocalHome.class, FooStatefulLocal.class);
        ejbJar.addEnterpriseBean(stateful);
        org.apache.openejb.jee.EntityBean bean = new org.apache.openejb.jee.EntityBean(MyEntity.class, PersistenceType.BEAN);
        bean.setLocalHome(MyLocalHome.class.getName());
        bean.setLocal(MyLocal.class.getName());
        ejbJar.addEnterpriseBean(bean);
        org.apache.openejb.jee.EntityBean bean1 = new org.apache.openejb.jee.EntityBean(YourEntity.class, PersistenceType.BEAN);
        bean1.setLocalHome(MyLocalHome.class.getName());
        bean1.setLocal(MyLocal.class.getName());
        ejbJar.addEnterpriseBean(bean1);
        StatelessBean bar = new StatelessBean(BarStateless.class);
        bar.setHomeAndRemote(BarStatelessHome.class, BarStatelessRemote.class);
        ejbJar.addEnterpriseBean(bar);
        StatefulBean bazStateful = new StatefulBean(BazStateful.class);
        ejbJar.addEnterpriseBean(bazStateful);
        return ejbJar;
    }
View Full Code Here


        Interceptor interceptor = new Interceptor(SimpleInterceptor.class);
        ejbJar.addInterceptor(interceptor);

        //Test SessionSynchronization interface
        StatefulBean subBeanA = new StatefulBean(SubBeanA.class);
        ejbJar.addEnterpriseBean(subBeanA);
        assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanA, interceptor));

        //Test configure session synchronization callback methods in deployment plan
        StatefulBean subBeanB = new StatefulBean(SubBeanB.class);
        subBeanB.setAfterBeginMethod(new NamedMethod(SubBeanB.class.getDeclaredMethod("afterBegin")));
        subBeanB.setBeforeCompletionMethod(new NamedMethod(SubBeanB.class.getDeclaredMethod("beforeCompletion")));
        subBeanB.setAfterCompletionMethod(new NamedMethod(SubBeanB.class.getDeclaredMethod("afterCompletion", boolean.class)));
        ejbJar.addEnterpriseBean(subBeanB);
        assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanB, interceptor));

        //Test session synchronization methods via annotations
        StatefulBean subBeanC = new StatefulBean(SubBeanC.class);
        ejbJar.addEnterpriseBean(subBeanC);
        assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanC, interceptor));

        //Test override the annotations by deployment plan
        StatefulBean subBeanD = new StatefulBean(SubBeanD.class);
        subBeanD.setAfterBeginMethod(new NamedMethod(SubBeanD.class.getDeclaredMethod("afterBeginNew")));
        subBeanD.setBeforeCompletionMethod(new NamedMethod(SubBeanD.class.getDeclaredMethod("beforeCompletionNew")));
        subBeanD.setAfterCompletionMethod(new NamedMethod(SubBeanD.class.getDeclaredMethod("afterCompletionNew", boolean.class)));
        ejbJar.addEnterpriseBean(subBeanD);
        assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanD, interceptor));

        //Test only one session synchronization method @AfterBegin
        StatefulBean subBeanE = new StatefulBean(SubBeanE.class);
        ejbJar.addEnterpriseBean(subBeanE);
        assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanE, interceptor));

        //Test only one session synchronization method @AfterCompletion
        StatefulBean subBeanF = new StatefulBean(SubBeanF.class);
        ejbJar.addEnterpriseBean(subBeanF);
        assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanF, interceptor));

        //Test only one session synchronization method @BeforeCompletion
        StatefulBean subBeanG = new StatefulBean(SubBeanG.class);
        ejbJar.addEnterpriseBean(subBeanG);
        assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(subBeanG, interceptor));

        //Test SessionSynchronization interface but methods are in the parent class
        //Interceptor is declared on the bean method
        StatefulBean subBeanH = new StatefulBean(SubBeanH.class);
        ejbJar.addEnterpriseBean(subBeanH);

        //Test SessionSynchronization interface but methods are in the parent class
        //using @LocalBean
        StatefulBean subBeanI = new StatefulBean(SubBeanI.class);
        ejbJar.addEnterpriseBean(subBeanI);

        EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
        assembler.createApplication(ejbJarInfo);
        InitialContext context = new InitialContext();
View Full Code Here

        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

        EjbJar ejbJar = new EjbJar();
        StatefulBean bean = ejbJar.addEnterpriseBean(new StatefulBean(AnnotatedBean.class));

        bean.getEjbLocalRef().add(new EjbLocalRef(name("annotatedLocal"), "BarBean"));

        bean.getEnvEntry().add(new EnvEntry(name("striing"), "java.lang.Integer", "2"));
        bean.getEnvEntry().add(new EnvEntry(name("doouble"), "java.lang.String", "two"));
        bean.getEnvEntry().add(new EnvEntry(name("loong"), "java.lang.String", "three"));
        bean.getEnvEntry().add(new EnvEntry(name("flooat"), "java.lang.String", "four"));
        bean.getEnvEntry().add(new EnvEntry(name("inteeger"), "java.lang.String", "five"));
        bean.getEnvEntry().add(new EnvEntry(name("shoort"), "java.lang.String", "six"));
        bean.getEnvEntry().add(new EnvEntry(name("booolean"), "java.lang.String", "seven"));
        bean.getEnvEntry().add(new EnvEntry(name("byyte"), "java.lang.String", "eight"));
        bean.getEnvEntry().add(new EnvEntry(name("chaaracter"), "java.lang.String", "nine"));
       
        EnvEntry lookupEntry = new EnvEntry(name("lookup"), "java.lang.String", null);
        lookupEntry.setLookupName("java:app/AppName");
        bean.getEnvEntry().add(lookupEntry);

        bean.getResourceRef().add(new ResourceRef(name("daataSource"), DataSource.class.getName(), ResAuth.CONTAINER, ResSharingScope.SHAREABLE));

        bean.getPersistenceUnitRef().add(new PersistenceUnitRef(name("emf"), "yellow"));

        bean.getPersistenceContextRef().add(new PersistenceContextRef(name("em"), "yellow", PersistenceContextType.TRANSACTION, new ArrayList(Arrays.asList(new Property("zzzz", "AAAA")))));

        org.apache.openejb.jee.jpa.unit.PersistenceUnit persistenceUnit = new org.apache.openejb.jee.jpa.unit.PersistenceUnit("yellow");

        AppModule app = new AppModule(this.getClass().getClassLoader(), "app");
        app.getEjbModules().add(new EjbModule(ejbJar));
View Full Code Here

    }

    @Keys(@Key(value="ignoredMethodAnnotation",type=KeyType.WARNING))
    public EjbJar testIgnoredAroundTimeout() throws Exception {
        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new StatefulBean("TestAroundTimeout", TestAroundTimeout.class));
        return ejbJar;
    }
View Full Code Here

        // Start creating the test application

        // Create an ejb-jar.xml for this app
        EjbJar ejbJar = new EjbJar();

        ejbJar.addEnterpriseBean(new StatefulBean("PleaseCloseMyExtendedEm", PleaseCloseMyExtendedEmBean.class));
        ejbJar.addEnterpriseBean(new StatefulBean("PleaseCloseMyEm", PleaseCloseMyEmBean.class));
        ejbJar.addEnterpriseBean(new StatelessBean("PleaseCloseMyLessEm", PleaseCloseMyEmBean.class));

        // Add six beans and link them all in a chain
        addStatefulBean(ejbJar, ExtendedContextBean.class, "Extended", "Extendedx2");
        addStatefulBean(ejbJar, ExtendedContextBean.class, "Extendedx2", "Extendedx3");
        addStatefulBean(ejbJar, ExtendedContextBean.class, "Extendedx3", "Extendedx4");
        addStatefulBean(ejbJar, ExtendedContextBean.class, "Extendedx4", "Extendedx5");
        addStatefulBean(ejbJar, ExtendedContextBean.class, "ExtendedToTransaction", "StatelessTransactionToExtended");
        addStatefulBean(ejbJar, ExtendedContextBean.class, "Extendedx5", "Extendedx6");
        ejbJar.addEnterpriseBean(new StatefulBean("Extendedx6", EndNodeBean.class));

        // Add six beans and link them all in a chain
        addStatefulBean(ejbJar, TransactionContextBean.class, "Transaction", "Transactionx2");
        addStatefulBean(ejbJar, TransactionContextBean.class, "Transactionx2", "Transactionx3");
        addStatefulBean(ejbJar, TransactionContextBean.class, "Transactionx3", "Transactionx4");
        addStatefulBean(ejbJar, TransactionContextBean.class, "Transactionx4", "Transactionx5");
        addStatefulBean(ejbJar, TransactionContextBean.class, "Transactionx5", "Transactionx6");
        addStatefulBean(ejbJar, TransactionContextBean.class, "TransactionToExtended", "Extendedx5");
       
        addStatelessBean(ejbJar, TransactionContextBean.class, "StatelessTransactionToExtended", "Extendedx5");
        ejbJar.addEnterpriseBean(new StatefulBean("Transactionx6", EndNodeBean.class));
       
        ejbJar.setAssemblyDescriptor(new AssemblyDescriptor());
        ejbJar.getAssemblyDescriptor().addApplicationException(IllegalArgumentException.class, false, true);
        ejbJar.getAssemblyDescriptor().addApplicationException(ArgumentException.class, false, true);
       
View Full Code Here

        AppInfo info = config.configureApplication(appModule);
        assembler.createApplication(info);
    }

    private void addStatefulBean(EjbJar ejbJar, Class<?> ejbClass, String name, String reference) {
        StatefulBean bean = ejbJar.addEnterpriseBean(new StatefulBean(name, ejbClass));
        bean.getEjbLocalRef().add(new EjbLocalRef("child", reference));
    }
View Full Code Here

        // Setup the descriptor information

        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new StatelessBean(BlueStatelessBean.class));
        ejbJar.addEnterpriseBean(new StatefulBean(RedStatefulBean.class));
        ejbJar.addEnterpriseBean(new StatefulBean(LegacyStatefulBean.class));

        assembler.createApplication(config.configureApplication(ejbJar));
    }
View Full Code Here

        final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
        assembler.createContainer(statefulContainerInfo);

        final EjbJar ejbJar = new EjbJar();

        final StatefulBean bean1 = new StatefulBean(MyLocalBeanImpl.class);
        final Timeout timeout1 = new Timeout();
        timeout1.setTimeout(10);
        timeout1.setUnit(TimeUnit.SECONDS);
        final ConcurrentMethod method1 = new ConcurrentMethod();
        method1.setMethod(new NamedMethod("*"));
        method1.setAccessTimeout(timeout1);
        bean1.getConcurrentMethod().add(method1);

        ejbJar.addEnterpriseBean(bean1);

        assembler.createApplication(config.configureApplication(ejbJar));
    }
View Full Code Here

    @Keys( { @Key(value = "resourceRef.onEntityManagerFactory", count = 2), @Key(value = "resourceRef.onEntityManager", count = 2),
            @Key(value = "resourceAnnotation.onClassWithNoName", count = 2) })
    public EjbJar wrongUsage() throws OpenEJBException {
        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new StatelessBean(FooStateless.class));
        ejbJar.addEnterpriseBean(new StatefulBean(FooStateful.class));
        return ejbJar;
    }
View Full Code Here

    public EjbModule buildTestApp() {
        EjbJar ejbJar = new EjbJar();
        AssemblyDescriptor ad = ejbJar.getAssemblyDescriptor();

        EnterpriseBean bean = ejbJar.addEnterpriseBean(new StatefulBean(TargetBean.class));

        Interceptor interceptor;

        interceptor = ejbJar.addInterceptor(new Interceptor(ClassInterceptor.class));
        ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.StatefulBean

Copyright © 2018 www.massapicom. 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.