1 2 12 package com.versant.core.ejb; 13 14 import com.versant.core.jdo.PersistenceManagerFactoryBase; 15 import com.versant.core.jdo.BootstrapPMF; 16 import com.versant.core.jdo.LifecycleListener; 17 import com.versant.core.jdo.VersantPMFInternal; 18 import com.versant.core.storagemanager.StorageManagerFactory; 19 import com.versant.core.storagemanager.StorageCache; 20 import com.versant.core.metric.Metric; 21 import com.versant.core.metric.MetricSnapshotPacket; 22 import com.versant.core.server.DataStoreInfo; 23 import com.versant.core.logging.LogEventStore; 24 import com.versant.core.logging.LogEvent; 25 import com.versant.core.common.config.ConfigParser; 26 import com.versant.core.metadata.MDStatics; 27 28 import javax.persistence.EntityManager; 29 import javax.persistence.EntityManagerFactory; 30 import javax.jdo.PersistenceManagerFactory; 31 import java.util.Map ; 32 import java.util.Properties ; 33 34 37 public class EntityManagerFactoryImp implements EntityManagerFactory { 38 private VersantPMFInternal pmf; 39 40 public EntityManagerFactoryImp(PersistenceManagerFactory pmf) { 41 this.pmf = (VersantPMFInternal) pmf; 42 } 43 44 public static EntityManagerFactoryImp getEntityManagerFactory( 45 Properties props) { 46 props.setProperty(ConfigParser.META_DATA_PRE_PROCESSOR, 47 props.getProperty(ConfigParser.META_DATA_PRE_PROCESSOR, 48 MDStatics.EJB_JDBC_PRE_PROCESSOR)); 49 PersistenceManagerFactoryBase pmfBase = 50 (PersistenceManagerFactoryBase) BootstrapPMF.getPersistenceManagerFactory(props); 51 return new EntityManagerFactoryImp(pmfBase); 52 } 53 54 public EntityManager getEntityManager() { 55 return new EntityManagerImp( 56 pmf.getStorageManagerFactory().getStorageManager(), 57 pmf.getJDOMetaData()); 58 } 59 60 protected StorageManagerFactory createStorageManagerFactory() { 61 return null; 62 } 63 64 public Metric[] getMetrics() { 65 return pmf.getMetrics(); 66 } 67 68 public MetricSnapshotPacket getNewMetricSnapshots(int lastId) { 69 return pmf.getNewMetricSnapshots(lastId); 70 } 71 72 public MetricSnapshotPacket getMostRecentMetricSnapshot(int lastId) { 73 return pmf.getMostRecentMetricSnapshot(lastId); 74 } 75 76 public void setUserMetric(String name, int value) { 77 pmf.setUserMetric(name, value); 78 } 79 80 public void incUserMetric(String name, int delta) { 81 pmf.incUserMetric(name, delta); 82 } 83 84 public int getUserMetric(String name) { 85 return pmf.getUserMetric(name); 86 } 87 88 public Map getHyperdriveBytecode() { 89 return pmf.getHyperdriveBytecode(); 90 } 91 92 public int getHyperdriveBytecodeMaxSize() { 93 return pmf.getHyperdriveBytecodeMaxSize(); 94 } 95 96 public DataStoreInfo getDataStoreInfo(String datastore) { 97 return pmf.getStorageManagerFactory().getDataStoreInfo(); 98 } 99 100 public void evictAll() { 101 pmf.evictAll(); 102 } 103 104 public void logEvent(int eventNormal, String s, int i) { 105 pmf.logEvent(eventNormal, s, i); 106 } 107 108 public void addLifecycleListener(LifecycleListener listener, 109 Class [] classes) { 110 pmf.addLifecycleListener(listener, classes); 111 } 112 113 public boolean isLocal() { 114 return pmf.isLocal(); 115 } 116 117 public LogEventStore getLogEventStore() { 118 return pmf.getLogEventStore(); 119 } 120 121 public LogEvent[] getNewPerfEvents(int lastEQEventId) { 122 return pmf.getNewPerfEvents(lastEQEventId); 123 } 124 125 public String getConnectionURL() { 126 return pmf.getConnectionURL(); 127 } 128 129 public StorageCache getStorageCache() { 130 return pmf.getStorageCache(); 131 } 132 133 public StorageManagerFactory getStorageManagerFactory() { 134 return pmf.getStorageManagerFactory(); 135 } 136 } 137 | Popular Tags |