KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > standalone > flushmodenever > Session2Bean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * 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 JavaDoc;
27 import javax.ejb.Remote JavaDoc;
28 import javax.ejb.Stateless JavaDoc;
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: 45473 $
39  */

40 @Stateless JavaDoc
41 @Remote JavaDoc(Session2.class)
42 public class Session2Bean implements Session2
43 {
44    @PersistenceContext(unitName="manager2") EntityManager manager2;
45    @PersistenceContext(unitName="../flushmodenever-session1.jar#manager1") EntityManager manager1;
46    @PersistenceUnit(unitName="manager2") EntityManagerFactory factory2;
47    @PersistenceUnit(unitName="../flushmodenever-session1.jar#manager1") EntityManagerFactory factory1;
48    @EJB JavaDoc @IgnoreDependency Session1 session1;
49
50    //@Resource SessionContext ctx;
51

52    public Entity1 find1FromManager(int id)
53    {
54       return manager1.find(Entity1.class, id);
55    }
56    public void find1FromFactory(int id)
57    {
58       EntityManager m = factory1.createEntityManager();
59       Entity1 one = m.find(Entity1.class, id);
60       try
61       {
62          if (one == null) throw new RuntimeException JavaDoc("NOT FOUND");
63       }
64       finally
65       {
66          m.close();
67       }
68
69    }
70    public Entity2 find2FromManager(int id)
71    {
72       return manager2.find(Entity2.class, id);
73    }
74    public void find2FromFactory(int id)
75    {
76       EntityManager m = factory2.createEntityManager();
77       Entity2 two = m.find(Entity2.class, id);
78       if (two == null) throw new RuntimeException JavaDoc("NOT FOUND");
79       // leak m.close();
80
}
81
82    public Util findUtil1FromManager(int id)
83    {
84       return manager1.find(Util.class, id);
85    }
86
87    public Util findUtil2FromManager(int id)
88    {
89       return manager2.find(Util.class, id);
90    }
91 }
92
Popular Tags