Search in sources :

Example 41 with EjbDeployment

use of org.apache.openejb.jee.oejb3.EjbDeployment 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 42 with EjbDeployment

use of org.apache.openejb.jee.oejb3.EjbDeployment 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 43 with EjbDeployment

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

the class PropertiesPropogationTest method test.

public void test() throws Exception {
    EjbServer ejbServer = new EjbServer();
    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());
    ServicePool pool = new ServicePool(ejbServer, 10);
    ServiceDaemon serviceDaemon = new ServiceDaemon(pool, 0, "localhost");
    serviceDaemon.start();
    int port = serviceDaemon.getPort();
    Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
    ConfigurationFactory config = new ConfigurationFactory();
    EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
    EjbJar ejbJar = ejbModule.getEjbJar();
    OpenejbJar openejbJar = ejbModule.getOpenejbJar();
    StatelessBean statelessBean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
    EjbDeployment deployment = openejbJar.addEjbDeployment(statelessBean);
    deployment.getProperties().put("color", "orange");
    deployment.getProperties().put("openejb.client.color", "red");
    EjbJarInfo ejbJarInfo = config.configureApplication(ejbModule);
    EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
    assertTrue(beanInfo.properties.containsKey("color"));
    assertTrue(beanInfo.properties.containsKey("openejb.client.color"));
    assertEquals("orange", beanInfo.properties.get("color"));
    assertEquals("red", beanInfo.properties.get("openejb.client.color"));
    assembler.createApplication(ejbJarInfo);
    ContainerSystem cs = SystemInstance.get().getComponent(ContainerSystem.class);
    BeanContext info = cs.getBeanContext("WidgetBean");
    assertNotNull(info);
    assertTrue(info.getProperties().containsKey("color"));
    assertTrue(info.getProperties().containsKey("openejb.client.color"));
    assertEquals("orange", info.getProperties().get("color"));
    assertEquals("red", info.getProperties().get("openejb.client.color"));
    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);
    Context context = new InitialContext(props);
    Widget remote = (Widget) context.lookup("WidgetBeanRemote");
    InvocationHandler handler = ProxyManager.getInvocationHandler(remote);
    EJBObjectHandler objectHandler = EJBObjectHandler.class.cast(handler);
    Properties properties = objectHandler.getEjb().getProperties();
    // Should only contain "openejb.client.*" properties
    assertFalse(properties.containsKey("color"));
    // The openejb.client.color property should have been propogated
    assertTrue(properties.containsKey("openejb.client.color"));
    assertEquals("red", properties.getProperty("openejb.client.color"));
    serviceDaemon.stop();
    OpenEJB.destroy();
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) InitialContext(javax.naming.InitialContext) BeanContext(org.apache.openejb.BeanContext) Context(javax.naming.Context) ServerFederation(org.apache.openejb.core.ServerFederation) EJBObjectHandler(org.apache.openejb.client.EJBObjectHandler) ServicePool(org.apache.openejb.server.ServicePool) EjbModule(org.apache.openejb.config.EjbModule) Properties(java.util.Properties) InvocationHandler(org.apache.openejb.client.proxy.InvocationHandler) InitialContext(javax.naming.InitialContext) EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) BeanContext(org.apache.openejb.BeanContext) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) ServiceDaemon(org.apache.openejb.server.ServiceDaemon) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 44 with EjbDeployment

use of org.apache.openejb.jee.oejb3.EjbDeployment 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 45 with EjbDeployment

use of org.apache.openejb.jee.oejb3.EjbDeployment 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

EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)46 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)35 EjbJar (org.apache.openejb.jee.EjbJar)27 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)16 EjbModule (org.apache.openejb.config.EjbModule)15 Properties (java.util.Properties)14 OpenEJBException (org.apache.openejb.OpenEJBException)10 ResourceLink (org.apache.openejb.jee.oejb3.ResourceLink)9 Assembler (org.apache.openejb.assembler.classic.Assembler)8 StatelessBean (org.apache.openejb.jee.StatelessBean)8 HashMap (java.util.HashMap)7 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)7 InitialContext (javax.naming.InitialContext)6 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)6 ManagedBean (org.apache.openejb.jee.ManagedBean)6 MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)6 SessionBean (org.apache.openejb.jee.SessionBean)6 Map (java.util.Map)5 SingletonBean (org.apache.openejb.jee.SingletonBean)5 ContainerSystem (org.apache.openejb.spi.ContainerSystem)5