Search in sources :

Example 51 with AppModule

use of org.apache.openejb.config.AppModule 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

AppModule (org.apache.openejb.config.AppModule)51 EjbModule (org.apache.openejb.config.EjbModule)41 EjbJar (org.apache.openejb.jee.EjbJar)40 StatelessBean (org.apache.openejb.jee.StatelessBean)18 InitialContext (javax.naming.InitialContext)15 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)15 Properties (java.util.Properties)14 AppInfo (org.apache.openejb.assembler.classic.AppInfo)14 Assembler (org.apache.openejb.assembler.classic.Assembler)14 SingletonBean (org.apache.openejb.jee.SingletonBean)11 Test (org.junit.Test)10 WebModule (org.apache.openejb.config.WebModule)9 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)8 File (java.io.File)7 IOException (java.io.IOException)6 List (java.util.List)6 OpenEJBException (org.apache.openejb.OpenEJBException)6 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)6 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)6 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)6