KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > enums > ejb > FacadeSessionBean


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.test.cmp2.enums.ejb;
23
24 import java.util.Collection JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import javax.ejb.SessionBean JavaDoc;
29 import javax.ejb.SessionContext JavaDoc;
30 import javax.ejb.CreateException JavaDoc;
31
32 /**
33  * @ejb:bean
34  * type="Stateless"
35  * name="Facade"
36  * view-type="remote"
37  * @ejb.util generate="physical"
38  * @ejb:transaction type="Required"
39  * @ejb:transaction-type type="Container"
40  */

41 public class FacadeSessionBean
42    implements SessionBean JavaDoc
43 {
44    // Business methods
45

46    /**
47     * @ejb.interface-method
48     */

49    public ColorEnum getColorForId(IDClass id)
50       throws Exception JavaDoc
51    {
52       ChildLocal child = ChildUtil.getLocalHome().findByPrimaryKey(id);
53       return child.getColor();
54    }
55
56    /**
57     * @ejb.interface-method
58     */

59    public AnimalEnum getAnimalForId(IDClass id)
60       throws Exception JavaDoc
61    {
62       ChildLocal child = ChildUtil.getLocalHome().findByPrimaryKey(id);
63       return child.getAnimal();
64    }
65
66    /**
67     * @ejb.interface-method
68     */

69    public void setColor(IDClass id, ColorEnum color)
70       throws Exception JavaDoc
71    {
72       ChildLocal child = ChildUtil.getLocalHome().findByPrimaryKey(id);
73       child.setColor(color);
74    }
75
76    /**
77     * @ejb.interface-method
78     */

79    public void setAnimal(IDClass id, AnimalEnum animal)
80       throws Exception JavaDoc
81    {
82       ChildLocal child = ChildUtil.getLocalHome().findByPrimaryKey(id);
83       child.setAnimal(animal);
84    }
85
86    /**
87     * @ejb.interface-method
88     */

89    public void createChild(IDClass childId)
90       throws Exception JavaDoc
91    {
92       ChildUtil.getLocalHome().create(childId);
93    }
94
95    /**
96     * @ejb.interface-method
97     */

98    public void removeChild(IDClass childId)
99       throws Exception JavaDoc
100    {
101       ChildUtil.getLocalHome().remove(childId);
102    }
103
104    /**
105     * @ejb.interface-method
106     */

107    public IDClass findByColor(ColorEnum color)
108       throws Exception JavaDoc
109    {
110       ChildLocal child = ChildUtil.getLocalHome().findByColor(color);
111       return child.getId();
112    }
113
114    /**
115     * @ejb.interface-method
116     */

117    public IDClass findAndOrderByColor(ColorEnum color)
118       throws Exception JavaDoc
119    {
120       ChildLocal child = ChildUtil.getLocalHome().findAndOrderByColor(color);
121       return child.getId();
122    }
123
124    /**
125     * @ejb.interface-method
126     */

127    public IDClass findByColorDeclaredSql(ColorEnum color)
128       throws Exception JavaDoc
129    {
130       ChildLocal child = ChildUtil.getLocalHome().findByColorDeclaredSql(color);
131       return child.getId();
132    }
133
134    /**
135     * @ejb.interface-method
136     */

137    public List JavaDoc findLowColor(ColorEnum color)
138       throws Exception JavaDoc
139    {
140       Collection JavaDoc children = ChildUtil.getLocalHome().findLowColor(color);
141       List JavaDoc ids = new ArrayList JavaDoc(children.size());
142       for(Iterator JavaDoc i = children.iterator(); i.hasNext();)
143       {
144          ChildLocal child = (ChildLocal)i.next();
145          ids.add(child.getId());
146       }
147       return ids;
148    }
149
150    // SessionBean implementation
151

152    /**
153     * @exception CreateException Description of Exception
154     * @ejb.create-method
155     */

156    public void ejbCreate() throws CreateException JavaDoc
157    {
158    }
159
160    public void ejbActivate()
161    {
162    }
163
164    public void ejbPassivate()
165    {
166    }
167
168    public void ejbRemove()
169    {
170    }
171
172    public void setSessionContext(SessionContext JavaDoc ctx)
173    {
174    }
175 }
176
Popular Tags