String homeServantLoggerName =
EjbHomeCorbaServant.class.getName() + '.'+ jndiName;
ServantWithMBeanServer homeServant =
new EjbHomeCorbaServant(container.getJmxName(),
container.getClassLoader(),
homeMethodMap,
homeRepositoryIds,
homeInterfaceDef,
Logger.getLogger(homeServantLoggerName));
homeReferenceFactory = homeServantRegistry.bind(homeServantName(jndiName), homeServant, policies);
org.omg.CORBA.Object corbaRef =
homeReferenceFactory.createReference(homeRepositoryIds[0]);
ejbHome = (EJBHome)PortableRemoteObject.narrow(corbaRef, EJBHome.class);
((EjbHomeCorbaServant)homeServant).setHomeHandle(
new HomeHandleImplIIOP(ejbHome));
// Initialize beanPOA and create metadata depending on the kind of bean
if (container.getBeanMetaData() instanceof EntityMetaData) {
// This is an entity bean (lifespan: persistent)
beanServantRegistry =
servantRegistries.getServantRegistry(registryWithPersistentPOA);
Class pkClass;
EntityMetaData metaData = (EntityMetaData)container.getBeanMetaData();
String pkClassName = metaData.getPrimaryKeyClass();
try {
if (pkClassName != null)
pkClass = container.getClassLoader().loadClass(pkClassName);
else
pkClass = container.getClassLoader().loadClass(
metaData.getEjbClass()).getField(
metaData.getPrimKeyField()).getClass();
}
catch (NoSuchFieldException e) {
logger.error("Unable to identify Bean's Primary Key class! "
+ "Did you specify a primary key class and/or field? "
+ "Does that field exist?");
throw new Exception("Primary Key Problem");
}
catch (NullPointerException e) {
logger.error("Unable to identify Bean's Primary Key class! "
+ "Did you specify a primary key class and/or field? "
+ "Does that field exist?");
throw new Exception("Primary Key Problem");
}
ejbMetaData = new EJBMetaDataImplIIOP(
((EJBProxyFactoryContainer)container).getRemoteClass(),
((EJBProxyFactoryContainer)container).getHomeClass(),
pkClass,
false, // Session
false, // Stateless
ejbHome);
}
else {
// This is a session bean (lifespan: transient)
beanServantRegistry =
servantRegistries.getServantRegistry(registryWithTransientPOA);
if (((SessionMetaData)container.getBeanMetaData()).isStateless()) {
// Stateless session bean
ejbMetaData = new EJBMetaDataImplIIOP(
((EJBProxyFactoryContainer)container).getRemoteClass(),
((EJBProxyFactoryContainer)container).getHomeClass(),
null, // No PK
true, // Session
true, // Stateless
ejbHome);
}
else {
// Stateful session bean
ejbMetaData = new EJBMetaDataImplIIOP(
((EJBProxyFactoryContainer)container).getRemoteClass(),
((EJBProxyFactoryContainer)container).getHomeClass(),
null, // No PK
true, // Session
false, // Stateless
ejbHome);
}
}
// If there is an interface repository, then get
// the beanInterfaceDef from the IR
InterfaceDef beanInterfaceDef = null;
if (iri != null) {
Repository ir = iri.getReference();
beanInterfaceDef =
InterfaceDefHelper.narrow(ir.lookup_id(beanRepositoryIds[0]));
}
String beanServantLoggerName =
EjbObjectCorbaServant.class.getName() + '.'+ jndiName;
ServantWithMBeanServer beanServant =
new EjbObjectCorbaServant(container.getJmxName(),
container.getClassLoader(),
poaCurrent,
beanMethodMap,
beanRepositoryIds,