Package org.odata.appengine

Source Code of org.odata.appengine.ProducerFactory

package org.odata.appengine;

import java.util.Properties;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.odata4j.edm.EdmDataServices;
import org.odata4j.producer.ODataProducer;
import org.odata4j.producer.ODataProducerFactory;
import org.odata4j.producer.jpa.JPAEdmGenerator;

public class ProducerFactory implements ODataProducerFactory {

  private static final String PERSISTENCE_UNIT_NAME = "transactions-optional";
  private static final String NAMESPACE = "Datastore";

  @Override
  public ODataProducer create(Properties properties) {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
    EdmDataServices metadata = new JPAEdmGenerator(emf, NAMESPACE).generateEdm(null).build();
    return new Producer(metadata);
  }
}
TOP

Related Classes of org.odata.appengine.ProducerFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.