Search in sources :

Example 36 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class CmpJpaConversion method deploy.

public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    if (!hasCmpEntities(appModule)) {
        return appModule;
    }
    // todo scan existing persistence module for all entity mappings and don't generate mappings for them
    // create mappings if no mappings currently exist
    EntityMappings cmpMappings = appModule.getCmpMappings();
    if (cmpMappings == null) {
        cmpMappings = new EntityMappings();
        cmpMappings.setVersion("1.0");
        appModule.setCmpMappings(cmpMappings);
    }
    // app mapping data
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        final EjbJar ejbJar = ejbModule.getEjbJar();
        // scan for CMP entity beans and merge the data into the collective set
        for (final EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
            if (isCmpEntity(enterpriseBean)) {
                processEntityBean(ejbModule, cmpMappings, (EntityBean) enterpriseBean);
            }
        }
        // if there are relationships defined in this jar, get a list of the defined
        // entities and process the relationship maps.
        final Relationships relationships = ejbJar.getRelationships();
        if (relationships != null) {
            final Map<String, Entity> entitiesByEjbName = new TreeMap<String, Entity>();
            for (final Entity entity : cmpMappings.getEntity()) {
                entitiesByEjbName.put(entity.getEjbName(), entity);
            }
            for (final EjbRelation relation : relationships.getEjbRelation()) {
                processRelationship(entitiesByEjbName, relation);
            }
        }
        // Let's warn the user about any declarations we didn't end up using
        // so there can be no misunderstandings.
        final EntityMappings userMappings = getUserEntityMappings(ejbModule);
        for (final Entity mapping : userMappings.getEntity()) {
            logger.warning("openejb-cmp-orm.xml mapping ignored: module=" + ejbModule.getModuleId() + ":  <entity class=\"" + mapping.getClazz() + "\">");
        }
        for (final MappedSuperclass mapping : userMappings.getMappedSuperclass()) {
            logger.warning("openejb-cmp-orm.xml mapping ignored: module=" + ejbModule.getModuleId() + ":  <mapped-superclass class=\"" + mapping.getClazz() + "\">");
        }
    }
    if (!cmpMappings.getEntity().isEmpty()) {
        final PersistenceUnit persistenceUnit = getCmpPersistenceUnit(appModule);
        persistenceUnit.getMappingFile().add("META-INF/openejb-cmp-generated-orm.xml");
        for (final Entity entity : cmpMappings.getEntity()) {
            persistenceUnit.getClazz().add(entity.getClazz());
        }
    }
    // causes some of the unit tests to fail.  Not sure why.  Should be fixed.
    for (final Entity entity : appModule.getCmpMappings().getEntity()) {
        if (entity.getAttributes() != null && entity.getAttributes().isEmpty()) {
            entity.setAttributes(null);
        }
    }
    return appModule;
}
Also used : Entity(org.apache.openejb.jee.jpa.Entity) Relationships(org.apache.openejb.jee.Relationships) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) PersistenceUnit(org.apache.openejb.jee.jpa.unit.PersistenceUnit) EjbRelation(org.apache.openejb.jee.EjbRelation) MappedSuperclass(org.apache.openejb.jee.jpa.MappedSuperclass) EntityMappings(org.apache.openejb.jee.jpa.EntityMappings) TreeMap(java.util.TreeMap) EjbJar(org.apache.openejb.jee.EjbJar)

Example 37 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class LegacyProcessor method deploy.

@Override
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        final ClassLoader classLoader = ejbModule.getClassLoader();
        for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
            if (bean.getEjbClass() == null) {
                continue;
            }
            try {
                final Class<?> clazz = classLoader.loadClass(bean.getEjbClass());
                process(clazz, bean);
            } catch (final ClassNotFoundException e) {
            // skip, we'll get this in validation
            }
        }
    }
    return appModule;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean)

Example 38 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class LinkBuiltInTypes method deploy.

