Package org.apache.openejb.config

Examples of org.apache.openejb.config.AppModule


  @Test
  public void testMethodScopeAsynch() throws Exception{
      System.out.println(long.class.getName());
      System.out.println(String[].class.getCanonicalName());
      //Build the application
      AppModule app = new AppModule(this.getClass().getClassLoader(), "testasynch");
        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new StatelessBean(TestBeanC.class));
        ejbJar.addEnterpriseBean(new SingletonBean(TestBeanD.class));
        app.getEjbModules().add(new EjbModule(ejbJar));

        AppInfo appInfo = config.configureApplication(app);
        assembler.createApplication(appInfo);

    InitialContext context = new InitialContext();
View Full Code Here


  }

  @Test
  public void testClassScopeAsynch() throws Exception {
      //Build the application
        AppModule app = new AppModule(this.getClass().getClassLoader(), "testclassasynch");
        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new SingletonBean(TestBeanA.class));
        app.getEjbModules().add(new EjbModule(ejbJar));

        AppInfo appInfo = config.configureApplication(app);
        assembler.createApplication(appInfo);

        InitialContext context = new InitialContext();
View Full Code Here

  }

    @Test
    public void testSessionContext() throws Exception {
        //Build the application
        AppModule app = new AppModule(this.getClass().getClassLoader(), "testcanceltask");
        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new StatelessBean(TestBeanB.class));
        app.getEjbModules().add(new EjbModule(ejbJar));

        AppInfo appInfo = config.configureApplication(app);
        assembler.createApplication(appInfo);

        InitialContext context = new InitialContext();
View Full Code Here

        transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MyBmpBean", "*"));
        transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MyCmpBean", "*"));
        transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MySingletonBean", "*"));

        AppModule module = new AppModule(this.getClass().getClassLoader(), "test");
        module.getEjbModules().add(new EjbModule(ejbJar));
        assembler.createApplication(config.configureApplication(module));

    }
View Full Code Here

            // where the same java:module java:app java:global names
            // are re-declared in a compatible way
            ejbJar.addEnterpriseBean(new SingletonBean("Other", Bean.class));

            EjbModule ejbModule = new EjbModule(ejbJar);
            AppModule module = new AppModule(ejbModule);
            app = assembler.createApplication(config.configureApplication(module));
        }

        BeanContext bean = app.getBeanContexts().get(0);

        ModuleContext module = bean.getModuleContext();


        { // app context lookups
            Context context = app.getAppJndiContext();

            assertTrue(context.lookup("app") instanceof Context);
            assertTrue(context.lookup("app/AppName") instanceof String);
            assertTrue(context.lookup("app/green") instanceof DataSource);
            assertTrue(context.lookup("app/testmodule") instanceof Context);
            assertTrue(context.lookup("app/testmodule/Bean") instanceof Bean);
            assertTrue(context.lookup("app/testmodule/Bean!" + Bean.class.getName()) instanceof Bean);
            assertTrue(context.lookup("app/testmodule/Other") instanceof Bean);
            assertTrue(context.lookup("app/testmodule/Other!" + Bean.class.getName()) instanceof Bean);

            assertEquals("testmodule", context.lookup("app/AppName"));
        }

        { // module context lookups
            Context context = module.getModuleJndiContext();

            assertTrue(context.lookup("module") instanceof Context);
            assertTrue(context.lookup("module/ModuleName") instanceof String);
            assertTrue(context.lookup("module/blue") instanceof DataSource);
            assertTrue(context.lookup("module/Bean") instanceof Bean);
View Full Code Here

        // where the same java:module java:app java:global names
        // are re-declared in a compatible way
        ejbJar.addEnterpriseBean(new SingletonBean("Other", Bean.class));

        EjbModule ejbModule = new EjbModule(ejbJar);
        AppModule module = new AppModule(ejbModule);
        return assembler.createApplication(config.configureApplication(module));
    }
View Full Code Here

        final ClassLoader loader = this.getClass().getClassLoader();

        final ClientModule clientModule = new ClientModule(new ApplicationClient(), loader, "orange-client", OrangeAppClient.class.getName(), "orange-client");

        final AppModule appModule = new AppModule(loader, "testapp");

        appModule.getClientModules().add(clientModule);
        appModule.getEjbModules().add(ejbModule);

        assembler.createApplication(config.configureApplication(appModule));

        final Properties props = new Properties();
        props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
View Full Code Here

                assembler.createApplication(config.configureApplication(ejbJar));
            } else if (obj instanceof EjbModule) {
                EjbModule ejbModule = (EjbModule) obj;
                assembler.createApplication(config.configureApplication(ejbModule));
            } else if (obj instanceof AppModule) {
                AppModule appModule = (AppModule) obj;
                assembler.createApplication(config.configureApplication(appModule));
            }
            if (!isEmpty(expectedKeys)) {
                fail("A ValidationFailedException should have been thrown");
            }
View Full Code Here

        // Setup the descriptor information

        EmailBean.lifecycle.clear();


        AppModule app = new AppModule(this.getClass().getClassLoader(), "testapp");

        Connector connector = new Connector("email-ra");
        ResourceAdapter adapter = new ResourceAdapter(EmailResourceAdapter.class);
        connector.setResourceAdapter(adapter);
        InboundResourceadapter inbound = adapter.setInboundResourceAdapter(new InboundResourceadapter());
        MessageAdapter messageAdapter = inbound.setMessageAdapter(new MessageAdapter());
        MessageListener listener = messageAdapter.addMessageListener(new MessageListener(EmailConsumer.class, EmailAccountInfo.class));
        listener.getActivationSpec().addRequiredConfigProperty("address");
        app.getConnectorModules().add(new ConnectorModule(connector));

        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new MessageDrivenBean(EmailBean.class));
        app.getEjbModules().add(new EjbModule(ejbJar));

        AppInfo appInfo = config.configureApplication(app);
        assembler.createApplication(appInfo);

        InitialContext initialContext = new InitialContext();
View Full Code Here

        ejbJar.addEnterpriseBean(new StatelessBean(UtilityBean.class));

        EjbModule ejbModule = new EjbModule(ejbJar);

        // Create an "ear"
        AppModule appModule = new AppModule(ejbModule.getClassLoader(), "test-dynamic-data-source");
        appModule.getEjbModules().add(ejbModule);

        // Create a persistence-units
        PersistenceUnit unit = new PersistenceUnit("router");
        unit.addClass(Person.class);
        unit.getProperties().put("openjpa.jdbc.SynchronizeMappings", "buildSchema");
        unit.setTransactionType(TransactionType.JTA);
        unit.setJtaDataSource("Routed Datasource");
        appModule.getPersistenceModules().add(new PersistenceModule("root", new Persistence(unit)));
        for (int i = 1; i <= 3; i++) {
            PersistenceUnit u = new PersistenceUnit("db" + i);
            u.addClass(Person.class);
            u.getProperties().put("openjpa.jdbc.SynchronizeMappings", "buildSchema");
            u.setTransactionType(TransactionType.JTA);
            u.setJtaDataSource("database" + i);
            appModule.getPersistenceModules().add(new PersistenceModule("root", new Persistence(u)));
        }

        assembler.createApplication(config.configureApplication(appModule));

        // context
View Full Code Here

TOP

Related Classes of org.apache.openejb.config.AppModule

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.