Search in sources :

Example 21 with SessionBean$JAXB.writeSessionBean

use of org.apache.openejb.jee.SessionBean$JAXB.writeSessionBean in project tomee by apache.

the class AppInfoBuilderTest method testShouldUseDefaultsIfSettingIsNull.

public void testShouldUseDefaultsIfSettingIsNull() 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.serviceLink = "MySessionBean";
    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(null, info.realmName);
    assertEquals(null, info.securityRealmName);
    assertEquals("NONE", info.authMethod);
    assertEquals("NONE", info.transportGuarantee);
    assertTrue(portInfo.properties.isEmpty());
}
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) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 22 with SessionBean$JAXB.writeSessionBean

use of org.apache.openejb.jee.SessionBean$JAXB.writeSessionBean in project tomee by apache.

the class AppInfoBuilderTest method testShouldAddSecurityDetailsToPortInfo.

public void testShouldAddSecurityDetailsToPortInfo() 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");
    ejbDeployment.addProperty("webservice.security.realm", "MyRealm");
    ejbDeployment.addProperty("webservice.security.securityRealm", "MySecurityRealm");
    ejbDeployment.addProperty("webservice.security.transportGarantee", TransportGuaranteeType.NONE.value());
    ejbDeployment.addProperty("webservice.security.authMethod", AuthMethodType.BASIC.value());
    ejbDeployment.addProperty("wss4j.in.action", "Timestamp");
    ejbDeployment.addProperty("wss4j.out.action", "Timestamp");
    final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
    final EjbJarInfo ejbJarInfo = new EjbJarInfo();
    final PortInfo portInfo = new PortInfo();
    portInfo.serviceLink = "MySessionBean";
    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("MyRealm", info.realmName);
    assertEquals("MySecurityRealm", info.securityRealmName);
    assertEquals("BASIC", info.authMethod);
    assertEquals("NONE", 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) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 23 with SessionBean$JAXB.writeSessionBean

use of org.apache.openejb.jee.SessionBean$JAXB.writeSessionBean in project aries by apache.

the class OpenEJBLocator method findEJBs.

public void findEJBs(BundleManifest manifest, IDirectory bundle, EJBRegistry registry) throws ModellerException {
    logger.debug("Scanning " + manifest.getSymbolicName() + "_" + manifest.getManifestVersion() + " for EJBs");
    String ejbJarLocation = (manifest.getRawAttributes().getValue("Web-ContextPath") == null) ? "META-INF/ejb-jar.xml" : "WEB-INF/ejb-jar.xml";
    try {
        //If we have an ejb-jar.xml then parse it 
        IFile file = bundle.getFile(ejbJarLocation);
        EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL());
        EjbModule module = new EjbModule(ejbJar);
        //We build our own because we can't trust anyone to get the classpath right otherwise!
        module.setFinder(new IDirectoryFinder(AnnotationDeployer.class.getClassLoader(), getClassPathLocations(manifest, bundle)));
        //Scan our app for annotated EJBs
        AppModule app = new AppModule(module);
        new AnnotationDeployer().deploy(app);
        //Register our session beans
        for (EnterpriseBean eb : ejbJar.getEnterpriseBeans()) {
            if (!!!(eb instanceof SessionBean))
                continue;
            else
                registerSessionBean(registry, (SessionBean) eb);
        }
    } catch (Exception e) {
        throw new ModellerException(e);
    }
}
Also used : AnnotationDeployer(org.apache.openejb.config.AnnotationDeployer) IFile(org.apache.aries.util.filesystem.IFile) AppModule(org.apache.openejb.config.AppModule) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) EjbModule(org.apache.openejb.config.EjbModule) ModellerException(org.apache.aries.application.modelling.ModellerException) SessionBean(org.apache.openejb.jee.SessionBean) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ModellerException(org.apache.aries.application.modelling.ModellerException) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

SessionBean (org.apache.openejb.jee.SessionBean)22 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)12 EjbJar (org.apache.openejb.jee.EjbJar)10 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)8 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)7 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)4 Method (java.lang.reflect.Method)3 ArrayList (java.util.ArrayList)3 OpenEJBException (org.apache.openejb.OpenEJBException)3 PortInfo (org.apache.openejb.assembler.classic.PortInfo)3 EjbModule (org.apache.openejb.config.EjbModule)3 MalformedURLException (java.net.MalformedURLException)2 List (java.util.List)2 Beans (org.apache.openejb.jee.Beans)2 EntityBean (org.apache.openejb.jee.EntityBean)2 Interceptor (org.apache.openejb.jee.Interceptor)2 IOException (java.io.IOException)1 URI (java.net.URI)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1