01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.ejb3.test.standalone.flushmodenever;
23:
24: import org.jboss.annotation.IgnoreDependency;
25:
26: import javax.ejb.EJB;
27: import javax.ejb.Remote;
28: import javax.ejb.Stateless;
29: import javax.persistence.EntityManager;
30: import javax.persistence.EntityManagerFactory;
31: import javax.persistence.PersistenceContext;
32: import javax.persistence.PersistenceUnit;
33:
34: /**
35: * Comment
36: *
37: * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
38: * @version $Revision: 60233 $
39: */
40: @Stateless
41: @Remote(Session2.class)
42: public class Session2Bean implements Session2 {
43: @PersistenceContext(unitName="manager2")
44: EntityManager manager2;
45: @PersistenceContext(unitName="../flushmodenever-session1.jar#manager1")
46: EntityManager manager1;
47: @PersistenceUnit(unitName="manager2")
48: EntityManagerFactory factory2;
49: @PersistenceUnit(unitName="../flushmodenever-session1.jar#manager1")
50: EntityManagerFactory factory1;
51: @EJB
52: @IgnoreDependency
53: Session1 session1;
54:
55: //@Resource SessionContext ctx;
56:
57: public Entity1 find1FromManager(int id) {
58: return manager1.find(Entity1.class, id);
59: }
60:
61: public void find1FromFactory(int id) {
62: EntityManager m = factory1.createEntityManager();
63: Entity1 one = m.find(Entity1.class, id);
64: try {
65: if (one == null)
66: throw new RuntimeException("NOT FOUND");
67: } finally {
68: m.close();
69: }
70:
71: }
72:
73: public Entity2 find2FromManager(int id) {
74: return manager2.find(Entity2.class, id);
75: }
76:
77: public void find2FromFactory(int id) {
78: EntityManager m = factory2.createEntityManager();
79: Entity2 two = m.find(Entity2.class, id);
80: if (two == null)
81: throw new RuntimeException("NOT FOUND");
82: // leak m.close();
83: }
84:
85: public Util findUtil1FromManager(int id) {
86: return manager1.find(Util.class, id);
87: }
88:
89: public Util findUtil2FromManager(int id) {
90: return manager2.find(Util.class, id);
91: }
92: }
|