final Object existing = context.getPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY);
final Method ejbCreate = (Method) context.getPrivateData(EntityBeanHomeCreateInterceptorFactory.EJB_CREATE_METHOD_KEY);
final Method ejbPostCreate = (Method) context.getPrivateData(EntityBeanHomeCreateInterceptorFactory.EJB_POST_CREATE_METHOD_KEY);
final Object[] params = (Object[]) context.getPrivateData(EntityBeanHomeCreateInterceptorFactory.PARAMETERS_KEY);
final ComponentClientInstance clientInstance = context.getPrivateData(ComponentClientInstance.class);
if (existing != null) {
clientInstance.setViewInstanceData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY, existing);
return existing;
}
final Component component = context.getPrivateData(Component.class);
if (!(component instanceof EntityBeanComponent)) {
throw EjbLogger.ROOT_LOGGER.unexpectedComponent(component, EntityBeanComponent.class);
}
final EntityBeanComponent entityBeanComponent = (EntityBeanComponent) component;
//grab an unasociated entity bean from the pool
final EntityBeanComponentInstance instance = entityBeanComponent.acquireUnAssociatedInstance();
//call the ejbCreate method
final Object primaryKey = invokeEjbCreate(context, ejbCreate, instance, params);
instance.associate(primaryKey);
clientInstance.setViewInstanceData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY, primaryKey);
//now add the instance to the cache, so it is usable
//note that we do not release it back to the pool
//the cache will do that when it is expired or removed
boolean synchronizationRegistered = false;