Search in sources :

Example 71 with EjbModule

use of org.apache.openejb.config.EjbModule in project tomee by apache.

the class CheckDescriptorLocation method validate.

@Override
public void validate(final AppModule appModule) {
    final List<String> validated = new ArrayList<String>();
    for (final WebModule webModule : safe(appModule.getWebModules())) {
        validated.add(webModule.getModuleId());
        validateWebModule(webModule);
    }
    for (final EjbModule ejbModule : safe(appModule.getEjbModules())) {
        // without this check, CheckDescriptorLocationTest#testWarWithDescriptorInRoot() would fail
        if (!validated.contains(ejbModule.getModuleId())) {
            validateEjbModule(ejbModule);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) EjbModule(org.apache.openejb.config.EjbModule) WebModule(org.apache.openejb.config.WebModule)

Example 72 with EjbModule

use of org.apache.openejb.config.EjbModule in project tomee by apache.

the class ValidationBase method validate.

public void validate(final AppModule appModule) {
    final ClassLoader loader = Thread.currentThread().getContextClassLoader();
    try {
        for (final EjbModule ejbModule : appModule.getEjbModules()) {
            Thread.currentThread().setContextClassLoader(ejbModule.getClassLoader());
            module = ejbModule;
            validate(ejbModule);
        }
        for (final ClientModule clientModule : appModule.getClientModules()) {
            Thread.currentThread().setContextClassLoader(clientModule.getClassLoader());
            module = clientModule;
            validate(clientModule);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(loader);
    }
}
Also used : EjbModule(org.apache.openejb.config.EjbModule) ClientModule(org.apache.openejb.config.ClientModule)

Example 73 with EjbModule

use of org.apache.openejb.config.EjbModule in project tomee by apache.

the class CustomEndpointConfiguratorTest method module.

@Module
public EjbModule module() {
    final EjbModule module = new EjbModule(new EjbJar());
    module.setOpenejbJar(new OpenejbJar());
    final SingletonBean bean = new SingletonBean(MyWebservice.class);
    bean.setLocalBean(new Empty());
    final EjbDeployment deployment = new EjbDeployment(bean);
    deployment.getProperties().setProperty("openejb.endpoint.configurator", CustomConfigurator.class.getName());
    module.getOpenejbJar().addEjbDeployment(deployment);
    module.getEjbJar().addEnterpriseBean(bean);
    return module;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) Empty(org.apache.openejb.jee.Empty) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) EjbModule(org.apache.openejb.config.EjbModule) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.testing.Module)

Example 74 with EjbModule

use of org.apache.openejb.config.EjbModule in project tomee by apache.

the class FeatureTest method app.

@Module
public EjbModule app() {
    final EjbJar jar = new EjbJar();
    jar.addEnterpriseBean(new SingletonBean(AuthenticatorServiceBean.class).localBean());
    final OpenejbJar openejbJar = new OpenejbJar();
    openejbJar.addEjbDeployment(new EjbDeployment(jar.getEnterpriseBeans()[0]));
    final Properties properties = openejbJar.getEjbDeployment().iterator().next().getProperties();
    properties.setProperty(CxfService.OPENEJB_JAXWS_CXF_FEATURES, MyFeature.class.getName());
    properties.setProperty("cxf.jaxws.features", "my-feature");
    properties.setProperty("cxf.jaxws.properties", "my-props");
    final EjbModule module = new EjbModule(jar);
    module.setOpenejbJar(openejbJar);
    final Resources resources = new Resources();
    final Service service = new Service("my-feature", null, null, null);
    service.setClassName(MyFeature.class.getName());
    resources.add(service);
    final Service myProps = new Service("my-props", null, null, null);
    myProps.setClassName(Properties.class.getName());
    myProps.getProperties().setProperty("faultStackTraceEnabled", "true");
    resources.add(myProps);
    module.initResources(resources);
    return module;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) EjbModule(org.apache.openejb.config.EjbModule) Service(org.apache.openejb.config.sys.Service) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) Resources(org.apache.openejb.config.sys.Resources) Properties(java.util.Properties) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.junit.Module)

Example 75 with EjbModule

