// Register the factory bean, and then create an entitymanager from it
ctx.getComponentDefinitionRegistry().registerComponentDefinition(
factory);
MutableBeanMetadata meta = ctx.createMetadata(MutableBeanMetadata.class);
MutableRefMetadata ref = ctx.createMetadata(MutableRefMetadata.class);
ref.setComponentId(factory.getId());
meta.setFactoryComponent(ref);
meta.setActivation(factory.getActivation());
meta.setFactoryMethod("createEntityManager");
meta.setScope(BeanMetadata.SCOPE_PROTOTYPE);
meta.setDestroyMethod("internalClose");