Source Code Cross Referenced for M2MBManagerBean.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » foedeployer » ejb » m2mb » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » testsuite » org.jboss.test.foedeployer.ejb.m2mb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.foedeployer.ejb.m2mb;
023:
024:        import java.sql.Date;
025:        import java.util.Collection;
026:        import java.util.HashSet;
027:        import java.util.Set;
028:        import java.util.Iterator;
029:        import java.util.ArrayList;
030:
031:        import java.rmi.RemoteException;
032:
033:        import javax.ejb.SessionBean;
034:        import javax.ejb.SessionContext;
035:        import javax.ejb.EJBException;
036:        import javax.ejb.CreateException;
037:        import javax.ejb.FinderException;
038:        import javax.ejb.RemoveException;
039:
040:        import javax.naming.Context;
041:        import javax.naming.InitialContext;
042:        import javax.naming.NamingException;
043:
044:        import javax.rmi.PortableRemoteObject;
045:
046:        import org.apache.log4j.Category;
047:
048:        /**
049:         * Manager session bean.
050:         *
051:         * @ejb.bean
052:         *    type="Stateless"
053:         *    name="M2MBManager"
054:         *    jndi-name="M2MBManagerEJB.M2MBManagerHome"
055:         *    generate="true"
056:         *    view-type="remote"
057:         *
058:         * @ejb.ejb-ref
059:         *    ejb-name="Project"
060:         *    view-type="local"
061:         * @ejb.ejb-ref
062:         *    ejb-name="Developer"
063:         *    view-type="local"
064:         *
065:         * @ejb.transaction type="Required"
066:         */
067:        public class M2MBManagerBean implements  SessionBean {
068:            // Attributes --------------------------------------------------
069:            static Category log = Category.getInstance(M2MBManagerBean.class);
070:
071:            static String PROJECT_NAME = "java:comp/env/ejb/Project";
072:            static String DEVELOPER_NAME = "java:comp/env/ejb/Developer";
073:
074:            private ProjectLocalHome projectHome;
075:            private DeveloperLocalHome developerHome;
076:
077:            // Business methods ---------------------------------------------
078:            /**
079:             * Creates a project
080:             *
081:             * @ejb.interface-method
082:             */
083:            public void createProject(String projectName) {
084:                try {
085:                    projectHome.create(projectName);
086:                } catch (CreateException ce) {
087:                    throw new EJBException(ce);
088:                }
089:            }
090:
091:            /**
092:             * Creates a developer
093:             *
094:             * @ejb.interface-method
095:             */
096:            public void createDeveloper(String developerName) {
097:                try {
098:                    developerHome.create(developerName);
099:                } catch (CreateException ce) {
100:                    throw new EJBException(ce);
101:                }
102:            }
103:
104:            /**
105:             * Returns developers for project
106:             *
107:             * @ejb.interface-method
108:             */
109:            public Collection getDevelopersForProject(String projectName) {
110:                try {
111:                    ProjectLocal project = projectHome
112:                            .findByPrimaryKey(projectName);
113:                    Collection devs = new ArrayList();
114:                    for (Iterator iter = project.getDevelopers().iterator(); iter
115:                            .hasNext();) {
116:                        DeveloperLocal developer = (DeveloperLocal) iter.next();
117:                        devs.add(developer.getName());
118:                    }
119:                    return devs;
120:                } catch (FinderException fe) {
121:                    throw new EJBException(fe);
122:                }
123:            }
124:
125:            /**
126:             * Returns projects for developer
127:             *
128:             * @ejb.interface-method
129:             */
130:            public Collection getProjectsForDeveloper(String developerName) {
131:                try {
132:                    DeveloperLocal developer = developerHome
133:                            .findByPrimaryKey(developerName);
134:                    Collection prjs = new ArrayList();
135:                    for (Iterator iter = developer.getProjects().iterator(); iter
136:                            .hasNext();) {
137:                        ProjectLocal project = (ProjectLocal) iter.next();
138:                        prjs.add(project.getName());
139:                    }
140:                    return prjs;
141:                } catch (FinderException fe) {
142:                    throw new EJBException(fe);
143:                }
144:            }
145:
146:            /**
147:             * Adds a project to developer
148:             *
149:             * @ejb.interface-method
150:             */
151:            public void addProjectToDeveloper(String developerName,
152:                    String projectName) {
153:                try {
154:                    DeveloperLocal dev = developerHome
155:                            .findByPrimaryKey(developerName);
156:                    ProjectLocal prj = projectHome
157:                            .findByPrimaryKey(projectName);
158:                    dev.getProjects().add(prj);
159:                } catch (Exception e) {
160:                    throw new EJBException(e);
161:                }
162:            }
163:
164:            /**
165:             * Adds a develeloper to project
166:             *
167:             * @ejb.interface-method
168:             */
169:            public void addDeveloperToProject(String projectName,
170:                    String developerName) {
171:                try {
172:                    DeveloperLocal dev = developerHome
173:                            .findByPrimaryKey(developerName);
174:                    ProjectLocal prj = projectHome
175:                            .findByPrimaryKey(projectName);
176:                    prj.getDevelopers().add(dev);
177:                } catch (Exception e) {
178:                    throw new EJBException(e);
179:                }
180:            }
181:
182:            /**
183:             * Removes project if exists
184:             *
185:             * @ejb.interface-method
186:             */
187:            public void removeProjectIfExists(String projectName) {
188:                try {
189:                    ProjectLocal project = projectHome
190:                            .findByPrimaryKey(projectName);
191:                    project.remove();
192:                } catch (Exception e) {
193:                    // yam-yam
194:                }
195:            }
196:
197:            /**
198:             * Removes developer if exists
199:             *
200:             * @ejb.interface-method
201:             */
202:            public void removeDeveloperIfExists(String developerName) {
203:                try {
204:                    DeveloperLocal developer = developerHome
205:                            .findByPrimaryKey(developerName);
206:                    developer.remove();
207:                } catch (Exception e) {
208:                    // yam-yam
209:                }
210:            }
211:
212:            // SessionBean implementation -------------------------------------
213:
214:            public void setSessionContext(SessionContext c) {
215:                try {
216:                    Context ic = new InitialContext();
217:                    developerHome = (DeveloperLocalHome) ic
218:                            .lookup(DEVELOPER_NAME);
219:                    projectHome = (ProjectLocalHome) ic.lookup(PROJECT_NAME);
220:                } catch (NamingException ne) {
221:                    throw new EJBException(ne);
222:                }
223:            }
224:
225:            /**
226:             * create method
227:             *
228:             * @ejb:create-method
229:             */
230:            public void ejbCreate() {
231:            }
232:
233:            public void ejbActivate() {
234:            }
235:
236:            public void ejbPassivate() {
237:            }
238:
239:            public void ejbRemove() {
240:            }
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.