// Should create a CORBA interface repository?
final boolean interfaceRepositorySupported = false;
final EJBComponent component = ejbComponentInjectedValue.getValue();
final String earApplicationName = component.getEarApplicationName();
if (component.getDistinctName() == null || component.getDistinctName().isEmpty()) {
name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
name = name + component.getModuleName() + "/" + component.getComponentName();
} else {
name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
name = name + component.getModuleName() + "/" + component.getDistinctName() + "/" + component.getComponentName();
}
name = name.replace(".", "_");
final ORB orb = this.orb.getValue();
if (interfaceRepositorySupported) {
// Create a CORBA interface repository for the enterprise bean
iri = new InterfaceRepository(orb, irPoa.getValue(), name);
// Add bean interface info to the interface repository
iri.mapClass(remoteView.getValue().getViewClass());
iri.mapClass(homeView.getValue().getViewClass());
iri.finishBuild();
logger.info("CORBA interface repository for " + name + ": " + orb.object_to_string(iri.getReference()));
}
// Create csiv2Policy for both home and remote containing IorSecurityConfigMetadata
final Any secPolicy = orb.create_any();
/*
IORSecurityConfigMetaData securityConfig = container.getBeanMetaData().getIorSecurityConfigMetaData();
// if no security metadata was found, get the default metadata from the registry.
if (securityConfig == null) {
securityConfig = (IORSecurityConfigMetaData) Registry.lookup(CorbaORBService.IOR_SECURITY_CONFIG);
}
*/
//TODO: setup security config
final IORSecurityConfigMetaData securityConfig = null;
secPolicy.insert_Value(securityConfig);
csiv2Policy = null; // = orb.create_policy(CSIv2Policy.TYPE, secPolicy);
// Create SSLPolicy
// (SSL_REQUIRED ensures home and remote IORs
// will have port 0 in the primary address)
boolean sslRequired = false;
if (securityConfig != null) {
IORTransportConfigMetaData tc = securityConfig.getTransportConfig();
sslRequired = tc.getIntegrity() ==
IORTransportConfigMetaData.INTEGRITY_REQUIRED
|| tc.getConfidentiality() ==
IORTransportConfigMetaData.CONFIDENTIALITY_REQUIRED
|| tc.getEstablishTrustInClient() ==
IORTransportConfigMetaData.ESTABLISH_TRUST_IN_CLIENT_REQUIRED;
}
final Any sslPolicyValue = orb.create_any();
SSLPolicyValueHelper.insert(sslPolicyValue, (sslRequired) ? SSLPolicyValue.SSL_REQUIRED : SSLPolicyValue.SSL_NOT_REQUIRED);
sslPolicy = null; //orb.create_policy(SSL_POLICY_TYPE.value, sslPolicyValue);
logger.debug("container's SSL policy: " + sslPolicy);
// Get the POACurrent object
poaCurrent = CurrentHelper.narrow(orb.resolve_initial_references("POACurrent"));
Policy[] policies = {};
/*
if (codebasePolicy == null)
policies = new Policy[]{sslPolicy, csiv2Policy};
else
policies = new Policy[]{codebasePolicy, sslPolicy, csiv2Policy};
*/
// If there is an interface repository, then get
// the homeInterfaceDef from the IR
InterfaceDef homeInterfaceDef = null;
if (iri != null) {
Repository ir = iri.getReference();
homeInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(homeRepositoryIds[0]));
}
// Instantiate home servant, bind it to the servant registry, and
// create CORBA reference to the EJBHome.
homeServantRegistry = poaRegistry.getValue().getRegistryWithPersistentPOAPerServant();
final EjbHomeCorbaServant homeServant = new EjbHomeCorbaServant(homeMethodMap, homeRepositoryIds, homeInterfaceDef, orb, homeView.getValue(), deploymentRepository.getValue(), component.getTransactionManager());
homeReferenceFactory = homeServantRegistry.bind(homeServantName(name), homeServant, policies);
final org.omg.CORBA.Object corbaRef = homeReferenceFactory.createReference(homeRepositoryIds[0]);
ejbHome = (EJBHome) PortableRemoteObject.narrow(corbaRef, EJBHome.class);
homeServant.setHomeHandle(new HomeHandleImplIIOP(corbaRef));
// Initialize beanPOA and create metadata depending on the kind of bean
if (component instanceof EntityBeanComponent) {
// This is an entity bean (lifespan: persistent)
beanServantRegistry = poaRegistry.getValue().getRegistryWithPersistentPOAPerServant();
final EntityBeanComponent entityBeanComponent = (EntityBeanComponent) component;
final Class pkClass = entityBeanComponent.getPrimaryKeyClass();
ejbMetaData = new EJBMetaDataImp(entityBeanComponent.getRemoteClass(), entityBeanComponent.getHomeClass(), pkClass, false, false, ejbHome);
} else {
// This is a session bean (lifespan: transient)
beanServantRegistry = poaRegistry.getValue().getRegistryWithTransientPOAPerServant();
if (component instanceof StatelessSessionComponent) {
// Stateless session bean
ejbMetaData = new EJBMetaDataImp(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, true, ejbHome);
} else {
// Stateful session bean
ejbMetaData = new EJBMetaDataImp(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, false, ejbHome);
}
}
// If there is an interface repository, then get
// the beanInterfaceDef from the IR
InterfaceDef beanInterfaceDef = null;
if (iri != null) {
final Repository ir = iri.getReference();
beanInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(beanRepositoryIds[0]));
}
final EjbObjectCorbaServant beanServant = new EjbObjectCorbaServant(poaCurrent, beanMethodMap, beanRepositoryIds, beanInterfaceDef, orb, remoteView.getValue(), factory, configuration, component.getTransactionManager());
beanReferenceFactory = beanServantRegistry.bind(beanServantName(name), beanServant, policies);
final NamingContextExt corbaContext = corbaNamingContext.getValue();
// Register bean home in local CORBA naming context
rebind(corbaContext, name, corbaRef);
logger.debug("Home IOR for " + component.getComponentName() + " bound to " + name + " in CORBA naming service");
} catch (Exception e) {
throw new StartException(e);
}
}