MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbOpenJPABrokerFactory.java
1 /*
2  Copyright 2010 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 package com.mysql.clusterj.openjpa;
20 
21 import com.mysql.clusterj.core.util.I18NHelper;
22 import com.mysql.clusterj.core.util.Logger;
23 import com.mysql.clusterj.core.util.LoggerFactoryService;
24 
25 import java.util.Map;
26 
27 import org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory;
28 
29 import org.apache.openjpa.kernel.Bootstrap;
30 import org.apache.openjpa.kernel.StoreManager;
31 
32 import org.apache.openjpa.lib.conf.ConfigurationProvider;
33 
38 @SuppressWarnings("serial")
39 public class NdbOpenJPABrokerFactory extends JDBCBrokerFactory {
40 
42  static final I18NHelper local = I18NHelper.getInstance(NdbOpenJPABrokerFactory.class);
43 
46 
51  public static NdbOpenJPABrokerFactory newInstance(ConfigurationProvider cp) {
53  cp.setInto(conf);
54  return new NdbOpenJPABrokerFactory(conf);
55  }
56 
61  public static NdbOpenJPABrokerFactory getInstance(ConfigurationProvider cp) {
62  Map<String, Object> props = cp.getProperties();
63  Object key = toPoolKey(props);
65  getPooledFactoryForKey(key);
66  if (factory != null)
67  return factory;
68 
69  factory = newInstance(cp);
70  pool(key, factory);
71  return factory;
72  }
73 
79  super(conf);
80  if (logger.isInfoEnabled()) {
81  StringBuffer buffer = new StringBuffer();
82  buffer.append("connectString: " + conf.getConnectString());
83  buffer.append("; connectDelay: " + conf.getConnectDelay());
84  buffer.append("; connectVerbose: " + conf.getConnectVerbose());
85  buffer.append("; connectTimeoutBefore: " + conf.getConnectTimeoutBefore());
86  buffer.append("; connectTimeoutAfter: " + conf.getConnectTimeoutAfter());
87  buffer.append("; maxTransactions: " + conf.getMaxTransactions());
88  buffer.append("; default database: " + conf.getDatabase());
89  logger.info(buffer.toString());
90  }
91  }
92 
93  @Override
94  protected StoreManager newStoreManager() {
95  return new NdbOpenJPAStoreManager();
96  }
97 
98 }