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;
}
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;
}
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;
}
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;
}
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);
}
}
}
}
Aggregations