~tritone-team/tritone/eucalyptus

« back to all changes in this revision

Viewing changes to clc/modules/msgs/src/main/java/com/eucalyptus/util/DatabaseUtil.java

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2009-12-01 21:09:28 UTC
  • mto: This revision was merged to the branch mainline in revision 75.
  • Revision ID: james.westby@ubuntu.com-20091201210928-o2dvg0ubljhb0ft6
Tags: upstream-1.6.1~bzr1083
ImportĀ upstreamĀ versionĀ 1.6.1~bzr1083

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import java.util.Set;
6
6
import java.util.concurrent.ConcurrentSkipListMap;
7
7
 
 
8
import javax.persistence.EntityManagerFactory;
8
9
import javax.persistence.Persistence;
9
10
 
10
11
import org.apache.log4j.Logger;
83
84
                                for ( PoolConfig p : PoolConfig.values( ) ) {
84
85
                                        LOG.debug( "-> db pool property: " + LogUtil.lineObject( p ) );
85
86
                                }
 
87
                                EntityManagerFactoryImpl createEntityManagerFactory = (EntityManagerFactoryImpl) Persistence.createEntityManagerFactory( persistenceContext );
 
88
                                emf.put( persistenceContext, createEntityManagerFactory );
86
89
                                LOG.info( "-> Setting up persistence context for : " + persistenceContext );
87
90
                                LOG.info( "-> database host: " + System.getProperty( "euca.db.host" ) );
88
91
                                LOG.info( "-> database port: " + System.getProperty( "euca.db.port" ) );
89
 
                                emf.put( persistenceContext, ( EntityManagerFactoryImpl ) Persistence.createEntityManagerFactory( persistenceContext ) );
90
92
                                for ( PooledDataSource ds : ( Set<PooledDataSource> ) C3P0Registry.getPooledDataSources( ) ) {
91
93
                                        if ( pools.containsValue( persistenceContext ) ) break;
92
94
                                        if ( !pools.containsKey( ds.getDataSourceName( ) ) ) {
151
153
                }
152
154
        }
153
155
 
 
156
        public static void closeAllEMFs() {
 
157
                for(String key : emf.keySet()) {
 
158
                        EntityManagerFactoryImpl factory = (EntityManagerFactoryImpl) emf.get(key);
 
159
                        if(factory.isOpen())
 
160
                                factory.close();
 
161
                }
 
162
        }
154
163
}