use of org.apache.openejb.config.EjbModule in project tomee by apache.

the class AppClientTest method test.

public void test() throws Exception {
    final EjbServer ejbServer = new EjbServer();
    final Properties initProps = new Properties();
    initProps.setProperty("openejb.deployments.classpath.include", "");
    initProps.setProperty("openejb.deployments.classpath.filter.descriptors", "true");
    OpenEJB.init(initProps, new ServerFederation());
    ejbServer.init(new Properties());
    final ServicePool pool = new ServicePool(ejbServer, 10);
    final ServiceDaemon serviceDaemon = new ServiceDaemon(pool, 0, "localhost");
    serviceDaemon.start();
    int port = serviceDaemon.getPort();
    final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
    final ConfigurationFactory config = new ConfigurationFactory();
    final EjbModule ejbModule = new EjbModule(new EjbJar("testejbmodule"), new OpenejbJar());
    final EjbJar ejbJar = ejbModule.getEjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(Orange.class));
    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");
    props.put("java.naming.provider.url", "ejbd://127.0.0.1:" + port);
    props.put("openejb.client.moduleId", "orange-client");
    Context context = new InitialContext(props);
    final Object home = context.lookup("comp/env/home");
    assertTrue(home instanceof OrangeHome);
    OrangeHome orangeHome = (OrangeHome) home;
    final OrangeRemote orangeRemote = orangeHome.create();
    assertEquals("bat", orangeRemote.echo("tab"));
    final Object business = context.lookup("comp/env/business");
    assertTrue(business instanceof OrangeBusinessRemote);
    OrangeBusinessRemote orangeBusinessRemote = (OrangeBusinessRemote) business;
    assertEquals("nap", orangeBusinessRemote.echo("pan"));
    final Object dataSourceObject = context.lookup("comp/env/datasource");
    assertTrue(dataSourceObject instanceof DataSource);
    // DataSource dataSource = (DataSource) dataSourceObject;
    // assertEquals("nap", orangeBusinessRemote.echo("pan"));
    props.put("openejb.client.moduleId", "openejb/global");
    context = new InitialContext(props);
    final Object global = context.lookup("global/testapp/testejbmodule/Orange!" + OrangeBusinessRemote.class.getName());
    assertTrue(global instanceof OrangeBusinessRemote);
    OrangeBusinessRemote globalOrangeBusinessRemote = (OrangeBusinessRemote) global;
    assertEquals("nap", globalOrangeBusinessRemote.echo("pan"));
    serviceDaemon.stop();
    OpenEJB.destroy();
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) Properties(java.util.Properties) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbJar(org.apache.openejb.jee.EjbJar) Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ServerFederation(org.apache.openejb.core.ServerFederation) ApplicationClient(org.apache.openejb.jee.ApplicationClient) ServicePool(org.apache.openejb.server.ServicePool) ClientModule(org.apache.openejb.config.ClientModule) InitialContext(javax.naming.InitialContext) DataSource(javax.sql.DataSource) StatelessBean(org.apache.openejb.jee.StatelessBean) ServiceDaemon(org.apache.openejb.server.ServiceDaemon) EJBObject(javax.ejb.EJBObject) Assembler(org.apache.openejb.assembler.classic.Assembler)

Aggregations

EjbModule (org.apache.openejb.config.EjbModule)91 EjbJar (org.apache.openejb.jee.EjbJar)81 AppModule (org.apache.openejb.config.AppModule)41 StatelessBean (org.apache.openejb.jee.StatelessBean)37 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)30 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)29 Assembler (org.apache.openejb.assembler.classic.Assembler)27 Properties (java.util.Properties)24 SingletonBean (org.apache.openejb.jee.SingletonBean)21 InitialContext (javax.naming.InitialContext)20 Module (org.apache.openejb.testing.Module)18 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)15 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)13 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)13 Beans (org.apache.openejb.jee.Beans)12 AppInfo (org.apache.openejb.assembler.classic.AppInfo)11 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)10 ContainerSystem (org.apache.openejb.spi.ContainerSystem)10 ArrayList (java.util.ArrayList)9 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)9