public EntityManagerFactory createEntityManagerFactory()

in jpa-container/src/main/java/org/apache/aries/jpa/container/impl/AriesEntityManagerFactoryBuilder.java [156:199]


	public EntityManagerFactory createEntityManagerFactory(Map<String, Object> props) {
		
		synchronized (this) {
			if (closed) {
				throw new IllegalStateException("The EntityManagerFactoryBuilder for " + 
						getPUName() + " is no longer valid");
			}
		}
		
		if (bundle.getState() == Bundle.UNINSTALLED || bundle.getState() == Bundle.INSTALLED
				|| bundle.getState() == Bundle.STOPPING) {
			// Not sure why but during the TCK tests updated sometimes was
			// called for uninstalled bundles
			throw new IllegalStateException("The EntityManagerFactoryBuilder for " + 
					getPUName() + " is no longer valid");
		}
		
		Map<String, Object> processedProperties = processProperties(props);
		
		synchronized (this) {
			if(processedProperties.equals(activeProps) && emf != null) {
				return emf;
			}
		}
		
		closeEMF();
		
		final EntityManagerFactory toUse = createAndPublishEMF(processedProperties);
		
		return (EntityManagerFactory) Proxy.newProxyInstance(getClass().getClassLoader(), 
				new Class<?>[] {EntityManagerFactory.class}, new InvocationHandler() {
					
					@Override
					public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
						if("close".equals(method.getName())) {
							// Close the registration as per the spec
							closeEMF();
							// Do not delegate as the closeEMF call already closes
							return null;
						}
						return method.invoke(toUse, args);
					}
				});
	}