{
// ejb1.jar
JavaArchive ejbJar1 = createEjbJar("ejb1.jar", true, PlainJavaBean.class);
DeploymentUnit unit = assertDeploy(ejbJar1);
Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
Deployment deployment1 = initializeDeploymentBean(unit);
// ejb2.jar
JavaArchive ejbJar2 = createEjbJar("ejb2.jar", false, MySLSBean.class, BusinessInterface.class);
unit = assertDeploy(ejbJar2);
ClassLoader classLoader2 = unit.getClassLoader();
Class<?> mySLSBeanClass = classLoader2.loadClass(MySLSBean.class.getName());
Class<?> businessInterface = classLoader2.loadClass(BusinessInterface.class.getName());
BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
// creation of bda2 on demand
BeanDeploymentArchive bda2 = deployment1.loadBeanDeploymentArchive(mySLSBeanClass);
assertBDAId(bda2, "ejb2.jar");
assertExpectedClasses(bda2, MySLSBean.class);
assertNoBeansXml(bda2);
// double invocation
assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
assertBDAId(bda2, "ejb2.jar");
assertExpectedClasses(bda2, MySLSBean.class);
assertNoBeansXml(bda2);
// inclusion of BusinessInterface
assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
assertBDAId(bda2, "ejb2.jar");
assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
assertNoBeansXml(bda2);
// double invocation
assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
assertBDAId(bda2, "ejb2.jar");
assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
assertNoBeansXml(bda2);
}