use of org.apache.openejb.jee.EjbJar$JAXB 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.EjbJar$JAXB 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.EjbJar$JAXB in project tomee by apache.
the class DebuggableVmHackery method deploy.
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
for (final EjbModule ejbModule : appModule.getEjbModules()) {
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
ejbJar.setRelationships(null);
final List<String> removed = new ArrayList<String>();
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
final String ejbName = bean.getEjbName();
final EjbDeployment ejbDeployment = deployments.get(ejbName);
pruneRefs(bean, ejbDeployment);
// }
if (!(bean instanceof MessageDrivenBean) && !(bean instanceof EntityBean)) {
continue;
}
ejbJar.removeEnterpriseBean(ejbName);
openejbJar.removeEjbDeployment(ejbDeployment);
removed.add(ejbName);
final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
for (final MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
for (final Method method : copy(permission.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
permission.getMethod().remove(method);
}
}
if (permission.getMethod().size() == 0) {
assemblyDescriptor.getMethodPermission().remove(permission);
}
}
for (final ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
for (final Method method : copy(transaction.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
transaction.getMethod().remove(method);
}
}
if (transaction.getMethod().size() == 0) {
assemblyDescriptor.getContainerTransaction().remove(transaction);
}
}
for (final InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
if (binding.getEjbName().equals(ejbName)) {
assemblyDescriptor.getInterceptorBinding().remove(binding);
}
}
}
}
// Drop any ejb ref to with an ejb-link to a removed ejb
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
bean.getEjbLocalRefMap().keySet().removeAll(removed);
bean.getEjbRefMap().keySet().removeAll(removed);
}
for (final Interceptor interceptor : ejbJar.getInterceptors()) {
pruneRefs(interceptor, new EjbDeployment());
}
}
return appModule;
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class DeploymentLoader method fillEjbJar.
/**
* If the web.xml is metadata-complete and there is no ejb-jar.xml
* then per specification we use the web.xml metadata-complete setting
* to imply the same for EJBs.
*
* @param webModule WebModule
* @param ejbModule EjbModule
*/
private static void fillEjbJar(final WebModule webModule, final EjbModule ejbModule) {
final Object o = webModule.getAltDDs().get("ejb-jar.xml");
if (o != null) {
return;
}
if (ejbModule.getEjbJar() != null) {
return;
}
final EjbJar ejbJar = new EjbJar();
final WebApp webApp = webModule.getWebApp();
ejbJar.setMetadataComplete(webApp.isMetadataComplete());
ejbModule.setEjbJar(ejbJar);
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class DeploymentLoader method addBeansXmls.
private void addBeansXmls(final AppModule appModule) {
final List<URL> urls = appModule.getAdditionalLibraries();
final URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
final ArrayList<URL> xmls;
try {
xmls = Collections.list(loader.getResources("META-INF/beans.xml"));
} catch (final IOException e) {
return;
}
final CompositeBeans complete = new CompositeBeans();
for (final URL url : xmls) {
if (url == null) {
continue;
}
mergeBeansXml(complete, url);
}
if (complete.getDiscoveryByUrl().isEmpty()) {
return;
}
complete.removeDuplicates();
ensureContainerUrls();
appModule.getScannableContainerUrls().addAll(containerUrls);
IAnnotationFinder finder;
try {
finder = FinderFactory.createFinder(appModule);
} catch (final Exception e) {
finder = new FinderFactory.ModuleLimitedFinder(new FinderFactory.OpenEJBAnnotationFinder(new WebappAggregatedArchive(appModule.getClassLoader(), appModule.getAltDDs(), xmls)));
}
appModule.setEarLibFinder(finder);
final EjbModule ejbModule = new EjbModule(appModule.getClassLoader(), EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar());
ejbModule.setBeans(complete);
ejbModule.setFinder(finder);
ejbModule.setEjbJar(new EmptyEjbJar());
appModule.getEjbModules().add(ejbModule);
}
Aggregations