KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > session > AllProjectsSessionBean


1 package hero.session;
2 /*
3 * 02/01/2002 - 15:24:07
4 *
5 * AllProjectsSessionEJB.java -
6 * Copyright (C) 2002 Ecoo Team
7 * valdes@loria.fr
8 *
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */

24
25 import hero.interfaces.BnProjectLocal;
26 import hero.interfaces.BnProjectLocalHome;
27 import hero.util.EventConstants;
28 import hero.util.HeroException;
29 import hero.util.StrutsProjectValue;
30
31 import java.util.ArrayList JavaDoc;
32 import java.util.Collection JavaDoc;
33 import java.util.Iterator JavaDoc;
34
35 import javax.ejb.CreateException JavaDoc;
36 import javax.ejb.FinderException JavaDoc;
37 import javax.ejb.SessionBean JavaDoc;
38 import javax.ejb.SessionContext JavaDoc;
39
40
41
42
43 /**
44  * Session Bean Template
45  *
46  * @ejb:bean name="AllProjectsSession"
47  * display-name="AllProjectsSession Bean"
48  * type="Stateless"
49  * transaction-type="Container"
50  * jndi-name="ejb/hero/AllProjectsSession"
51  * local-jndi-name="ejb/hero/AllProjectsSession_L"
52  *
53  * @ejb:ejb-ref ejb-name="BnProject"
54  * ref-name="myhero/BnProject"
55  * @ejb:transaction type="Supports"
56  * @ejb.permission unchecked="yes"
57  * @ejb.security-identity run-as="SuperAdmin"
58  * @jonas.bean
59  * ejb-name="AllProjectsSession"
60  * jndi-name="ejb/hero/AllProjectsSession"
61  *
62  *
63  **/

64
65 public class AllProjectsSessionBean implements SessionBean JavaDoc, EventConstants {
66
67
68    // -------------------------------------------------------------------------
69
// Static
70
// -------------------------------------------------------------------------
71

72    // -------------------------------------------------------------------------
73
// Members
74
// -------------------------------------------------------------------------
75

76    private SessionContext JavaDoc mContext;
77   
78    // -------------------------------------------------------------------------
79
// Methods
80
// -------------------------------------------------------------------------
81

82    /**
83    * Get all projects
84    *
85    * @ejb.permission unchecked="yes"
86    * @ejb:interface-method view-type="both"
87    * @ejb:transaction type="Supports"
88    *
89    **/

90        public Collection JavaDoc getProjects() throws HeroException {
91        BnProjectLocalHome pHome;
92        ArrayList JavaDoc projects = new ArrayList JavaDoc();
93
94        try {
95            pHome=hero.interfaces.BnProjectUtil.getLocalHome();
96        } catch (javax.naming.NamingException JavaDoc be) {
97            throw new HeroException(be.getMessage());
98        }
99        try {
100            Collection JavaDoc allProjects= pHome.findAll();
101            Iterator JavaDoc i = allProjects.iterator();
102            while(i.hasNext()) {
103            BnProjectLocal pvalue = (BnProjectLocal)i.next();
104            StrutsProjectValue spv = new StrutsProjectValue();
105            spv.setName(pvalue.getName());
106            spv.setCreator(pvalue.getCreator());
107            spv.setState(hero.interfaces.Constants.Pj.projectStateName[pvalue.getState()]);
108            spv.setNact(pvalue.getBnNodes().size());
109            spv.setNusers(pvalue.getBnUsers().size());
110            projects.add(spv);
111            }
112            return((Collection JavaDoc)projects);
113
114        } catch (FinderException JavaDoc fe) {
115            throw new HeroException(fe.getMessage());}
116        }
117    /**
118    * Create the All Projects Session Bean
119    *
120    * @throws CreateException
121    *
122    * @ejb.permission unchecked="yes"
123    * @ejb:create-method view-type="both"
124    **/

125
126     public void ejbCreate() throws CreateException JavaDoc {
127     }
128     
129     public void setSessionContext(final javax.ejb.SessionContext JavaDoc context) {
130     mContext = context;
131     }
132     
133     public void ejbRemove() {
134     }
135     
136     public void ejbActivate() {
137     }
138     
139     public void ejbPassivate() {
140     }
141     
142 }
143
Popular Tags