Source Code Cross Referenced for Ejb3Creator.java in  » Ajax » dwr » org » directwebremoting » create » 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 » Ajax » dwr » org.directwebremoting.create 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.directwebremoting.create;
002:
003:        import java.util.Properties;
004:
005:        import javax.naming.Context;
006:        import javax.naming.InitialContext;
007:        import javax.naming.NamingException;
008:
009:        import org.directwebremoting.extend.Creator;
010:        import org.directwebremoting.util.LocalUtil;
011:        import org.directwebremoting.util.Messages;
012:
013:        /**
014:         * A Creator that works against EJB3 beans
015:         * @author Squishy [Squishy_I at gmx dot net]
016:         * @author Joe Walker [joe at getahead dot ltd dot uk]
017:         */
018:        public class Ejb3Creator extends AbstractCreator implements  Creator {
019:            /**
020:             * The common interface of the Bean.
021:             * <b>If you don't have a common interface from which local and remote are
022:             * derived, you have to set the bean name manually!</b>
023:             * The BeanName is fetched from the part of the String behind the last '.'
024:             * @param className The fully qualified class name of the Bean's interface
025:             */
026:            public void setInterface(String className) {
027:                this .className = className;
028:                this .bean = className.substring(className.lastIndexOf('.') + 1);
029:            }
030:
031:            /**
032:             * Set the name of the bean for the JNDI lookup
033:             * @param bean The JNDI name to lookup
034:             */
035:            public void setBean(String bean) {
036:                this .bean = bean;
037:            }
038:
039:            /**
040:             * Get local or remote interface?
041:             * Defaults remote
042:             * @param iface Either "local" for the local interface or anything else for the remote
043:             */
044:            public void setInterfaceType(String iface) {
045:                remote = !iface.equalsIgnoreCase(LOCAL);
046:            }
047:
048:            /**
049:             * Set the ending that is appended to the actual bean name fetched from the
050:             * interface name (UserMgr --> UserMgrBean). Defaults to "Bean"
051:             * @param beanNamePostfix The name to append to a bean before lookup
052:             */
053:            public void setBeanNamePostfix(String beanNamePostfix) {
054:                this .beanNamePostfix = beanNamePostfix;
055:            }
056:
057:            /* (non-Javadoc)
058:             * @see org.directwebremoting.Creator#getType()
059:             */
060:            public Class<?> getType() {
061:                try {
062:                    return LocalUtil.classForName(className);
063:                } catch (ClassNotFoundException ex) {
064:                    throw new IllegalArgumentException(Messages.getString(
065:                            "Creator.BeanClassNotFound", className));
066:                }
067:            }
068:
069:            /* (non-Javadoc)
070:             * @see org.directwebremoting.Creator#getInstance()
071:             */
072:            public Object getInstance() throws InstantiationException {
073:                String type = remote ? "remote" : "local";
074:
075:                Context jndi = null;
076:
077:                try {
078:                    Properties props = new Properties();
079:                    props.load(getClass().getResourceAsStream(
080:                            "/jndi.properties"));
081:                    jndi = new InitialContext(props);
082:
083:                    return jndi.lookup(bean + beanNamePostfix + "/" + type);
084:                } catch (Exception ex) {
085:                    throw new InstantiationException(bean + "/" + type
086:                            + " not bound:" + ex.getMessage());
087:                } finally {
088:                    if (jndi != null) {
089:                        try {
090:                            jndi.close();
091:                        } catch (NamingException ex) {
092:                            // Ignore
093:                        }
094:                    }
095:                }
096:            }
097:
098:            /**
099:             * Constant for local/remote lookup
100:             */
101:            private static final String LOCAL = "local";
102:
103:            /**
104:             * Are we using a remote interface? Default == true
105:             */
106:            private boolean remote = true;
107:
108:            /**
109:             * The name of the bean
110:             */
111:            private String bean;
112:
113:            /**
114:             * The type of the bean
115:             */
116:            private String className;
117:
118:            /**
119:             * A suffix to help lookup
120:             */
121:            private String beanNamePostfix = "Bean";
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.