public void initContext() throws DeploymentException {
for (EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) {
AbstractName abstractName = createEjbName(enterpriseBean);
GBeanData gbean = null;
if (enterpriseBean instanceof SessionBean) {
SessionBean sessionBean = (SessionBean) enterpriseBean;
switch (sessionBean.getSessionType()) {
case STATELESS:
gbean = new GBeanData(abstractName, StatelessDeploymentGBean.GBEAN_INFO);
break;
case STATEFUL:
gbean = new GBeanData(abstractName, StatefulDeploymentGBean.GBEAN_INFO);
break;
}
} else if (enterpriseBean instanceof EntityBean) {
gbean = new GBeanData(abstractName, EntityDeploymentGBean.GBEAN_INFO);
} else if (enterpriseBean instanceof MessageDrivenBean) {
gbean = new GBeanData(abstractName, MessageDrivenDeploymentGBean.GBEAN_INFO);
}
if (gbean == null) {
throw new DeploymentException("Unknown enterprise bean type " + enterpriseBean.getClass().getName());
}
String ejbName = enterpriseBean.getEjbName();
EjbDeployment ejbDeployment = ejbModule.getOpenejbJar().getDeploymentsByEjbName().get(ejbName);
if (ejbDeployment == null) {
throw new DeploymentException("OpenEJB configuration not found for ejb " + ejbName);
}
gbean.setAttribute("deploymentId", ejbDeployment.getDeploymentId());
gbean.setAttribute("ejbName", ejbName);
// set interface class names
if (enterpriseBean instanceof RemoteBean) {
RemoteBean remoteBean = (RemoteBean) enterpriseBean;
// Remote
if (remoteBean.getRemote() != null) {
String remoteInterfaceName = remoteBean.getRemote();
assureEJBObjectInterface(remoteInterfaceName, ejbModule.getClassLoader());
gbean.setAttribute(EjbInterface.REMOTE.getAttributeName(), remoteInterfaceName);
String homeInterfaceName = remoteBean.getHome();
assureEJBHomeInterface(homeInterfaceName, ejbModule.getClassLoader());
gbean.setAttribute(EjbInterface.HOME.getAttributeName(), homeInterfaceName);
}
// Local
if (remoteBean.getLocal() != null) {
String localInterfaceName = remoteBean.getLocal();
assureEJBLocalObjectInterface(localInterfaceName, ejbModule.getClassLoader());
gbean.setAttribute(EjbInterface.LOCAL.getAttributeName(), localInterfaceName);
String localHomeInterfaceName = remoteBean.getLocalHome();
assureEJBLocalHomeInterface(localHomeInterfaceName, ejbModule.getClassLoader());
gbean.setAttribute(EjbInterface.LOCAL_HOME.getAttributeName(), localHomeInterfaceName);
}
if (enterpriseBean instanceof SessionBean && ((SessionBean)enterpriseBean).getSessionType() == SessionType.STATELESS ) {
SessionBean statelessBean = (SessionBean) enterpriseBean;
gbean.setAttribute(EjbInterface.SERVICE_ENDPOINT.getAttributeName(), statelessBean.getServiceEndpoint());
}
}
// set reference patterns
gbean.setReferencePattern("TrackedConnectionAssociator", new AbstractNameQuery(null, Collections.EMPTY_MAP, TrackedConnectionAssociator.class.getName()));