Search in sources :

Example 51 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class CheckedExceptionMapperTest method module.

@Module
@Classes({ ExampleExceptionMapper.class })
public EjbModule module() {
    final SingletonBean bean = new SingletonBean(ExampleRest.class);
    bean.setRestService(true);
    final EjbJar ejbJar = new EjbJar("beans");
    ejbJar.addEnterpriseBean(bean);
    final OpenejbJar openejbJar = new OpenejbJar();
    openejbJar.addEjbDeployment(new EjbDeployment(bean));
    final Properties properties = openejbJar.getEjbDeployment().iterator().next().getProperties();
    properties.setProperty("cxf.jaxrs.providers", "org.apache.openejb.server.cxf.rs.CheckedExceptionMapperTest$ExampleExceptionMapper");
    final EjbModule module = new EjbModule(ejbJar);
    module.setOpenejbJar(openejbJar);
    return module;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) EjbModule(org.apache.openejb.config.EjbModule) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) Properties(java.util.Properties) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.testing.Module) Classes(org.apache.openejb.testing.Classes)

Example 52 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class CustomContextTest method service.

@Module
public static EjbModule service() throws Exception {
    final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
    final SingletonBean bean = new SingletonBean(CustomContextInjectedBean.class);
    bean.setLocalBean(new Empty());
    module.getEjbJar().addEnterpriseBean(bean);
    final PojoDeployment e = new PojoDeployment();
    e.setClassName("jaxrs-application");
    e.getProperties().setProperty("cxf.jaxrs.providers", CustomProvider.class.getName());
    module.getOpenejbJar().getPojoDeployment().add(e);
    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) PojoDeployment(org.apache.openejb.jee.oejb3.PojoDeployment) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.testing.Module)

Example 53 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class FeatureTest method app.

@Module
public EjbModule app() {
    final StatelessBean bean = (StatelessBean) new StatelessBean(MySecondRestClass.class).localBean();
    bean.setRestService(true);
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(bean);
    final OpenejbJar openejbJar = new OpenejbJar();
    final PojoDeployment e = new PojoDeployment();
    openejbJar.getPojoDeployment().add(e);
    e.setClassName("jaxrs-application");
    final Properties properties = e.getProperties();
    properties.setProperty(CxfRsHttpListener.CXF_JAXRS_PREFIX + CxfUtil.FEATURES, "my-feature");
    final EjbModule module = new EjbModule(ejbJar);
    module.setOpenejbJar(openejbJar);
    final Resources resources = new Resources();
    final Service feature = new Service("my-feature", null);
    feature.setClassName(MyFeature.class.getName());
    resources.getService().add(feature);
    module.initResources(resources);
    return module;
}
Also used : OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) Service(org.apache.openejb.config.sys.Service) PojoDeployment(org.apache.openejb.jee.oejb3.PojoDeployment) 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.testing.Module)

Example 54 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class ActivationConfigPropertyOverrideTest method testMdbOverrideOpenejbJar.

