1 22 package org.jboss.ejb3; 23 24 import java.util.concurrent.ConcurrentHashMap ; 25 import java.util.Collection ; 26 import org.jboss.logging.Logger; 27 import org.jboss.ejb3.entity.PersistenceUnitDeployment; 28 29 33 public class PersistenceUnitRegistry 34 { 35 private static final Logger log = Logger.getLogger(PersistenceUnitRegistry.class); 36 37 private static ConcurrentHashMap <String , PersistenceUnitDeployment> persistenceUnits = new ConcurrentHashMap <String , PersistenceUnitDeployment>(); 38 39 public static void register(PersistenceUnitDeployment container) 40 { 41 if (persistenceUnits.contains(container.getKernelName())) throw new RuntimeException ("Persistence Unit is already registered: " + container.getKernelName()); 42 persistenceUnits.put(container.getKernelName(), container); 43 } 44 45 public static void unregister(PersistenceUnitDeployment container) 46 { 47 persistenceUnits.remove(container.getKernelName()); 48 } 49 50 public static PersistenceUnitDeployment getPersistenceUnit(String kernelName) 51 { 52 return persistenceUnits.get(kernelName); 53 } 54 55 public static Collection <PersistenceUnitDeployment> getPersistenceUnits() 56 { 57 return persistenceUnits.values(); 58 } 59 60 } 61 | Popular Tags |