use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class AnnotationDeployerTest method interceptingGenericBusinessMethodCalls.
/**
* For https://issues.apache.org/jira/browse/OPENEJB-1128
*/
@Test
public void interceptingGenericBusinessMethodCalls() throws Exception {
EjbModule ejbModule = testModule();
final EjbJar ejbJar = ejbModule.getEjbJar();
final AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans();
ejbModule = discvrAnnBeans.deploy(ejbModule);
final EnterpriseBean bean = ejbJar.getEnterpriseBean("InterceptedSLSBean");
assert bean != null;
}
use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class AnnotationDeployerTest method testLocalBean.
/**
* For https://issues.apache.org/jira/browse/OPENEJB-1188
*
* @throws Exception
*/
@Test
public void testLocalBean() throws Exception {
final EjbModule ejbModule = testModule();
final EjbJar ejbJar = ejbModule.getEjbJar();
AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), "myapp");
appModule.getEjbModules().add(ejbModule);
final AnnotationDeployer annotationDeployer = new AnnotationDeployer();
appModule = annotationDeployer.deploy(appModule);
EnterpriseBean bean = ejbJar.getEnterpriseBean("TestLocalBean");
assert bean != null;
assert (((SessionBean) bean).getLocalBean() != null);
bean = ejbJar.getEnterpriseBean("InterceptedSLSBean");
assert bean != null;
assert (((SessionBean) bean).getLocalBean() == null);
}
use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class EnvEntriesPropertiesDeployer method deploy.
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
// ApplicationClient META-INF/env-entries.properties
for (final ClientModule module : appModule.getClientModules()) {
if (module.getApplicationClient() == null) {
continue;
}
for (final Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
final EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
apply(module.getApplicationClient(), envEntry, "AppClient");
}
}
// WebModule META-INF/env-entries.properties
for (final WebModule webModule : appModule.getWebModules()) {
deploy(webModule);
}
// EjbJar META-INF/env-entries.properties
for (final EjbModule module : appModule.getEjbModules()) {
for (final Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
final EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
// <ejb-name>.name = value
if (envEntry.getName().contains(".")) {
String name = envEntry.getName();
final String ejbName = name.substring(0, name.indexOf('.'));
name = name.substring(name.indexOf('.') + 1);
final EnterpriseBean bean = module.getEjbJar().getEnterpriseBean(ejbName);
if (bean != null) {
// Set the new property name without the <ejb-name>. prefix
envEntry.setName(name);
apply(bean, envEntry, bean.getEjbName());
continue;
}
}
for (final EnterpriseBean bean : module.getEjbJar().getEnterpriseBeans()) {
apply(bean, envEntry, bean.getEjbName());
}
}
}
return appModule;
}
use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class GeronimoMappedName method mapReferences.
private void mapReferences(final EjbJar ejbJar) {
if (ejbJar == null) {
return;
}
for (final EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
for (final EjbRef ref : enterpriseBean.getEjbRef()) {
// remap only corba references
final String mappedName = ref.getMappedName();
if (mappedName != null && (mappedName.startsWith("jndi:corbaloc") || mappedName.startsWith("jndi:corbaname"))) {
final String refName = ref.getEjbRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
if (null == mappedName && ref.getEjbRefName().equals("ejb/MEJB")) {
ref.setMappedName("mejb/ejb/mgmt/MEJB");
}
}
for (final MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
final String refName = ref.getMessageDestinationRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final PersistenceContextRef ref : enterpriseBean.getPersistenceContextRef()) {
final String refName = ref.getPersistenceContextRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final PersistenceUnitRef ref : enterpriseBean.getPersistenceUnitRef()) {
final String refName = ref.getPersistenceUnitRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final ResourceRef ref : enterpriseBean.getResourceRef()) {
final String refName = ref.getResRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final ResourceEnvRef ref : enterpriseBean.getResourceEnvRef()) {
final String refName = ref.getResourceEnvRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final ServiceRef ref : enterpriseBean.getServiceRef()) {
final String refName = ref.getServiceRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
}
}
use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.
the class InitEjbDeployments method deploy.
public synchronized AppModule deploy(final AppModule appModule) throws OpenEJBException {
final Set<String> abstractSchemaNames = new HashSet<String>();
for (final EjbModule ejbModule : appModule.getEjbModules()) {
for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
if (isCmpEntity(bean)) {
final EntityBean entity = (EntityBean) bean;
final String name = entity.getAbstractSchemaName();
if (name != null) {
abstractSchemaNames.add(name);
}
}
}
}
final Map<String, String> contextData = new HashMap<String, String>();
contextData.put("appId", appModule.getModuleId());
for (final EjbModule ejbModule : appModule.getEjbModules()) {
contextData.put("host", ejbModule.isWebapp() ? findHost(ejbModule.getModuleId(), appModule.getWebModules()) : appModule.uniqueHostIfExists());
contextData.put("hash", Integer.toString(ejbModule.hashCode()));
contextData.put("ejbJarId", ejbModule.getModuleId());
deploy(ejbModule, contextData, abstractSchemaNames);
}
contextData.clear();
return appModule;
}
Aggregations