@Override
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    for (final ClientModule module : appModule.getClientModules()) {
        final JndiConsumer consumer = module.getApplicationClient();
        if (consumer == null) {
            continue;
        }
        link(consumer);
    }
    for (final WebModule module : appModule.getWebModules()) {
        final JndiConsumer consumer = module.getWebApp();
        if (consumer == null) {
            continue;
        }
        link(consumer);
    }
    for (final EjbModule module : appModule.getEjbModules()) {
        final EjbJar ejbJar = module.getEjbJar();
        if (ejbJar == null) {
            continue;
        }
        for (final EnterpriseBean consumer : ejbJar.getEnterpriseBeans()) {
            link(consumer);
        }
    }
    return appModule;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) JndiConsumer(org.apache.openejb.jee.JndiConsumer) EjbJar(org.apache.openejb.jee.EjbJar)

Example 39 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class MappedNameBuilder method deploy.

public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
        if (openejbJar == null) {
            return appModule;
        }
        final Map<String, EjbDeployment> ejbDeployments = openejbJar.getDeploymentsByEjbName();
        for (final EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) {
            final EjbDeployment ejbDeployment = ejbDeployments.get(enterpriseBean.getEjbName());
            if (ejbDeployment == null) {
                continue;
            }
            final String mappedName = enterpriseBean.getMappedName();
            if (mappedName != null && mappedName.length() > 0) {
                ejbDeployment.getJndi().add(new Jndi(mappedName, "Remote"));
            }
        }
    }
    return appModule;
}
Also used : OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) Jndi(org.apache.openejb.jee.oejb3.Jndi)

Example 40 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class OpenEjb2Conversion method convertMdbConfigs.

public final void convertMdbConfigs(final EjbJar ejbJar, final OpenejbJarType openejbJarType) {
    final Map<String, MessageDrivenBean> mdbs = new TreeMap<String, MessageDrivenBean>();
    for (final EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
        if (!(enterpriseBean instanceof MessageDrivenBean)) {
            continue;
        }
        mdbs.put(enterpriseBean.getEjbName(), (MessageDrivenBean) enterpriseBean);
    }
    for (final org.apache.openejb.jee.oejb2.EnterpriseBean enterpriseBean : openejbJarType.getEnterpriseBeans()) {
        if (!(enterpriseBean instanceof MessageDrivenBeanType)) {
            continue;
        }
        final MessageDrivenBeanType bean = (MessageDrivenBeanType) enterpriseBean;
        final MessageDrivenBean mdb = mdbs.get(bean.getEjbName());
        if (mdb == null) {
            // todo warn no such ejb in the ejb-jar.xml
            continue;
        }
        final ActivationConfigType activationConfigType = bean.getActivationConfig();
        if (activationConfigType != null) {
            ActivationConfig activationConfig = mdb.getActivationConfig();
            if (activationConfig == null) {
                activationConfig = new ActivationConfig();
                mdb.setActivationConfig(activationConfig);
            }
            for (final ActivationConfigPropertyType propertyType : activationConfigType.getActivationConfigProperty()) {
                final ActivationConfigProperty property = new ActivationConfigProperty(propertyType.getActivationConfigPropertyName(), propertyType.getActivationConfigPropertyValue());
                activationConfig.getActivationConfigProperty().add(property);
            }
        }
    }
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) MessageDrivenBeanType(org.apache.openejb.jee.oejb2.MessageDrivenBeanType) TreeMap(java.util.TreeMap) ActivationConfig(org.apache.openejb.jee.ActivationConfig) ActivationConfigProperty(org.apache.openejb.jee.ActivationConfigProperty) ActivationConfigPropertyType(org.apache.openejb.jee.oejb2.ActivationConfigPropertyType) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) ActivationConfigType(org.apache.openejb.jee.oejb2.ActivationConfigType)

Aggregations

EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)46 EjbJar (org.apache.openejb.jee.EjbJar)19 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)16 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)14 SessionBean (org.apache.openejb.jee.SessionBean)12 ArrayList (java.util.ArrayList)9 EjbModule (org.apache.openejb.config.EjbModule)9 HashMap (java.util.HashMap)8 OpenEJBException (org.apache.openejb.OpenEJBException)7 MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)7 Map (java.util.Map)6 AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)6 Interceptor (org.apache.openejb.jee.Interceptor)6 List (java.util.List)5 Properties (java.util.Properties)5 EntityBean (org.apache.openejb.jee.EntityBean)5 InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)5 ResourceLink (org.apache.openejb.jee.oejb3.ResourceLink)5 Resources (org.apache.openejb.config.sys.Resources)4 JndiConsumer (org.apache.openejb.jee.JndiConsumer)4