@Test
public void testMdbOverrideOpenejbJar() throws Exception {
    SystemInstance.reset();
    final Assembler assembler = new Assembler();
    final ConfigurationFactory config = new ConfigurationFactory();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    {
        final EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new MessageDrivenBean(Orange.class));
        ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
        final OpenejbJar openejbJar = new OpenejbJar();
        final Properties properties = openejbJar.getProperties();
        properties.setProperty("mdb.activation.maxSessions", "20");
        properties.setProperty("mdb.activation.maxMessagesPerSessions", "100");
        properties.setProperty("mdb.activation.destinationType", "javax.jms.Queue");
        properties.setProperty("mdb.activation.destination", "OVERRIDDEN.QUEUE");
        final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
        final EjbJarInfo ejbJarInfo = config.configureApplication(ejbModule);
        assertEquals(2, ejbJarInfo.enterpriseBeans.size());
        final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
        final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
        assertEquals("20", orange.activationProperties.get("maxSessions"));
        assertEquals("100", orange.activationProperties.get("maxMessagesPerSessions"));
        assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
        assertEquals("OVERRIDDEN.QUEUE", orange.activationProperties.get("destination"));
        assertEquals("20", yellow.activationProperties.get("maxSessions"));
        assertEquals("100", yellow.activationProperties.get("maxMessagesPerSessions"));
        assertEquals("javax.jms.Queue", yellow.activationProperties.get("destinationType"));
        assertEquals("OVERRIDDEN.QUEUE", yellow.activationProperties.get("destination"));
    }
    // Verify the openejb-jar level overrides do not affect other apps
    {
        final EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new MessageDrivenBean(Orange.class));
        ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
        final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
        assertEquals(2, ejbJarInfo.enterpriseBeans.size());
        final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
        final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
        assertEquals("7", orange.activationProperties.get("maxSessions"));
        assertEquals("4", orange.activationProperties.get("maxMessagesPerSessions"));
        assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
        assertEquals("ORANGE.QUEUE", orange.activationProperties.get("destination"));
        assertEquals("5", yellow.activationProperties.get("maxSessions"));
        assertEquals("10", yellow.activationProperties.get("maxMessagesPerSessions"));
        assertEquals("javax.jms.Topic", yellow.activationProperties.get("destinationType"));
        assertEquals("YELLOW.TOPIC", yellow.activationProperties.get("destination"));
    }
}
Also used : OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) Properties(java.util.Properties) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test) ActivationContainerOverwriteBothConfigurationTest(org.apache.openejb.activemq.ActivationContainerOverwriteBothConfigurationTest)

Example 55 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class AppInfoBuilderTest method testShouldIgnorePortInfoThatDontMatchTheEjb.

public void testShouldIgnorePortInfoThatDontMatchTheEjb() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final SessionBean sessionBean = new SessionBean();
    sessionBean.setEjbName("MySessionBean");
    sessionBean.setEjbClass("org.superbiz.MySessionBean");
    sessionBean.setRemote("org.superbiz.MySession");
    ejbJar.addEnterpriseBean(sessionBean);
    final OpenejbJar openejbJar = new OpenejbJar();
    final EjbDeployment ejbDeployment = new EjbDeployment();
    openejbJar.addEjbDeployment(ejbDeployment);
    ejbDeployment.setEjbName("MySessionBean");
    final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
    final EjbJarInfo ejbJarInfo = new EjbJarInfo();
    final PortInfo portInfo = new PortInfo();
    portInfo.authMethod = "DIGEST";
    portInfo.realmName = "";
    portInfo.securityRealmName = "";
    portInfo.transportGuarantee = "CONFIDENTIAL";
    portInfo.serviceLink = "DifferentInfo";
    final Properties props = new Properties();
    props.put("wss4j.in.action", "Timestamp");
    props.put("wss4j.out.action", "Timestamp");
    portInfo.properties = props;
    ejbJarInfo.portInfos.add(portInfo);
    new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
    final List<PortInfo> portInfoList = ejbJarInfo.portInfos;
    assertEquals(1, portInfoList.size());
    final PortInfo info = portInfoList.get(0);
    assertEquals("", info.realmName);
    assertEquals("", info.securityRealmName);
    assertEquals("DIGEST", info.authMethod);
    assertEquals("CONFIDENTIAL", info.transportGuarantee);
    assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.in.action"));
    assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.out.action"));
}
Also used : PortInfo(org.apache.openejb.assembler.classic.PortInfo) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) SessionBean(org.apache.openejb.jee.SessionBean) Properties(java.util.Properties) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)62 EjbJar (org.apache.openejb.jee.EjbJar)50 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)36 EjbModule (org.apache.openejb.config.EjbModule)29 Properties (java.util.Properties)20 StatelessBean (org.apache.openejb.jee.StatelessBean)18 Assembler (org.apache.openejb.assembler.classic.Assembler)17 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)15 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)12 ContainerSystem (org.apache.openejb.spi.ContainerSystem)12 SingletonBean (org.apache.openejb.jee.SingletonBean)10 Module (org.apache.openejb.testing.Module)9 AppModule (org.apache.openejb.config.AppModule)8 InitialContext (javax.naming.InitialContext)7 OpenEJBException (org.apache.openejb.OpenEJBException)7 MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)7 PojoDeployment (org.apache.openejb.jee.oejb3.PojoDeployment)7 File (java.io.File)6 HashMap (java.util.HashMap)6 Resources (org.apache.openejb.config.sys.Resources)6