001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.cmp2.enums.ejb;
023:
024: import java.util.Collection;
025: import java.util.List;
026: import java.util.ArrayList;
027: import java.util.Iterator;
028: import javax.ejb.SessionBean;
029: import javax.ejb.SessionContext;
030: import javax.ejb.CreateException;
031:
032: /**
033: * @ejb:bean
034: * type="Stateless"
035: * name="Facade"
036: * view-type="remote"
037: * @ejb.util generate="physical"
038: * @ejb:transaction type="Required"
039: * @ejb:transaction-type type="Container"
040: */
041: public class FacadeSessionBean implements SessionBean {
042: // Business methods
043:
044: /**
045: * @ejb.interface-method
046: */
047: public ColorEnum getColorForId(IDClass id) throws Exception {
048: ChildLocal child = ChildUtil.getLocalHome()
049: .findByPrimaryKey(id);
050: return child.getColor();
051: }
052:
053: /**
054: * @ejb.interface-method
055: */
056: public AnimalEnum getAnimalForId(IDClass id) throws Exception {
057: ChildLocal child = ChildUtil.getLocalHome()
058: .findByPrimaryKey(id);
059: return child.getAnimal();
060: }
061:
062: /**
063: * @ejb.interface-method
064: */
065: public void setColor(IDClass id, ColorEnum color) throws Exception {
066: ChildLocal child = ChildUtil.getLocalHome()
067: .findByPrimaryKey(id);
068: child.setColor(color);
069: }
070:
071: /**
072: * @ejb.interface-method
073: */
074: public void setAnimal(IDClass id, AnimalEnum animal)
075: throws Exception {
076: ChildLocal child = ChildUtil.getLocalHome()
077: .findByPrimaryKey(id);
078: child.setAnimal(animal);
079: }
080:
081: /**
082: * @ejb.interface-method
083: */
084: public void createChild(IDClass childId) throws Exception {
085: ChildUtil.getLocalHome().create(childId);
086: }
087:
088: /**
089: * @ejb.interface-method
090: */
091: public void removeChild(IDClass childId) throws Exception {
092: ChildUtil.getLocalHome().remove(childId);
093: }
094:
095: /**
096: * @ejb.interface-method
097: */
098: public IDClass findByColor(ColorEnum color) throws Exception {
099: ChildLocal child = ChildUtil.getLocalHome().findByColor(color);
100: return child.getId();
101: }
102:
103: /**
104: * @ejb.interface-method
105: */
106: public IDClass findAndOrderByColor(ColorEnum color)
107: throws Exception {
108: ChildLocal child = ChildUtil.getLocalHome()
109: .findAndOrderByColor(color);
110: return child.getId();
111: }
112:
113: /**
114: * @ejb.interface-method
115: */
116: public IDClass findByColorDeclaredSql(ColorEnum color)
117: throws Exception {
118: ChildLocal child = ChildUtil.getLocalHome()
119: .findByColorDeclaredSql(color);
120: return child.getId();
121: }
122:
123: /**
124: * @ejb.interface-method
125: */
126: public List findLowColor(ColorEnum color) throws Exception {
127: Collection children = ChildUtil.getLocalHome().findLowColor(
128: color);
129: List ids = new ArrayList(children.size());
130: for (Iterator i = children.iterator(); i.hasNext();) {
131: ChildLocal child = (ChildLocal) i.next();
132: ids.add(child.getId());
133: }
134: return ids;
135: }
136:
137: // SessionBean implementation
138:
139: /**
140: * @exception CreateException Description of Exception
141: * @ejb.create-method
142: */
143: public void ejbCreate() throws CreateException {
144: }
145:
146: public void ejbActivate() {
147: }
148:
149: public void ejbPassivate() {
150: }
151:
152: public void ejbRemove() {
153: }
154:
155: public void setSessionContext(SessionContext ctx) {
156: }
157: }
|