Source Code Cross Referenced for EjbInfo.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » ejb » datamodel » 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 » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.ejb.datamodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        /*
043:         * EjbInfo.java
044:         *
045:         * Created on April 28, 2004, 4:58 PM
046:         */
047:
048:        package org.netbeans.modules.visualweb.ejb.datamodel;
049:
050:        import java.util.*;
051:
052:        /**
053:         * This class is to encapsulate the information Rave needs to know about an EJB
054:         *
055:         * @author cao
056:         */
057:        public class EjbInfo implements  java.lang.Cloneable, Comparable {
058:            public final static int STATELESS_SESSION_BEAN = 1;
059:            public final static int STATEFUL_SESSION_BEAN = 2;
060:            public final static int ENTITY_BEAN = 3;
061:            public final static int MESSAGE_DRIVEN_BEAN = 4;
062:
063:            private int beanType; // Must be one of the types listed above
064:            private String jndiName;
065:            private String ejbName;
066:            private String beanId; // Can be null for SunAppServer and weblogic. But needed for websphere
067:            private String homeInterfaceName;
068:            private String compInterfaceName;
069:            private String webEjbRef; // the ejb ref name used in web.xml/sun-web.xml
070:
071:            private String beanWrapperName;
072:            private String beanInfoWrapperName;
073:
074:            // A collection of business method - MethodInfo
075:            private ArrayList methodInfos = new ArrayList();
076:
077:            /**
078:             * Creates a session bean info
079:             */
080:            public EjbInfo(String jndiName, String ejbName,
081:                    String homeInterface, String compInterface) {
082:                this .beanType = STATELESS_SESSION_BEAN;
083:                this .jndiName = jndiName;
084:                this .ejbName = ejbName;
085:                this .homeInterfaceName = homeInterface;
086:                this .compInterfaceName = compInterface;
087:            }
088:
089:            public EjbInfo() {
090:            };
091:
092:            public void setBeanType(int type) {
093:                if (type != STATELESS_SESSION_BEAN
094:                        && type != STATEFUL_SESSION_BEAN && type != ENTITY_BEAN
095:                        && type != MESSAGE_DRIVEN_BEAN)
096:                    throw new java.lang.IllegalArgumentException(
097:                            "Invalid EJB type: " + type);
098:
099:                beanType = type;
100:            }
101:
102:            public void setBeanId(String id) {
103:                this .beanId = id;
104:            }
105:
106:            public void setEjbName(String name) {
107:                this .ejbName = name;
108:            }
109:
110:            public void setJNDIName(String jndiName) {
111:                this .jndiName = jndiName;
112:            }
113:
114:            public void setHomeInterfaceName(String interfaceName) {
115:                this .homeInterfaceName = interfaceName;
116:            }
117:
118:            public void setCompInterfaceName(String interfaceName) {
119:                this .compInterfaceName = interfaceName;
120:            }
121:
122:            public void setMethods(ArrayList methods) {
123:                this .methodInfos = methods;
124:            }
125:
126:            public void addMethod(MethodInfo method) {
127:                if (methodInfos == null)
128:                    methodInfos = new ArrayList();
129:
130:                methodInfos.add(method);
131:            }
132:
133:            public void setWebEjbRef(String webRef) {
134:                this .webEjbRef = webRef;
135:            }
136:
137:            public void setBeanWrapperName(String name) {
138:                this .beanWrapperName = name;
139:            }
140:
141:            public void setBeanInfoWrapperName(String name) {
142:                this .beanInfoWrapperName = name;
143:            }
144:
145:            public boolean isStatelessSessionBean() {
146:                if (this .beanType == STATELESS_SESSION_BEAN)
147:                    return true;
148:                else
149:                    return false;
150:            }
151:
152:            public int getBeanType() {
153:                return this .beanType;
154:            }
155:
156:            public String getJNDIName() {
157:                return this .jndiName;
158:            }
159:
160:            public String getEjbName() {
161:                return this .ejbName;
162:            }
163:
164:            public String getBeanId() {
165:                return this .beanId;
166:            }
167:
168:            public String getHomeInterfaceName() {
169:                return this .homeInterfaceName;
170:            }
171:
172:            public String getCompInterfaceName() {
173:                return this .compInterfaceName;
174:            }
175:
176:            public String getWebEjbRef() {
177:                return this .webEjbRef;
178:            }
179:
180:            public ArrayList getMethods() {
181:                // Sort it first
182:                ArrayList methods = new ArrayList(this .methodInfos);
183:                Collections.sort(methods);
184:                return methods;
185:            }
186:
187:            public boolean hasAnyMethodWithCollectionReturn() {
188:                for (Iterator iter = methodInfos.iterator(); iter.hasNext();) {
189:                    MethodInfo m = (MethodInfo) iter.next();
190:                    if (m.getReturnType().isCollection())
191:                        return true;
192:                }
193:
194:                // Didn't find any
195:                return false;
196:            }
197:
198:            public boolean hasAnyConfigurableMethod() {
199:                for (Iterator iter = methodInfos.iterator(); iter.hasNext();) {
200:                    MethodInfo m = (MethodInfo) iter.next();
201:                    if (m.isMethodConfigurable())
202:                        return true;
203:                }
204:
205:                // Didn't find any
206:                return false;
207:            }
208:
209:            public String getBeanTypeName() {
210:                // NOI18N
211:                switch (this .beanType) {
212:                case STATELESS_SESSION_BEAN:
213:                case STATEFUL_SESSION_BEAN:
214:                    return "Session"; // NOI18N
215:                case ENTITY_BEAN:
216:                    return "Entity"; // NOI18N
217:                case MESSAGE_DRIVEN_BEAN:
218:                    return "Message Driven Bean"; // NOI18N
219:                default:
220:                    return "Session"; // NOI18N
221:                }
222:            }
223:
224:            public String getBeanWrapperName() {
225:                return this .beanWrapperName;
226:            }
227:
228:            public String getBeanInfoWrapperName() {
229:                return this .beanInfoWrapperName;
230:            }
231:
232:            /**
233:             * The EJB can be auto be auto init() if it only has one init() and
234:             * it takes no arguments
235:             */
236:            public boolean canBeAutoInit() {
237:                int numCreateMethods = 0;
238:                boolean foundNonArgCreateMethod = false;
239:                for (Iterator iter = methodInfos.iterator(); iter.hasNext();) {
240:                    MethodInfo method = (MethodInfo) iter.next();
241:                    if (!method.isBusinessMethod()) {
242:                        // Found a create method
243:                        numCreateMethods++;
244:
245:                        // And found a create method w/o arguemnt
246:                        if (method.hasNoParameters())
247:                            foundNonArgCreateMethod = true;
248:                    }
249:                }
250:
251:                if (numCreateMethods == 1 && foundNonArgCreateMethod)
252:                    return true;
253:                else
254:                    return false;
255:            }
256:
257:            public String toString() {
258:                // NOI18N
259:                StringBuffer buf = new StringBuffer();
260:                buf.append("Type: " + getBeanType() + "\n");
261:                buf.append("JNDI name: " + getJNDIName() + "\n");
262:                buf.append("EJB name: " + getEjbName() + "\n");
263:                buf.append("EJB name: " + getBeanId() + "\n");
264:                buf.append("Home Interface: " + getHomeInterfaceName() + "\n");
265:                buf.append("Component Interface: " + getCompInterfaceName()
266:                        + "\n");
267:                buf.append("Web EJB Ref: " + getWebEjbRef() + "\n");
268:                buf.append("Wrapper Bean Name: " + getBeanWrapperName() + "\n");
269:                buf.append("Wrapper Bean Info Name: "
270:                        + getBeanInfoWrapperName() + "\n");
271:                if (getMethods() != null) {
272:                    buf.append("Num of methods: " + getMethods().size() + "\n");
273:                    buf.append(getMethods().toString());
274:                }
275:
276:                return buf.toString();
277:            }
278:
279:            public Collection getMethodNames() {
280:                ArrayList mNames = new ArrayList();
281:
282:                for (Iterator iter = methodInfos.iterator(); iter.hasNext();) {
283:                    MethodInfo mInfo = (MethodInfo) iter.next();
284:                    mNames.add(mInfo.getName());
285:                }
286:
287:                return mNames;
288:            }
289:
290:            public MethodInfo getMethod(String name) {
291:                for (Iterator iter = methodInfos.iterator(); iter.hasNext();) {
292:                    MethodInfo mInfo = (MethodInfo) iter.next();
293:                    if (mInfo.getName().equals(name))
294:                        return mInfo;
295:                }
296:
297:                return null;
298:            }
299:
300:            public Object clone() {
301:                try {
302:                    EjbInfo ejbCopy = (EjbInfo) super .clone();
303:
304:                    // Methods
305:                    if (this .methodInfos != null) {
306:                        ArrayList mdCopy = new ArrayList();
307:
308:                        for (Iterator iter = this .methodInfos.iterator(); iter
309:                                .hasNext();) {
310:                            mdCopy.add(((MethodInfo) iter.next()).clone());
311:                        }
312:
313:                        ejbCopy.setMethods(mdCopy);
314:                    }
315:
316:                    return ejbCopy;
317:                } catch (java.lang.CloneNotSupportedException e) {
318:                    return null;
319:                }
320:            }
321:
322:            // Implementing Comparable
323:            public int compareTo(Object o) {
324:
325:                if (o == null || !(o instanceof  EjbInfo))
326:                    return 0;
327:
328:                String theOtherName = ((EjbInfo) o).getJNDIName();
329:
330:                if (this .getJNDIName() == null || theOtherName == null)
331:                    return 0;
332:
333:                return this.getJNDIName().compareTo(theOtherName);
334:            }
335:
336:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.