01: /*
02: * JBoss, Home of Professional Open Source
03: * Copyright 2005, JBoss Inc., and individual contributors as indicated
04: * by the @authors tag. See the copyright.txt in the distribution for a
05: * 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.stateful.nested.base.xpc;
23:
24: import java.io.Serializable;
25:
26: import javax.ejb.EJB;
27: import javax.ejb.Remove;
28: import javax.persistence.EntityManager;
29: import javax.persistence.PersistenceContext;
30: import javax.persistence.PersistenceContextType;
31:
32: import org.jboss.ejb3.test.stateful.nested.base.DeepNestedStateful;
33: import org.jboss.ejb3.test.stateful.nested.base.PassivationActivationWatcherBean;
34:
35: /**
36: * Comment
37: *
38: * @author Ben Wang
39: * @version $Revision: 60062 $
40: */
41: public class ContainedBean extends PassivationActivationWatcherBean
42: implements Contained, Serializable {
43: /** The serialVersionUID */
44: private static final long serialVersionUID = 1L;
45:
46: @PersistenceContext(unitName="tempdb",type=PersistenceContextType.EXTENDED)
47: private EntityManager em;
48:
49: @EJB(beanName="testDeepNestedContained")
50: private DeepNestedContained deepNestedContained;
51:
52: private Customer customer;
53:
54: public Customer find(long id) {
55: Customer c = em.find(Customer.class, id);
56: log.trace("customer " + id + " = " + c);
57: return c;
58: }
59:
60: public void setCustomer(long id) {
61: customer = find(id);
62: }
63:
64: public Customer getCustomer() {
65: return customer;
66: }
67:
68: public void updateCustomer() {
69: customer.setName("contained modified");
70: }
71:
72: public void setContainedCustomer() {
73: deepNestedContained.setCustomer(customer.getId());
74: }
75:
76: public boolean checkContainedCustomer() {
77: return (deepNestedContained.getCustomer() == customer);
78: }
79:
80: @Remove
81: public void remove() {
82:
83: }
84:
85: public DeepNestedStateful getDeepNestedStateful() {
86: return deepNestedContained;
87: }
88:
89: public void reset() {
90: super.reset();
91: deepNestedContained.reset();
92: }
93:
94: }
|