01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.geronimo.openejb;
21:
22: import java.util.Map;
23:
24: import javax.persistence.EntityManager;
25: import javax.persistence.EntityManagerFactory;
26:
27: import org.apache.geronimo.persistence.ExtendedEntityManagerRegistry;
28: import org.apache.geronimo.gbean.GBeanInfoBuilder;
29: import org.apache.geronimo.gbean.GBeanInfo;
30: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
31: import org.apache.openejb.persistence.JtaEntityManagerRegistry;
32: import org.apache.openejb.loader.SystemInstance;
33:
34: /**
35: * @version $Rev: 538730 $ $Date: 2007-05-16 14:07:51 -0700 (Wed, 16 May 2007) $
36: */
37: public class EntityManagerRegistryImpl implements
38: ExtendedEntityManagerRegistry {
39:
40: private final JtaEntityManagerRegistry entityManagerRegistry;
41:
42: public EntityManagerRegistryImpl() {
43: entityManagerRegistry = SystemInstance.get().getComponent(
44: JtaEntityManagerRegistry.class);
45: }
46:
47: public EntityManagerRegistryImpl(
48: JtaEntityManagerRegistry entityManagerRegistry) {
49: this .entityManagerRegistry = entityManagerRegistry;
50: }
51:
52: public EntityManager getEntityManager(
53: EntityManagerFactory entityManagerFactory, Map properties)
54: throws IllegalStateException {
55: return entityManagerRegistry.getEntityManager(
56: entityManagerFactory, properties, true);
57: }
58:
59: public static final GBeanInfo GBEAN_INFO;
60:
61: static {
62: GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(
63: EntityManagerRegistryImpl.class,
64: NameFactory.GERONIMO_SERVICE);
65: GBEAN_INFO = infoBuilder.getBeanInfo();
66:
67: }
68:
69: public static GBeanInfo getGBeanInfo() {
70: return GBEAN_INFO;
71: }
72:
73: }
|